novelty and the perverse of the urban wild
non-working script:
it should work soon, but i'm still learning the lingo. if it starts to work- it should be able to evaluate new generations by assessing the previous generation, without going back to the initial iteration in the first two examples i posted.

right now i'm working on converting max percent to max number in the evaluate function.



option explicit
'balancing loop feedback system

'this is the main order of the script- it funtions like a table of contents
sub main
'call the userInput function to get initial variables
userInputs
'RETURNS:
'userInputs(0) = intIterations
'userInputs(1) = intPopulation
'userInputs(2) = intStartXPercentage
'userInputs(3) = intStartYPercentage
'userInputs(4) = maxPercentZ
'userInputs(5) = maxPercentX
'userInputs(6) = maxPercentY
'call the setup function to create our initial state and all necessary geometry
setup
'RETURNS:
'setup(0) = arrPopulationMembers
'setup(1) = arrPopulationMembers
if i > intIterations - 1 then
'before moving on create an image record of the previous generation
printScreen
'call the assess function to assess the current population
assess (arrPopulationMembersState)
'call the evaluate function to define the influences on the next generation
evaluate (userInputs(1), userInputs(5), maxNumberOfY, maxNumberOfZ)
'progress the counter
i = i + 1
end if
end sub

'array objects
'end of first generation (definition of initial state)

'
'this section loops to produce each generation after the first
function evaluate (intPopulation, maxNumberOfX, maxNumberOfY, maxNumberOfZ)
dim maxNumberOfX, maxNumberOfY, maxNumberOfZ
'now that we have assessed the demographics of the population, use this data to define the makeup of the next generation
'use 'consensus'/majority to establish desired state
if assess(0) > intPopulation/ 3 then
desiredState = X
else if assess(1) > intPopulation/ 3 then
desiredState = Y
else desiredState = Z
End if
'convert max percent to max number
#######################################
'enforce cap to prevent total domination
if assess(0) > maxNumberOfX then desiredState = Y
if assess(1) > maxNumberOfY then desiredState = Z
if assess(2) > maxNumberOfZ then desiredState = X
if desiredState = X then
End if
end function

Function makeObjects

End Function

'
function userInput
dim arrUserInputs(6)
arrUserInputs(0) = rhino.getInteger ("input Iteration", 2, 1)
if isNull(arrUserInputs(0)) then exit Function
arrUserInputs(1) = rhino.getInteger ("input population", 100, 2, 10000)
if isNull(arrUserInputs(1)) then exit Function
arrUserInputs(2) = rhino.getInteger ("input percentage of X", 67, 1, 100)
if isNull(arrUserInputs(2)) then exit Function
arrUserInputs(3) = rhino.getInteger ("input percentage of Y", (intPopulation - intStartXPercentage) / 2, 1, 100 - intStartXPercentage)
if isNull(arrUserInputs(3)) then exit Function
arrUserInputs(4) = rhino.getInteger ("input maximum percentage of Z", 90, 1, 100)
if isNull(arrUserInputs(4)) then exit Function
arrUserInputs(5) = rhino.getInteger ("input maximum percentage of X", 90, 1, 100)
if isNull(arrUserInputs(5)) then exit Function
arrUserInputs(6) = rhino.getInteger ("input maximum percentage of Y", 90, 1, 100)
if isNull(arrUserInputs(6)) then exit Function
userInput = arrUserInputs
end function

'
function Setup
dim imageLocation
dim l
dim intPopulation, intStartXPercentage
dim numberOfX, maxPercentX, numberOfY, maxPercentY, intStartYPercentage, numberOfZ, maxPercentZ
dim Y, X, Z
dim intNewXPercentage, intNewPopulation
dim arrPopulationMembersState(), maxCurrentRow, currentMemberState, desiredState
dim arrBoxPts, arrBoxPt0, arrBoxPt1, arrBoxPt2, arrBoxPt3, arrBoxPt4, arrBoxPt5, arrBoxPt6, arrBoxPt7
dim i, j, k, intNumberPerRow, arrPopulationMembers(), blnYX
dim arrReturns(1)
'for cones(X)
'for spheres (Y)
'for cubes (Z)
'initial distribution of X, Y, Z
'setup of population percentages
'spheres are Y, cones are X, cubes are Z
i = 0
j = 0
k = 0
intNumberPerRow = int(intPopulation ^ (1/2)) - 1
maxCurrentRow = intNumberPerRow
redim arrPopulationMembers(-1)
redim arrPopulationMembersState(-1)

