Modifying a 'Game of Life' Script


#1

Hi,

I’m looking to modify a script that performs a Game of Life function on a number of cells in order to generate a 3-Dimensional Volume. Currently the input values for the cells are randomized, but I would like to have direct control over these inputs. Is it possible to set these values either manually, or based on values from a black and white image (a la the grasshopper image sampler)? Because these arrays are often 20x20, I would prefer the latter.

Any help would be greatly appreciated. Thanks!

I only included the portion of the script that seemed relevant, if you need more information I would be happy include it.

def randomizeArray(intLength,intWidth):

arr = []

for j in range(intWidth):

	arri = []

	for i in range(intLength):

		rnd = random.random()

		arri.append(rnd)

	arr.append(arri)

return arr

def Main():

intLength = rs.GetInteger("how many in x",30)

intWidth  = rs.GetInteger("how many in y",30)

intGen	  = rs.GetInteger("how many generations",60)

strStack  = rs.GetString ("should I stack the generations", "yes", ["yes", "no"])

crvs = rs.GetObjects("select the crvs",4)

thres = rs.GetReal("type the threshold to voxelize",1)

allValues = []

arrValues = randomizeArray(intLength,intWidth)

for i in range(100):

	arrValues = applyGOL(arrValues)

allValues.append(arrValues)

#arrMeshes = render(arrValues,-1, strStack)

for i in range(intGen-1):

	arrValues = applyGOLCrvs(arrValues, i, crvs)

	allValues.append(arrValues)

	"""

	if strStack == "no" :

		update(arrMeshes, arrValues)

	else :

		render(arrValues,i, strStack) 

	"""

myVoxels = voxels(intLength,intWidth,intGen, allValues)

myVoxels.voxelize(thres)

#Call DeleteObjects2dArray(arrMeshes)

Main()


(Dale Fugier) #2

Does this help?