'build the population
For i = 0 to (intPopulation - 1)
redim preserve arrPopulationMembers(uBound(arrPopulationMembers)+1)
redim preserve arrPopulationMembersState(uBound(arrPopulationMembers)+1)
arrBoxPt0 = array(k*5 + 0.5, j*5 - 0.5, -0.5)
arrBoxPt1 = array(k*5 + 0.5, j*5 + 0.5, -0.5)
arrBoxPt2 = array(k*5 - 0.5, j*5 + 0.5, -0.5)
arrBoxPt3 = array(k*5 - 0.5, j*5 - 0.5, -0.5)
arrBoxPt4 = array(k*5 + 0.5, j*5 - 0.5, 0.5)
arrBoxPt5 = array(k*5 + 0.5, j*5 + 0.5, 0.5)
arrBoxPt6 = array(k*5 - 0.5, j*5 + 0.5, 0.5)
arrBoxPt7 = array(k*5 - 0.5, j*5 - 0.5, 0.5)
'create boxes (Z)
arrBoxPts = array(arrBoxPt0, arrBoxPt1, arrBoxPt2, arrBoxPt3, arrBoxPt4, arrBoxPt5, arrBoxPt6, arrBoxPt7)
arrPopulationMembers(i) = Rhino.AddBox (arrBoxPts)
arrPopulationMembersState(i) = Z

'create cones (X)
If rnd(1)<intStartXPercentage/100 then
rhino.deleteObject(arrPopulationMembers(i))
arrPopulationMembers(i) = Rhino.AddCone (array(k*5,j*5,0), array(k*5,j*5,1), 1)
arrPopulationMembersState(i) = X
End If
'create spheres (Y)
If rnd(1)<intStartXPercentage/100 then
rhino.deleteObject(arrPopulationMembers(i))
arrPopulationMembers(i) = Rhino.AddSphere (array(k*5,j*5,0), 1)
arrPopulationMembersState(i) = Y
End If
if i = maxCurrentRow then
maxCurrentRow = maxCurrentRow + intNumberPerRow
j = j + 1
End If
k = k + 1
if k

intNumberPerRow then k

0
'loop to create the next object
Next
arrReturns(0) = arrPopulationMembers
arrReturns(1) = arrPopulationMembersState
setup = arrReturns
end function

'
function assess (arrPopulationMembersState)
dim arrStatesTotals(2), currentMemberState
'assess the population produced in the previous generation to establish desired state
For each currentMemberState in arrPopulationMembersState
if currentMemberState

X then numberOfX

numberOfX + 1
if currentMemberState

Y then numberOfY

numberOfY + 1
if currentMemberState

Z then numberOfZ

numberOfZ + 1
Next
arrStatesTotals(0) = numberOfX
arrStatesTotals(1) = numberOfY
arrStatesTotals(2) = numberOfZ
assess = arrStatesTotals
end function

'
Function printScreen
'run iterations of populate function
For l = 0 to (intIterations - 1)
Rhino.command ("selall")
Rhino.command ("delete")
Rhino.command ("selnone")
' get top view
Rhino.command ("-_SetView _World _Top")
' screengrab
imageLocation = ("-_ScreenCaptureToFile E:\0shit\screencraps\001\screencraps" & (l) & ".jpg enter")
Rhino.command (imageLocation)
' get front view
Rhino.command ("-_SetView _World _Perspective")
Next
if l = (intIterations - 1) then exit sub
end Function