juney jaeyual 20120510 Final Project

uploaded our presentation slides for now… will compile them into a board and e-mail it to you by the may 17th.

FINAL PRESENTATION – Juney + Jaeyual

juney jaeyual 20120510 Final Project

 

import rhinoscriptsyntax as rs
from random import choice
import random
from System.Drawing import Color

Xnumber = 3
Ynumber = 3
Znumber = 3

smallunitpercentage = 0.7

iterations = 1

# 1. CELL (Condition/Rules)
class Cell():
def __init__(self, x, y, z):
self.X = x
self.Y = y
self.Z = z
self.Pos = [x,y,z]
self.Visibility = False # Cell’s visibility(True means On/Alive, False means Off/Dead)
self.N = 0 # Number of Neighboring Cells

def getVisibility(self):
return self.Visibility

def setVisibility(self, v): # v will be True or False
self.Visibility = v

def getN(self):
return self.N

def setN(self, n): # n is the number of neighbors
self.N = n

def getX(self):
return self.X

def getY(self):
return self.Y

def getZ(self):
return self.Z

def getPos(self):
return self.Pos

def updateVisibility(self):
if (self.Visibility == True): # ALIVE cell = apply rule1_visibility
self.rule1_Visibility()
else: #(self.Visibility == False) # DEAD cell = apply rule2_visibility
self.rule2_Population()

def rule1_Visibility(self):
if (self.N < 10):
self.setVisibility(False)
elif (self.N < 18):
self.setVisibility(True)
else:
self.setVisibility(False)

def rule2_Population(self):
if (self.N == 0 or self.N == 5 or self.N == 10):
self.setVisibility(True)
elif (self.N < 10):
self.setVisibility(False)
elif (self.N < 18):
self.setVisibility(True)
else:
pass

# 2. SET OF CELLS
class SetOfCells():
def __init__(self):
self.ListCells = [] # list containing all cell classes
self.generateCells() # these two functions automatically run when the class is initiated.
self.setSeeds()

def generateCells(self):
xCellList = [] # this is the outer list of nested list(ListCells)
for x in range(Xnumber):
yCellList = [] # this is the inner list of a nested list(ListCells)
for y in range(Ynumber):
zCellList = []
for z in range(Znumber):
c = Cell(x,y,z)
zCellList.append(c)
yCellList.append(zCellList)
xCellList.append(yCellList)
self.ListCells = xCellList # returns the nested list into self.ListCells

def setSeeds(self): # this function defines initial states of cells
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
if (x > 0 and x < Xnumber and y > 0 and y < Ynumber and z > 0 and z < Znumber): # initial condition
cell.setVisibility(True)
else:
cell.setVisibility(False)

def getCells(self): # getter for self.ListCells
return self.ListCells

# 3. AUTOMATA CONTROLLER
class AutomataController():
def __init__(self):
self.ListCells = []
self.SC = SetOfCells() # generate cells and contain them in a list
self.M = AutomataModel() # initiates AutomataModel

def initiateModel(self):
self.ListCells = self.SC.getCells() # gets the generated cells
self.M.setListCells(self.ListCells) # passes the list of cells into AutomataModel
self.M.repeatProcesses() # calls repeating processes

# 4. AUTOMATA MODEL
class AutomataModel():
def __init__(self):
self.ListCells = [] # will be passed by AutomataConroller
self.V = AutomataView() # initiates View class

def setListCells(self, lc): # s etter
self.ListCells = lc

def repeatProcesses(self): # repeats the two processes and make geometries
iterationNumber = iterations
for i in range(iterationNumber):
self.checkNeighboringCells()
self.updateCellVisibility()
self.V.setListCells(self.ListCells) # passes self.ListCells into View
points = self.V.getCoordinates() # makes Geometries
center = self.V.getCenter()
self.V.makeUnits (points, center)
self.V.moveGeometries() # deletes geometries for the next iteration

def checkNeighboringCells(self): # the “1)” process
for i in range(1,Xnumber-1):
for j in range(1,Ynumber-1):
for k in range(1,Znumber-1):
cell = self.ListCells[i][j][k] # gets each cell information
x = cell.getX()
y = cell.getY()
z = cell.getZ()
n = self.calculateNumberOfNeighboringCells(x,y,z)
cell.setN(n)

def calculateNumberOfNeighboringCells(self, x, y, z):
cell0 = self.ListCells[x-1][y-1][z-1]
cell1 = self.ListCells[x][y-1][z-1]
cell2 = self.ListCells[x+1][y-1][z-1]
cell3 = self.ListCells[x-1][y][z-1]
cell4 = self.ListCells[x][y][z-1]
cell5 = self.ListCells[x+1][y][z-1]
cell6 = self.ListCells[x-1][y+1][z-1]
cell7 = self.ListCells[x][y+1][z-1]
cell8 = self.ListCells[x+1][y+1][z-1]

cell9 = self.ListCells[x-1][y-1][z]
cell10 = self.ListCells[x][y-1][z]
cell11 = self.ListCells[x+1][y-1][z]
cell12 = self.ListCells[x-1][y][z]
cell13 = self.ListCells[x+1][y][z]
cell14 = self.ListCells[x-1][y+1][z]
cell15 = self.ListCells[x][y+1][z]
cell16 = self.ListCells[x+1][y+1][z]

cell17 = self.ListCells[x-1][y-1][z+1]
cell18 = self.ListCells[x][y-1][z+1]
cell19 = self.ListCells[x+1][y-1][z+1]
cell20 = self.ListCells[x-1][y][z+1]
cell21 = self.ListCells[x][y][z+1]
cell22 = self.ListCells[x+1][y][z+1]
cell23 = self.ListCells[x-1][y+1][z+1]
cell24 = self.ListCells[x][y+1][z+1]
cell25 = self.ListCells[x+1][y+1][z+1]

v0 = cell0.getVisibility()
v1 = cell1.getVisibility()
v2 = cell2.getVisibility()
v3 = cell3.getVisibility()
v4 = cell4.getVisibility()
v5 = cell5.getVisibility()
v6 = cell6.getVisibility()
v7 = cell7.getVisibility()
v8 = cell8.getVisibility()
v9 = cell9.getVisibility()
v10 = cell10.getVisibility()
v11 = cell11.getVisibility()
v12 = cell12.getVisibility()
v13 = cell13.getVisibility()
v14 = cell14.getVisibility()
v15 = cell15.getVisibility()
v16 = cell16.getVisibility()
v17 = cell17.getVisibility()
v18 = cell18.getVisibility()
v19 = cell19.getVisibility()
v20 = cell20.getVisibility()
v21 = cell21.getVisibility()
v22 = cell22.getVisibility()
v23 = cell23.getVisibility()
v24 = cell24.getVisibility()
v25 = cell25.getVisibility()

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

return sum

def updateCellVisibility(self): # the “2)” process
for x in range(1,Xnumber-1):
for y in range(1,Ynumber-1):
for z in range(1,Znumber-1):
cell = self.ListCells[x][y][z]
cell.updateVisibility()

# 5. AUTOMATA VIEW
class AutomataView():
def __init__(self):
self.ListCells = [] # will be passed by AutomataModel
self.S = smallunit ()
self.B = bigunit ()

def setListCells(self, lc):
self.ListCells = lc

def getCoordinates(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
ptlist.append (pos)
length = len (ptlist)
return ptlist

def getCenter(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
shift = 0.5
center = [pos[0]+shift, pos[1]+shift, pos[2]]
ptlist.append (center)
print ptlist
return ptlist

def makeUnits (self, points, center):
length = len (points)
print “point list =”, points
print “point list length =”, length #prints # of POINTS

percent = smallunitpercentage * length # set PERECNTAGE
minority = int(percent) # count of input percentage of all POINTS
print “minority # =”, minority
majority = length – minority # count of remaining percentage of all POINTS

minorityrandomlist = []
for i in range(minority):
randomvalues = random.randint (0, length-1)
minorityrandomlist.append (randomvalues)

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders
minorityrandomlist.sort() #sorts the list in ascending order
print “minority random list =”, minorityrandomlist

majorityrandomlist = []
for i in range (length):
majorityrandomlist.append (i)
print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:
majorityrandomlist.remove (x)

self.S.makeunit (minorityrandomlist, points, center)
self.B.makeunit (majorityrandomlist, points, center)

def moveGeometries(self):
#rs.Sleep(1000)
allObjIDs = rs.AllObjects()
trans = [0,0,Znumber-1]
rs.MoveObjects(allObjIDs, trans)

###

# CLASS FOR MAKING SMALL UNITS
class smallunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()
self.mullion = mullion_s()
self.railing = railing()
self.randomangle = randomangle()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.railingheight = 0.1
self.floorheight = 0.5
self.xdimension = 0.5
self.ydimension = 1

def makeunit (self, unitnumber, points, center):

for r in unitnumber :
rs.AddLayer(“Small Unit”, Color.Red)
rs.CurrentLayer(“Small Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)

slabs = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)
wall1 = self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
wall2 = self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

glass1 = self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
glass2 = self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

mullion1 = self.mullion.mullion(pt2, pt1, pt0, -self.glassoffset, self.floorheight, self.slabthickness)
mullion2 = self.mullion.mullion(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

railing = self.railing.railingmaker(rectangle, self.railingheight, self.floorheight)

angle = self.randomangle.generator()

verticalshift = [0, 0.5]
shift = choice(verticalshift)
path = [0, 0, shift]

rs.RotateObjects(slabs, center[r], angle)
rs.RotateObjects(wall1, center[r], angle)
rs.RotateObjects(wall2, center[r], angle)
rs.RotateObjects(glass1, center[r], angle)
rs.RotateObjects(glass2, center[r], angle)
rs.RotateObjects(mullion1, center[r], angle)
rs.RotateObjects(mullion2, center[r], angle)
rs.RotateObjects(railing, center[r], angle)

rs.MoveObjects(slabs, path)
rs.MoveObjects(wall1, path)
rs.MoveObjects(wall2, path)
rs.MoveObjects(glass1, path)
rs.MoveObjects(glass2, path)
rs.MoveObjects(mullion1, path)
rs.MoveObjects(mullion2, path)
rs.MoveObjects(railing, path)

#rs.DeleteObject(path)

rs.DeleteObject(rectangle)

# CLASS FOR MAKING BIG UNITS
class bigunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()
self.mullion = mullion_b()
self.railing = railing()
self.randomangle = randomangle()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.railingheight = 0.1
self.floorheight = 1
self.xdimension = 1
self.ydimension = 1

def makeunit (self, unitnumber, points, center):
for r in unitnumber :
rs.AddLayer(“Large Unit”, Color.Blue)
rs.CurrentLayer(“Large Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)
slab = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)

wall1 = self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
wall2 = self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

glass1 = self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
glass2 = self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

mullion1 = self.mullion.mullion(pt2, pt1, pt0, -self.glassoffset, self.floorheight, self.slabthickness)
mullion2 = self.mullion.mullion(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

railing = self.railing.railingmaker(rectangle, self.railingheight, self.floorheight)

angle = self.randomangle.generator()

slab = rs.RotateObjects(slab, center[r], angle)
wall1 = rs.RotateObjects(wall1, center[r], angle)
wall2 = rs.RotateObjects(wall2, center[r], angle)
glass1 = rs.RotateObjects(glass1, center[r], angle)
glass2 = rs.RotateObjects(glass2, center[r], angle)
mullion1 = rs.RotateObjects(mullion1, center[r], angle)
mullion2 = rs.RotateObjects(mullion2, center[r], angle)
railing = rs.RotateObjects(railing, center[r], angle)

rs.DeleteObject(rectangle)

# CLASS FOR MAKING SLABS
class slabmaker():
def __init__(self):
pass

def slabmaker(self, curve, slabthickness, floorheight):
path1 = rs.AddLine([0,0,0], [0,0,-slabthickness]) # Slab Thickness
extrusion = rs.ExtrudeCurve (curve, path1)
rs.CapPlanarHoles(extrusion)
copy = rs.CopyObject(extrusion, [0,0,floorheight])

return extrusion, copy

rs.DeleteObject(curve)
rs.DeleteObject(path1)

# CLASS FOR MAKING WALLS
class wall():
def __init__(self):
pass

def wall(self, point1, wallthickness, walllength, floorheight, slabthickness):
rs.AddLayer(“Wall”, Color.White)
rs.CurrentLayer(“Wall”)

rectangle = rs.AddRectangle(point1, wallthickness, walllength)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (rectangle, path)
rs.CapPlanarHoles(extrusion)

return extrusion

rs.DeleteObjects(rectangle)
rs.DeleteObject(path)

# CLASS FOR MAKING GLASS
class glass():
def __init__(self):
pass

def glass(self, point1, point2, directionpoint, offset, floorheight, slabthickness):
rs.AddLayer(“Glass”, Color.Gold)
rs.CurrentLayer(“Glass”)

line = rs.AddLine(point1, point2)
offset = rs.OffsetCurve(line, directionpoint, offset)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (offset, path)

return extrusion

rs.DeleteObjects(offset)
rs.DeleteObjects(line)
rs.DeleteObject(path)

# CLASS FOR MAKING MULLION
class mullion_s():
def __init__(self):
pass
def mullion(self, point1, point2, directionpoint, offset, floorheight, slabthickness):
rs.AddLayer(“Mullion”, Color.Aqua)
rs.CurrentLayer(“Mullion”)

line = rs.AddLine(point1, point2)

points = rs.DivideCurve(line, 2, False, True)
print points
pt1 = rs.AddPoint(points[1])

pt1_1 = rs.CopyObject(pt1, [0,0,floorheight-slabthickness])

mline_1 = rs.AddLine(pt1, pt1_1)

pt4 = rs.CopyObject(pt1, [0,offset,0])
height = rs.AddLine(pt1, pt4)

rec1 = rs.ExtrudeCurve(mline_1, height)

mullions = [rec1]
return mullions

rs.DeleteObjects(points)
rs.DeleteObject(line)
rs.DeleteObject(pt1)
rs.DeleteObject(pt1_1)
rs.DeleteObject(mline_1)
rs.DeleteObject(pt4)
rs.DeleteObject(height)

class mullion_b():
def __init__(self):
pass
def mullion(self, point1, point2, directionpoint, offset, floorheight, slabthickness):
rs.AddLayer(“Mullion”, Color.Aqua)
rs.CurrentLayer(“Mullion”)

line = rs.AddLine(point1, point2)

points = rs.DivideCurve(line, 4, False, True)
print points
pt1 = rs.AddPoint(points[1])
pt2 = rs.AddPoint(points[2])
pt3 = rs.AddPoint(points[3])

pt1_1 = rs.CopyObject(pt1, [0,0,floorheight-slabthickness])
pt2_1 = rs.CopyObject(pt2, [0,0,floorheight-slabthickness])
pt3_1 = rs.CopyObject(pt3, [0,0,floorheight-slabthickness])

mline_1 = rs.AddLine(pt1, pt1_1)
mline_2 = rs.AddLine(pt2, pt2_1)
mline_3 = rs.AddLine(pt3, pt3_1)

pt4 = rs.CopyObject(pt1, [0,offset,0])
height = rs.AddLine(pt1, pt4)

rec1 = rs.ExtrudeCurve(mline_1, height)
rec2 = rs.ExtrudeCurve(mline_2, height)
rec3 = rs.ExtrudeCurve(mline_3, height)

mullions = [rec1, rec2, rec3]
return mullions

rs.DeleteObjects(points)
rs.DeleteObject(line)
rs.DeleteObject(pt1)
rs.DeleteObject(pt2)
rs.DeleteObject(pt3)
rs.DeleteObject(pt1_1)
rs.DeleteObject(pt2_1)
rs.DeleteObject(pt3_1)
rs.DeleteObject(mline_1)
rs.DeleteObject(mline_2)
rs.DeleteObject(mline_3)
rs.DeleteObject(pt4)
rs.DeleteObject(height)

# CLASS FOR RAILING
class railing():
def __init__(self):
pass

def railingmaker(self, curve, railingheight, floorheight):
rs.AddLayer(“Railing”, Color.Gray)
rs.CurrentLayer(“Railing”)

path1 = rs.AddLine([0,0,0], [0,0,railingheight]) # Slab Thickness
railing = rs.ExtrudeCurve (curve, path1)
railing = rs.MoveObject(railing, [0,0,floorheight])
return railing

rs.DeleteObject(curve)
rs.DeleteObject(path1)
# CLASS FOR RANDOMLY ROTATING INPUT OBJECT
class randomangle():
def __init__(self):
pass

def generator(self):
rotation = [0, 90, 180, 270]
angle = choice(rotation)
print angle
return angle

# 6. RUN AUTOMATA CONTORLLER
ac = AutomataController()
ac.initiateModel()

 

juney jaeyual 20120427

This slideshow requires JavaScript.

juney jaeyual 20120427

CA with two rotation loops, and vertical translation for unit type A.

import rhinoscriptsyntax as rs
from random import choice
import random
from System.Drawing import Color

Xnumber = 6
Ynumber = 6
Znumber = 6

smallunitpercentage = 0.6

iterations = 4

# 1. CELL (Condition/Rules)
class Cell():
def __init__(self, x, y, z):
self.X = x
self.Y = y
self.Z = z
self.Pos = [x,y,z]
self.Visibility = False # Cell’s visibility(True means On/Alive, False means Off/Dead)
self.N = 0 # Number of Neighboring Cells

def getVisibility(self):
return self.Visibility

def setVisibility(self, v): # v will be True or False
self.Visibility = v

def getN(self):
return self.N

def setN(self, n): # n is the number of neighbors
self.N = n

def getX(self):
return self.X

def getY(self):
return self.Y

def getZ(self):
return self.Z

def getPos(self):
return self.Pos

def updateVisibility(self):
if (self.Visibility == True): # ALIVE cell = apply rule1_visibility
self.rule1_Visibility()
else: #(self.Visibility == False) # DEAD cell = apply rule2_visibility
self.rule2_Population()

def rule1_Visibility(self):
if (self.N < 10):
self.setVisibility(False)
elif (self.N < 18):
self.setVisibility(True)
else:
self.setVisibility(False)

def rule2_Population(self):
if (self.N == 0 or self.N == 5 or self.N == 10):
self.setVisibility(True)
elif (self.N < 10):
self.setVisibility(False)
elif (self.N < 18):
self.setVisibility(True)
else:
pass

# 2. SET OF CELLS
class SetOfCells():
def __init__(self):
self.ListCells = [] # list containing all cell classes
self.generateCells() # these two functions automatically run when the class is initiated.
self.setSeeds()

def generateCells(self):
xCellList = [] # this is the outer list of nested list(ListCells)
for x in range(Xnumber):
yCellList = [] # this is the inner list of a nested list(ListCells)
for y in range(Ynumber):
zCellList = []
for z in range(Znumber):
c = Cell(x,y,z)
zCellList.append(c)
yCellList.append(zCellList)
xCellList.append(yCellList)
self.ListCells = xCellList # returns the nested list into self.ListCells

def setSeeds(self): # this function defines initial states of cells
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
if (x > 0 and x < Xnumber and y > 0 and y < Ynumber and z > 0 and z < Znumber): # initial condition
cell.setVisibility(True)
else:
cell.setVisibility(False)

def getCells(self): # getter for self.ListCells
return self.ListCells

# 3. AUTOMATA CONTROLLER
class AutomataController():
def __init__(self):
self.ListCells = []
self.SC = SetOfCells() # generate cells and contain them in a list
self.M = AutomataModel() # initiates AutomataModel

def initiateModel(self):
self.ListCells = self.SC.getCells() # gets the generated cells
self.M.setListCells(self.ListCells) # passes the list of cells into AutomataModel
self.M.repeatProcesses() # calls repeating processes

# 4. AUTOMATA MODEL
class AutomataModel():
def __init__(self):
self.ListCells = [] # will be passed by AutomataConroller
self.V = AutomataView() # initiates View class

def setListCells(self, lc): # s etter
self.ListCells = lc

def repeatProcesses(self): # repeats the two processes and make geometries
iterationNumber = iterations
for i in range(iterationNumber):
self.checkNeighboringCells()
self.updateCellVisibility()
self.V.setListCells(self.ListCells) # passes self.ListCells into View
points = self.V.getCoordinates() # makes Geometries
center = self.V.getCenter()
self.V.makeUnits (points, center)
self.V.moveGeometries() # deletes geometries for the next iteration

def checkNeighboringCells(self): # the “1)” process
for i in range(1,Xnumber-1):
for j in range(1,Ynumber-1):
for k in range(1,Znumber-1):
cell = self.ListCells[i][j][k] # gets each cell information
x = cell.getX()
y = cell.getY()
z = cell.getZ()
n = self.calculateNumberOfNeighboringCells(x,y,z)
cell.setN(n)

def calculateNumberOfNeighboringCells(self, x, y, z):
cell0 = self.ListCells[x-1][y-1][z-1]
cell1 = self.ListCells[x][y-1][z-1]
cell2 = self.ListCells[x+1][y-1][z-1]
cell3 = self.ListCells[x-1][y][z-1]
cell4 = self.ListCells[x][y][z-1]
cell5 = self.ListCells[x+1][y][z-1]
cell6 = self.ListCells[x-1][y+1][z-1]
cell7 = self.ListCells[x][y+1][z-1]
cell8 = self.ListCells[x+1][y+1][z-1]

cell9 = self.ListCells[x-1][y-1][z]
cell10 = self.ListCells[x][y-1][z]
cell11 = self.ListCells[x+1][y-1][z]
cell12 = self.ListCells[x-1][y][z]
cell13 = self.ListCells[x+1][y][z]
cell14 = self.ListCells[x-1][y+1][z]
cell15 = self.ListCells[x][y+1][z]
cell16 = self.ListCells[x+1][y+1][z]

cell17 = self.ListCells[x-1][y-1][z+1]
cell18 = self.ListCells[x][y-1][z+1]
cell19 = self.ListCells[x+1][y-1][z+1]
cell20 = self.ListCells[x-1][y][z+1]
cell21 = self.ListCells[x][y][z+1]
cell22 = self.ListCells[x+1][y][z+1]
cell23 = self.ListCells[x-1][y+1][z+1]
cell24 = self.ListCells[x][y+1][z+1]
cell25 = self.ListCells[x+1][y+1][z+1]

v0 = cell0.getVisibility()
v1 = cell1.getVisibility()
v2 = cell2.getVisibility()
v3 = cell3.getVisibility()
v4 = cell4.getVisibility()
v5 = cell5.getVisibility()
v6 = cell6.getVisibility()
v7 = cell7.getVisibility()
v8 = cell8.getVisibility()
v9 = cell9.getVisibility()
v10 = cell10.getVisibility()
v11 = cell11.getVisibility()
v12 = cell12.getVisibility()
v13 = cell13.getVisibility()
v14 = cell14.getVisibility()
v15 = cell15.getVisibility()
v16 = cell16.getVisibility()
v17 = cell17.getVisibility()
v18 = cell18.getVisibility()
v19 = cell19.getVisibility()
v20 = cell20.getVisibility()
v21 = cell21.getVisibility()
v22 = cell22.getVisibility()
v23 = cell23.getVisibility()
v24 = cell24.getVisibility()
v25 = cell25.getVisibility()

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

return sum

def updateCellVisibility(self): # the “2)” process
for x in range(1,Xnumber-1):
for y in range(1,Ynumber-1):
for z in range(1,Znumber-1):
cell = self.ListCells[x][y][z]
cell.updateVisibility()

# 5. AUTOMATA VIEW
class AutomataView():
def __init__(self):
self.ListCells = [] # will be passed by AutomataModel
self.S = smallunit ()
self.B = bigunit ()

def setListCells(self, lc):
self.ListCells = lc

def getCoordinates(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
ptlist.append (pos)
length = len (ptlist)
return ptlist

def getCenter(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
shift = 0.5
center = [pos[0]+shift, pos[1]+shift, pos[2]]
ptlist.append (center)
print ptlist
return ptlist

def makeUnits (self, points, center):
length = len (points)
print “point list =”, points
print “point list length =”, length #prints # of POINTS

percent = smallunitpercentage * length # set PERECNTAGE
minority = int(percent) # count of input percentage of all POINTS
print “minority # =”, minority
majority = length – minority # count of remaining percentage of all POINTS

minorityrandomlist = []
for i in range(minority):
randomvalues = random.randint (0, length-1)
minorityrandomlist.append (randomvalues)

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders
minorityrandomlist.sort() #sorts the list in ascending order
print “minority random list =”, minorityrandomlist

majorityrandomlist = []
for i in range (length):
majorityrandomlist.append (i)
print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:
majorityrandomlist.remove (x)

self.S.makeunit (minorityrandomlist, points, center)
self.B.makeunit (majorityrandomlist, points, center)

def moveGeometries(self):
#rs.Sleep(1000)
allObjIDs = rs.AllObjects()
trans = [0,0,Znumber-1]
rs.MoveObjects(allObjIDs, trans)

###

# CLASS FOR MAKING SMALL UNITS
class smallunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()
self.randomangle = randomangle()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.floorheight = 0.5
self.xdimension = 0.5
self.ydimension = 1

def makeunit (self, unitnumber, points, center):

for r in unitnumber :
rs.AddLayer(“Small Unit”, Color.Red)
rs.CurrentLayer(“Small Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)

slabs = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)
wall1 = self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
wall2 = self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

glass1 = self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
glass2 = self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

angle = self.randomangle.generator()

verticalshift = [0, 0.5]
shift = choice(verticalshift)
path = [0, 0, shift]

rs.RotateObjects(slabs, center[r], angle)
rs.RotateObjects(wall1, center[r], angle)
rs.RotateObjects(wall2, center[r], angle)
rs.RotateObjects(glass1, center[r], angle)
rs.RotateObjects(glass2, center[r], angle)

rs.MoveObjects(slabs, path)
rs.MoveObjects(wall1, path)
rs.MoveObjects(wall2, path)
rs.MoveObjects(glass1, path)
rs.MoveObjects(glass2, path)

rs.DeleteObject(path)

rs.DeleteObject(rectangle)

# CLASS FOR MAKING BIG UNITS
class bigunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()
self.randomangle = randomangle()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.floorheight = 1
self.xdimension = 1
self.ydimension = 1

def makeunit (self, unitnumber, points, center):
for r in unitnumber :
rs.AddLayer(“Large Unit”, Color.Blue)
rs.CurrentLayer(“Large Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)
slab = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)

wall1 = self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
wall2 = self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

glass1 = self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
glass2 = self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

angle = self.randomangle.generator()

slab = rs.RotateObjects(slab, center[r], angle)
wall1 = rs.RotateObjects(wall1, center[r], angle)
wall2 = rs.RotateObjects(wall2, center[r], angle)
glass1 = rs.RotateObjects(glass1, center[r], angle)
glass2 = rs.RotateObjects(glass2, center[r], angle)

rs.DeleteObject(rectangle)

# CLASS FOR MAKING SLABS
class slabmaker():
def __init__(self):
pass

def slabmaker(self, curve, slabthickness, floorheight):
path1 = rs.AddLine([0,0,0], [0,0,-slabthickness]) # Slab Thickness
extrusion = rs.ExtrudeCurve (curve, path1)
rs.CapPlanarHoles(extrusion)
copy = rs.CopyObject(extrusion, [0,0,floorheight])

return extrusion, copy

rs.DeleteObject(curve)
rs.DeleteObject(path1)

# CLASS FOR MAKING WALLS
class wall():
def __init__(self):
pass

def wall(self, point1, wallthickness, walllength, floorheight, slabthickness):
rs.AddLayer(“Wall”, Color.White)
rs.CurrentLayer(“Wall”)

rectangle = rs.AddRectangle(point1, wallthickness, walllength)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (rectangle, path)
rs.CapPlanarHoles(extrusion)

return extrusion

rs.DeleteObjects(rectangle)
rs.DeleteObject(path)

# CLASS FOR MAKING GLASS
class glass():
def __init__(self):
pass

def glass(self, point1, point2, directionpoint, offset, floorheight, slabthickness):
rs.AddLayer(“Glass”, Color.Gold)
rs.CurrentLayer(“Glass”)

line = rs.AddLine(point1, point2)
offset = rs.OffsetCurve(line, directionpoint, offset)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (offset, path)

return extrusion

rs.DeleteObjects(offset)
rs.DeleteObjects(line)
rs.DeleteObject(path)

# CLASS FOR RANDOMLY ROTATING INPUT OBJECT
class randomangle():
def __init__(self):
pass

def generator(self):
rotation = [0, 90, 180, 270]
angle = choice(rotation)
print angle
return angle

# 6. RUN AUTOMATA CONTORLLER
ac = AutomataController()
ac.initiateModel()

juney jaeyual 2012 04 25

juney jaeyual 2012 04 25

Classes are subdivided further into smaller individual classes, and SIGNIFICANTLY cleaned up. although, our random-rotator class seem  to be not working… it keeps saying nothing is being input. Associated functions from other classes doesn’t seem to be outputting proper GUID… will talk to you tomorrow about this.

import rhinoscriptsyntax as rs
from random import choice
import random
from System.Drawing import Color

Xnumber = 7
Ynumber = 7
Znumber = 7

# 1. CELL (Condition/Rules)
class Cell():
def __init__(self, x, y, z):
self.X = x
self.Y = y
self.Z = z
self.Pos = [x,y,z]
self.Visibility = False # Cell’s visibility(True means On/Alive, False means Off/Dead)
self.N = 0 # Number of Neighboring Cells

def getVisibility(self):
return self.Visibility

def setVisibility(self, v): # v will be True or False
self.Visibility = v

def getN(self):
return self.N

def setN(self, n): # n is the number of neighbors
self.N = n

def getX(self):
return self.X

def getY(self):
return self.Y

def getZ(self):
return self.Z

def getPos(self):
return self.Pos

def updateVisibility(self):
if (self.Visibility == True): # ALIVE cell = apply rule1_visibility
self.rule1_Visibility()
else: #(self.Visibility == False) # DEAD cell = apply rule2_visibility
self.rule2_Population()

def rule1_Visibility(self):
if (self.N < 10):
self.setVisibility(False)
elif (self.N < 20):
self.setVisibility(True)
else:
self.setVisibility(False)

def rule2_Population(self):
if (self.N == 0 or self.N == 5 or self.N == 10):
self.setVisibility(True)
elif (self.N < 10):
self.setVisibility(False)
elif (self.N < 15):
self.setVisibility(True)
else:
pass

# 2. SET OF CELLS
class SetOfCells():
def __init__(self):
self.ListCells = [] # list containing all cell classes
self.generateCells() # these two functions automatically run when the class is initiated.
self.setSeeds()

def generateCells(self):
xCellList = [] # this is the outer list of nested list(ListCells)
for x in range(Xnumber):
yCellList = [] # this is the inner list of a nested list(ListCells)
for y in range(Ynumber):
zCellList = []
for z in range(Znumber):
c = Cell(x,y,z)
zCellList.append(c)
yCellList.append(zCellList)
xCellList.append(yCellList)
self.ListCells = xCellList # returns the nested list into self.ListCells

def setSeeds(self): # this function defines initial states of cells
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
if (x > 0 and x < Xnumber and y > 0 and y < Ynumber and z > 0 and z < Znumber): # initial condition
cell.setVisibility(True)
else:
cell.setVisibility(False)

def getCells(self): # getter for self.ListCells
return self.ListCells

# 3. AUTOMATA CONTROLLER
class AutomataController():
def __init__(self):
self.ListCells = []
self.SC = SetOfCells() # generate cells and contain them in a list
self.M = AutomataModel() # initiates AutomataModel

def initiateModel(self):
self.ListCells = self.SC.getCells() # gets the generated cells
self.M.setListCells(self.ListCells) # passes the list of cells into AutomataModel
self.M.repeatProcesses() # calls repeating processes

# 4. AUTOMATA MODEL
class AutomataModel():
def __init__(self):
self.ListCells = [] # will be passed by AutomataConroller
self.V = AutomataView() # initiates View class

def setListCells(self, lc): # s etter
self.ListCells = lc

def repeatProcesses(self): # repeats the two processes and make geometries
iterationNumber = 1
for i in range(iterationNumber):
self.checkNeighboringCells()
self.updateCellVisibility()
self.V.setListCells(self.ListCells) # passes self.ListCells into View
points = self.V.getCoordinates() # makes Geometries
center = self.V.getCenter()
self.V.makeUnits (points, center)
#self.V.moveGeometries() # deletes geometries for the next iteration

def checkNeighboringCells(self): # the “1)” process
for i in range(1,Xnumber-1):
for j in range(1,Ynumber-1):
for k in range(1,Znumber-1):
cell = self.ListCells[i][j][k] # gets each cell information
x = cell.getX()
y = cell.getY()
z = cell.getZ()
n = self.calculateNumberOfNeighboringCells(x,y,z)
cell.setN(n)

def calculateNumberOfNeighboringCells(self, x, y, z):
cell0 = self.ListCells[x-1][y-1][z-1]
cell1 = self.ListCells[x][y-1][z-1]
cell2 = self.ListCells[x+1][y-1][z-1]
cell3 = self.ListCells[x-1][y][z-1]
cell4 = self.ListCells[x][y][z-1]
cell5 = self.ListCells[x+1][y][z-1]
cell6 = self.ListCells[x-1][y+1][z-1]
cell7 = self.ListCells[x][y+1][z-1]
cell8 = self.ListCells[x+1][y+1][z-1]

cell9 = self.ListCells[x-1][y-1][z]
cell10 = self.ListCells[x][y-1][z]
cell11 = self.ListCells[x+1][y-1][z]
cell12 = self.ListCells[x-1][y][z]
cell13 = self.ListCells[x+1][y][z]
cell14 = self.ListCells[x-1][y+1][z]
cell15 = self.ListCells[x][y+1][z]
cell16 = self.ListCells[x+1][y+1][z]

cell17 = self.ListCells[x-1][y-1][z+1]
cell18 = self.ListCells[x][y-1][z+1]
cell19 = self.ListCells[x+1][y-1][z+1]
cell20 = self.ListCells[x-1][y][z+1]
cell21 = self.ListCells[x][y][z+1]
cell22 = self.ListCells[x+1][y][z+1]
cell23 = self.ListCells[x-1][y+1][z+1]
cell24 = self.ListCells[x][y+1][z+1]
cell25 = self.ListCells[x+1][y+1][z+1]

v0 = cell0.getVisibility()
v1 = cell1.getVisibility()
v2 = cell2.getVisibility()
v3 = cell3.getVisibility()
v4 = cell4.getVisibility()
v5 = cell5.getVisibility()
v6 = cell6.getVisibility()
v7 = cell7.getVisibility()
v8 = cell8.getVisibility()
v9 = cell9.getVisibility()
v10 = cell10.getVisibility()
v11 = cell11.getVisibility()
v12 = cell12.getVisibility()
v13 = cell13.getVisibility()
v14 = cell14.getVisibility()
v15 = cell15.getVisibility()
v16 = cell16.getVisibility()
v17 = cell17.getVisibility()
v18 = cell18.getVisibility()
v19 = cell19.getVisibility()
v20 = cell20.getVisibility()
v21 = cell21.getVisibility()
v22 = cell22.getVisibility()
v23 = cell23.getVisibility()
v24 = cell24.getVisibility()
v25 = cell25.getVisibility()

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

return sum

def updateCellVisibility(self): # the “2)” process
for x in range(1,Xnumber-1):
for y in range(1,Ynumber-1):
for z in range(1,Znumber-1):
cell = self.ListCells[x][y][z]
cell.updateVisibility()

# 5. AUTOMATA VIEW
class AutomataView():
def __init__(self):
self.ListCells = [] # will be passed by AutomataModel
self.S = smallunit ()
self.B = bigunit ()

def setListCells(self, lc):
self.ListCells = lc

def getCoordinates(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
ptlist.append (pos)
length = len (ptlist)
return ptlist

def getCenter(self):
ptlist = []
for x in range(Xnumber):
for y in range(Ynumber):
for z in range(Znumber):
cell = self.ListCells[x][y][z]
visibility = cell.getVisibility()
if visibility == True:
pos = cell.getPos()
shift = 0.5
center = [pos[0]+shift, pos[1]+shift, pos[2]]
ptlist.append (center)
print ptlist
return ptlist

def makeUnits (self, points, center):
length = len (points)
print “point list =”, points
print “point list length =”, length #prints # of POINTS

percent = 0.8 * length # set PERECNTAGE
minority = int(percent) # count of input percentage of all POINTS
print “minority # =”, minority
majority = length – minority # count of remaining percentage of all POINTS

minorityrandomlist = []
for i in range(minority):
randomvalues = random.randint (0, length-1)
minorityrandomlist.append (randomvalues)

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders
minorityrandomlist.sort() #sorts the list in ascending order
print “minority random list =”, minorityrandomlist

majorityrandomlist = []
for i in range (length):
majorityrandomlist.append (i)
print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:
majorityrandomlist.remove (x)

self.S.makeunit (minorityrandomlist, points, center)
self.B.makeunit (majorityrandomlist, points)

def moveGeometries(self):
#rs.Sleep(1000)
allObjIDs = rs.AllObjects()
trans = [20,0,0]
rs.MoveObjects(allObjIDs, trans)

# CLASS FOR MAKING SMALL UNITS
class smallunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()
self.rotator = randomrotator()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.floorheight = 0.5
self.xdimension = 0.5
self.ydimension = 1

def makeunit (self, unitnumber, points, center):

for r in unitnumber :
rs.AddLayer(“Small Unit”, Color.Red)
rs.CurrentLayer(“Small Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)

slabs = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)
wall1 = self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
wall2 = self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

glass1 = self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
glass2 = self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

smallunit = [slabs, wall1, wall2, glass1, glass2]

print smallunit

self.rotator.rotator(smallunit, center[r])
rs.DeleteObject(rectangle)

# CLASS FOR MAKING BIG UNITS
class bigunit():
def __init__(self):
self.slab = slabmaker()
self.wall = wall()
self.glass = glass()

self.slabthickness = 0.05
self.wallthickness = 0.02
self.glassoffset = 0.02

self.floorheight = 1
self.xdimension = 1
self.ydimension = 1

def makeunit (self, unitnumber, points):
for r in unitnumber :
rs.AddLayer(“Large Unit”, Color.Blue)
rs.CurrentLayer(“Large Unit”)

x = points [r][0]
y = points [r][1]
z = points [r][2]

pt0 = [x, y, z]
pt1 = [x, y + self.ydimension , z]
pt2 = [x + self.xdimension, y + self.ydimension, z]
pt3 = [x + self.xdimension, y, z]

rectangle = rs.AddRectangle(points[r], self.xdimension, self.ydimension)
slab = self.slab.slabmaker (rectangle, self.slabthickness, self.floorheight)

self.wall.wall(pt0, self.wallthickness, self.ydimension, self.floorheight, self.slabthickness)
self.wall.wall(pt2, -self.wallthickness, -self.ydimension, self.floorheight, self.slabthickness)

self.glass.glass(pt2, pt1, pt0, self.glassoffset, self.floorheight, self.slabthickness)
self.glass.glass(pt0, pt3, pt1, self.glassoffset, self.floorheight, self.slabthickness)

rs.DeleteObject(rectangle)

# CLASS FOR MAKING SLABS
class slabmaker():
def __init__(self):
pass

def slabmaker(self, curve, slabthickness, floorheight):
path1 = rs.AddLine([0,0,0], [0,0,-slabthickness]) # Slab Thickness
extrusion = rs.ExtrudeCurve (curve, path1)
rs.CapPlanarHoles(extrusion)
copy = rs.CopyObject(extrusion, [0,0,floorheight])

return extrusion, copy

rs.DeleteObject(curve)
rs.DeleteObject(path1)

# CLASS FOR MAKING WALLS
class wall():
def __init__(self):
pass

def wall(self, point1, wallthickness, walllength, floorheight, slabthickness):
rs.AddLayer(“Wall”, Color.DarkGray)
rs.CurrentLayer(“Wall”)

rectangle = rs.AddRectangle(point1, wallthickness, walllength)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (rectangle, path)
rs.CapPlanarHoles(extrusion)

return extrusion

rs.DeleteObject(rectangle)
rs.DeleteObject(path)

# CLASS FOR MAKING GLASS
class glass():
def __init__(self):
pass

def glass(self, point1, point2, directionpoint, offset, floorheight, slabthickness):
rs.AddLayer(“Glass”, Color.Aqua)
rs.CurrentLayer(“Glass”)

line = rs.AddLine(point1, point2)
offset = rs.OffsetCurve(line, directionpoint, offset)
path = rs.AddLine([0,0,0], [0,0,floorheight-slabthickness])

extrusion = rs.ExtrudeCurve (offset, path)

return extrusion

rs.DeleteObject(offset)
rs.DeleteObject(line)
rs.DeleteObject(path)

# CLASS FOR RANDOMLY ROTATING INPUT OBJECT
class randomrotator():
def __init__(self):
pass

def rotator(self, objects, center):
rotation = [0, 90, 180, 270]
angle = choice(rotation)

rs.RotateObjects(objects, center, angle)

# 6. RUN AUTOMATA CONTORLLER
ac = AutomataController()
ac.initiateModel()

 

juney jaeyual 20120422

This slideshow requires JavaScript.

juney jaeyual 20120422

“””Update Class with Floor Slabs”””

 

import rhinoscriptsyntax as rs

from random import choice

import random

from System.Drawing import Color

 

Xnumber = 8

Ynumber = 8

Znumber = 8

 

#################################################################

# 1. CELL (Condition/Rules)

class Cell():

def __init__(self, x, y, z):

self.X = x

self.Y = y

self.Z = z

self.Pos = [x,y,z]

self.Visibility = False     # Cell’s visibility(True means On/Alive, False means Off/Dead)

self.N = 0                  # Number of Neighboring Cells

 

def getVisibility(self):

return self.Visibility

 

def setVisibility(self, v):     # v will be True or False

self.Visibility = v

 

def getN(self):

return self.N

 

def setN(self, n):              # n is the number of neighbors

self.N = n

 

def getX(self):

return self.X

 

def getY(self):

return self.Y

 

def getZ(self):

return self.Z

 

def getPos(self):

return self.Pos

 

def updateVisibility(self):

if (self.Visibility == True):       # ALIVE cell = apply rule1_visibility

self.rule1_Visibility()

else: #(self.Visibility == False)   # DEAD cell =  apply rule2_visibility

self.rule2_Population()

 

def rule1_Visibility(self):

if (self.N < 10):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

self.setVisibility(False)

 

def rule2_Population(self):

if (self.N == 0 or self.N == 5 or self.N == 10):

self.setVisibility(True)

elif (self.N < 5):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

pass

 

#################################################################

# 2. SET OF CELLS

class SetOfCells():

def __init__(self):

self.ListCells = []     # list containing all cell classes

self.generateCells()    # these two functions automatically run when the class is initiated.

self.setSeeds()

 

def generateCells(self):

xCellList = []          # this is the outer list of nested list(ListCells)

for x in range(Xnumber):

yCellList = []      # this is the inner list of a nested list(ListCells)

for y in range(Ynumber):

zCellList = []

for z in range(Znumber):

c = Cell(x,y,z)

zCellList.append(c)

yCellList.append(zCellList)

xCellList.append(yCellList)

self.ListCells = xCellList  # returns the nested list into self.ListCells

 

def setSeeds(self):     # this function defines initial states of cells

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

if (x > 0 and x < 8 and y > 0 and y < 8 and z > 0 and z < 8): # initial condition

cell.setVisibility(True)

else:

cell.setVisibility(False)

 

def getCells(self):     # getter for self.ListCells

return self.ListCells

 

#################################################################

# 3. AUTOMATA CONTROLLER

class AutomataController():

def __init__(self):

self.ListCells = []

self.SC = SetOfCells()      # generate cells and contain them in a list

self.M = AutomataModel()    # initiates AutomataModel

 

def initiateModel(self):

self.ListCells = self.SC.getCells()     # gets the generated cells

self.M.setListCells(self.ListCells)     # passes the list of cells into AutomataModel

self.M.repeatProcesses()                # calls repeating processes

 

#################################################################

# 4. AUTOMATA MODEL

class AutomataModel():

def __init__(self):

self.ListCells = []         # will be passed by AutomataConroller

self.V = AutomataView()     # initiates View class

 

def setListCells(self, lc):     # s etter

self.ListCells = lc

 

def repeatProcesses(self):      # repeats the two processes and make geometries

iterationNumber = 5

for i in range(iterationNumber):

self.checkNeighboringCells()

self.updateCellVisibility()

self.V.setListCells(self.ListCells) # passes self.ListCells into View

points = self.V.getCoordinates()             # makes Geometries

center = self.V.getCenter ()

self.V.makeBoxes (points, center)

self.V.moveGeometries()           # deletes geometries for the next iteration

 

def checkNeighboringCells(self):            # the “1)” process

for i in range(1,Xnumber-1):

for j in range(1,Ynumber-1):

for k in range(1,Znumber-1):

cell = self.ListCells[i][j][k]     # gets each cell information

x = cell.getX()

y = cell.getY()

z = cell.getZ()

n = self.calculateNumberOfNeighboringCells(x,y,z)

cell.setN(n)

 

def calculateNumberOfNeighboringCells(self, x, y, z):

cell0 = self.ListCells[x-1][y-1][z-1]

cell1 = self.ListCells[x][y-1][z-1]

cell2 = self.ListCells[x+1][y-1][z-1]

cell3 = self.ListCells[x-1][y][z-1]

cell4 = self.ListCells[x][y][z-1]

cell5 = self.ListCells[x+1][y][z-1]

cell6 = self.ListCells[x-1][y+1][z-1]

cell7 = self.ListCells[x][y+1][z-1]

cell8 = self.ListCells[x+1][y+1][z-1]

 

cell9 = self.ListCells[x-1][y-1][z]

cell10 = self.ListCells[x][y-1][z]

cell11 = self.ListCells[x+1][y-1][z]

cell12 = self.ListCells[x-1][y][z]

cell13 = self.ListCells[x+1][y][z]

cell14 = self.ListCells[x-1][y+1][z]

cell15 = self.ListCells[x][y+1][z]

cell16 = self.ListCells[x+1][y+1][z]

 

cell17 = self.ListCells[x-1][y-1][z+1]

cell18 = self.ListCells[x][y-1][z+1]

cell19 = self.ListCells[x+1][y-1][z+1]

cell20 = self.ListCells[x-1][y][z+1]

cell21 = self.ListCells[x][y][z+1]

cell22 = self.ListCells[x+1][y][z+1]

cell23 = self.ListCells[x-1][y+1][z+1]

cell24 = self.ListCells[x][y+1][z+1]

cell25 = self.ListCells[x+1][y+1][z+1]

 

v0 = cell0.getVisibility()

v1 = cell1.getVisibility()

v2 = cell2.getVisibility()

v3 = cell3.getVisibility()

v4 = cell4.getVisibility()

v5 = cell5.getVisibility()

v6 = cell6.getVisibility()

v7 = cell7.getVisibility()

v8 = cell8.getVisibility()

v9 = cell9.getVisibility()

v10 = cell10.getVisibility()

v11 = cell11.getVisibility()

v12 = cell12.getVisibility()

v13 = cell13.getVisibility()

v14 = cell14.getVisibility()

v15 = cell15.getVisibility()

v16 = cell16.getVisibility()

v17 = cell17.getVisibility()

v18 = cell18.getVisibility()

v19 = cell19.getVisibility()

v20 = cell20.getVisibility()

v21 = cell21.getVisibility()

v22 = cell22.getVisibility()

v23 = cell23.getVisibility()

v24 = cell24.getVisibility()

v25 = cell25.getVisibility()

 

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

 

return sum

 

def updateCellVisibility(self):             # the “2)” process

for x in range(1,Xnumber-1):

for y in range(1,Ynumber-1):

for z in range(1,Znumber-1):

cell = self.ListCells[x][y][z]

cell.updateVisibility()

 

#################################################################

# 5. AUTOMATA VIEW

class AutomataView():

def __init__(self):

self.ListCells = []     # will be passed by AutomataModel

 

def setListCells(self, lc):

self.ListCells = lc

 

def getCoordinates(self):

ptlist = []

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

ptlist.append (pos)

length = len (ptlist)

return ptlist

 

def getCenter(self):

ptlist = []

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

shift = 0.5

center = [pos[0]+shift, pos[1]+shift, pos[2]]

ptlist.append (center)

print ptlist

return ptlist

 

 

def makeBoxes (self, points, center):

length = len (points)

print “point list =”, points

print “point list length =”, length #prints # of POINTS

 

percent = 0.8 * length # set PERECNTAGE

minority = int(percent) # count of input percentage of all POINTS

print “minority # =”, minority

majority = length – minority # count of remaining percentage of all POINTS

 

########################################################################

#for minority units

minorityrandomlist = []

for i in range(minority):

randomvalues = random.randint (0, length-1)

minorityrandomlist.append (randomvalues)

 

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders

minorityrandomlist.sort() #sorts the list in ascending order

print “minority random list =”, minorityrandomlist

for r in minorityrandomlist :

rs.AddLayer(“Small Unit”, Color.Red)

rs.CurrentLayer(“Small Unit”)

 

rectangle = rs.AddRectangle(points[r], 0.5, 1)

path = rs.AddLine([0,0,0], [0,0,0.5]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

rs.CapPlanarHoles(extrusion)

path2 = rs.AddLine([0,0,0], [0,0,0.05]) # Slab Thickness

extrusion2 = rs.ExtrudeCurve (rectangle, path2)

rs.CapPlanarHoles(extrusion2)

extrusions = [extrusion, extrusion2]

rotation = [0, 90, 180, 270]

angle = choice(rotation)

 

rs.RotateObjects(extrusions, center[r], angle)

rs.DeleteObject(path)

rs.DeleteObject(path2)

rs.DeleteObject (rectangle)

 

 

 

 

########################################################################

#for majority units

 

majorityrandomlist = []

for i in range (length):

majorityrandomlist.append (i)

print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:

majorityrandomlist.remove (x)

 

for r in majorityrandomlist: #Makes Large Unit

rs.AddLayer(“Large Unit”, Color.Blue)

rs.CurrentLayer(“Large Unit”)

rectangle = rs.AddRectangle(points[r], 1, 1)

path = rs.AddLine([0,0,0], [0,0,1]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

path2 = rs.AddLine([0,0,0], [0,0,.05]) # Slab Thickness

extrusion2 = rs.ExtrudeCurve (rectangle, path2)

rs.CapPlanarHoles(extrusion)

rs.DeleteObject(path)

rs.DeleteObject(path2)

 

 

def moveGeometries(self):

#rs.Sleep(1000)

allObjIDs = rs.AllObjects()

trans = [20,0,0]

rs.MoveObjects(allObjIDs, trans)

 

 

#################################################################

# 6. RUN AUTOMATA CONTORLLER

ac = AutomataController()

ac.initiateModel()

 

 

juney jaeyual 20120420

This slideshow requires JavaScript.

juney jaeyual 20120420

Updated class now has 2 different types with 2 different heights. The small units also rotate to give various terrace locations/orientation. Assembled with previous core/stair classes, and booleaned off with larger, terrace/voids.

 

import rhinoscriptsyntax as rs

from random import choice

import random

from System.Drawing import Color

Xnumber = 8

Ynumber = 8

Znumber = 8

#################################################################

# 1. CELL (Condition/Rules)

class Cell():

def __init__(self, x, y, z):

self.X = x

self.Y = y

self.Z = z

self.Pos = [x,y,z]

self.Visibility = False     # Cell’s visibility(True means On/Alive, False means Off/Dead)

self.N = 0                  # Number of Neighboring Cells

def getVisibility(self):

return self.Visibility

def setVisibility(self, v):     # v will be True or False

self.Visibility = v

def getN(self):

return self.N

def setN(self, n):              # n is the number of neighbors

self.N = n

def getX(self):

return self.X

def getY(self):

return self.Y

def getZ(self):

return self.Z

def getPos(self):

return self.Pos

def updateVisibility(self):

if (self.Visibility == True):       # ALIVE cell = apply rule1_visibility

self.rule1_Visibility()

else: #(self.Visibility == False)   # DEAD cell =  apply rule2_visibility

self.rule2_Population()

def rule1_Visibility(self):

if (self.N < 10):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

self.setVisibility(False)

def rule2_Population(self):

if (self.N == 0 or self.N == 5 or self.N == 10):

self.setVisibility(True)

elif (self.N < 5):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

pass

#################################################################

# 2. SET OF CELLS

class SetOfCells():

def __init__(self):

self.ListCells = []     # list containing all cell classes

self.generateCells()    # these two functions automatically run when the class is initiated.

self.setSeeds()

def generateCells(self):

xCellList = []          # this is the outer list of nested list(ListCells)

for x in range(Xnumber):

yCellList = []      # this is the inner list of a nested list(ListCells)

for y in range(Ynumber):

zCellList = []

for z in range(Znumber):

c = Cell(x,y,z)

zCellList.append(c)

yCellList.append(zCellList)

xCellList.append(yCellList)

self.ListCells = xCellList  # returns the nested list into self.ListCells

def setSeeds(self):     # this function defines initial states of cells

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

if (x > 0 and x < 8 and y > 0 and y < 8 and z > 0 and z < 8): # initial condition

cell.setVisibility(True)

else:

cell.setVisibility(False)

def getCells(self):     # getter for self.ListCells

return self.ListCells

#################################################################

# 3. AUTOMATA CONTROLLER

class AutomataController():

def __init__(self):

self.ListCells = []

self.SC = SetOfCells()      # generate cells and contain them in a list

self.M = AutomataModel()    # initiates AutomataModel

def initiateModel(self):

self.ListCells = self.SC.getCells()     # gets the generated cells

self.M.setListCells(self.ListCells)     # passes the list of cells into AutomataModel

self.M.repeatProcesses()                # calls repeating processes

#################################################################

# 4. AUTOMATA MODEL

class AutomataModel():

def __init__(self):

self.ListCells = []         # will be passed by AutomataConroller

self.V = AutomataView()     # initiates View class

def setListCells(self, lc):     # s etter

self.ListCells = lc

def repeatProcesses(self):      # repeats the two processes and make geometries

iterationNumber = 5

for i in range(iterationNumber):

self.checkNeighboringCells()

self.updateCellVisibility()

self.V.setListCells(self.ListCells) # passes self.ListCells into View

points = self.V.getCoordinates()             # makes Geometries

center = self.V.getCenter ()

self.V.makeBoxes (points, center)

self.V.moveGeometries()           # deletes geometries for the next iteration

def checkNeighboringCells(self):            # the “1)” process

for i in range(1,Xnumber-1):

for j in range(1,Ynumber-1):

for k in range(1,Znumber-1):

cell = self.ListCells[i][j][k]     # gets each cell information

x = cell.getX()

y = cell.getY()

z = cell.getZ()

n = self.calculateNumberOfNeighboringCells(x,y,z)

cell.setN(n)

def calculateNumberOfNeighboringCells(self, x, y, z):

cell0 = self.ListCells[x-1][y-1][z-1]

cell1 = self.ListCells[x][y-1][z-1]

cell2 = self.ListCells[x+1][y-1][z-1]

cell3 = self.ListCells[x-1][y][z-1]

cell4 = self.ListCells[x][y][z-1]

cell5 = self.ListCells[x+1][y][z-1]

cell6 = self.ListCells[x-1][y+1][z-1]

cell7 = self.ListCells[x][y+1][z-1]

cell8 = self.ListCells[x+1][y+1][z-1]

cell9 = self.ListCells[x-1][y-1][z]

cell10 = self.ListCells[x][y-1][z]

cell11 = self.ListCells[x+1][y-1][z]

cell12 = self.ListCells[x-1][y][z]

cell13 = self.ListCells[x+1][y][z]

cell14 = self.ListCells[x-1][y+1][z]

cell15 = self.ListCells[x][y+1][z]

cell16 = self.ListCells[x+1][y+1][z]

cell17 = self.ListCells[x-1][y-1][z+1]

cell18 = self.ListCells[x][y-1][z+1]

cell19 = self.ListCells[x+1][y-1][z+1]

cell20 = self.ListCells[x-1][y][z+1]

cell21 = self.ListCells[x][y][z+1]

cell22 = self.ListCells[x+1][y][z+1]

cell23 = self.ListCells[x-1][y+1][z+1]

cell24 = self.ListCells[x][y+1][z+1]

cell25 = self.ListCells[x+1][y+1][z+1]

v0 = cell0.getVisibility()

v1 = cell1.getVisibility()

v2 = cell2.getVisibility()

v3 = cell3.getVisibility()

v4 = cell4.getVisibility()

v5 = cell5.getVisibility()

v6 = cell6.getVisibility()

v7 = cell7.getVisibility()

v8 = cell8.getVisibility()

v9 = cell9.getVisibility()

v10 = cell10.getVisibility()

v11 = cell11.getVisibility()

v12 = cell12.getVisibility()

v13 = cell13.getVisibility()

v14 = cell14.getVisibility()

v15 = cell15.getVisibility()

v16 = cell16.getVisibility()

v17 = cell17.getVisibility()

v18 = cell18.getVisibility()

v19 = cell19.getVisibility()

v20 = cell20.getVisibility()

v21 = cell21.getVisibility()

v22 = cell22.getVisibility()

v23 = cell23.getVisibility()

v24 = cell24.getVisibility()

v25 = cell25.getVisibility()

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

return sum

def updateCellVisibility(self):             # the “2)” process

for x in range(1,Xnumber-1):

for y in range(1,Ynumber-1):

for z in range(1,Znumber-1):

cell = self.ListCells[x][y][z]

cell.updateVisibility()

#################################################################

# 5. AUTOMATA VIEW

class AutomataView():

def __init__(self):

self.ListCells = []     # will be passed by AutomataModel

def setListCells(self, lc):

self.ListCells = lc

def getCoordinates(self):

ptlist = []

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

ptlist.append (pos)

length = len (ptlist)

return ptlist

def getCenter(self):

ptlist = []

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

shift = 0.5

center = [pos[0]+shift, pos[1]+shift, pos[2]]

ptlist.append (center)

print ptlist

return ptlist

def makeBoxes (self, points, center):

length = len (points)

print “point list =”, points

print “point list length =”, length #prints # of POINTS

percent = 0.8 * length # set PERECNTAGE

minority = int(percent) # count of input percentage of all POINTS

print “minority # =”, minority

majority = length – minority # count of remaining percentage of all POINTS

########################################################################

#for minority units

minorityrandomlist = []

for i in range(minority):

randomvalues = random.randint (0, length-1)

minorityrandomlist.append (randomvalues)

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders

minorityrandomlist.sort() #sorts the list in ascending order

print “minority random list =”, minorityrandomlist

for r in minorityrandomlist :

rs.AddLayer(“Small Unit”, Color.Red)

rs.CurrentLayer(“Small Unit”)

rectangle = rs.AddRectangle(points[r], 0.5, 1)

path = rs.AddLine([0,0,0], [0,0,0.5]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

rs.CapPlanarHoles(extrusion)

rotation = [0, 90, 180, 270]

angle = choice(rotation)

rs.RotateObjects(extrusion, center[r], angle)

rs.DeleteObject(path)

rs.DeleteObject (rectangle)

########################################################################

#for majority units

majorityrandomlist = []

for i in range (length):

majorityrandomlist.append (i)

print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:

majorityrandomlist.remove (x)

for r in majorityrandomlist: #Makes Large Unit

rs.AddLayer(“Large Unit”, Color.Blue)

rs.CurrentLayer(“Large Unit”)

rectangle = rs.AddRectangle(points[r], 1, 1)

path = rs.AddLine([0,0,0], [0,0,1]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

rs.CapPlanarHoles(extrusion)

rs.DeleteObject(path)

def moveGeometries(self):

#rs.Sleep(1000)

allObjIDs = rs.AllObjects()

trans = [20,0,0]

rs.MoveObjects(allObjIDs, trans)

#################################################################

# 6. RUN AUTOMATA CONTORLLER

ac = AutomataController()

ac.initiateModel()

juney jaeyual 20120417 Room Type Distribution by %

 

This class takes a PERCENTAGE as an input, and distributes 2 types of units (red units are 1 bedroom units, and white units are 2 bedroom units). The percentage of all the cells converts the % into #(or integer) of cells, and distributes different unit types. The selection of the chosen cells are RANDOM.

For this particular iteration, the bottom quarter is 20% white, and 80% red. Second quarter, is 40% white, 60% red. Third quarter is 60% white, and 40% red. The top quarter is 80% white, and 20% red.

 

juney jaeyual 20120414 Contorlled Room Distribution

 

import rhinoscriptsyntax as rs

from random import choice

import random

from System.Drawing import Color

Xnumber = 10

Ynumber = 10

Znumber = 10

#################################################################

# 1. CELL (Condition/Rules)

class Cell():

def __init__(self, x, y, z):

self.X = x

self.Y = y

self.Z = z

self.Pos = [x,y,z]

self.Visibility = False     # Cell’s visibility(True means On/Alive, False means Off/Dead)

self.N = 0                  # Number of Neighboring Cells

def getVisibility(self):

return self.Visibility

def setVisibility(self, v):     # v will be True or False

self.Visibility = v

def getN(self):

return self.N

def setN(self, n):              # n is the number of neighbors

self.N = n

def getX(self):

return self.X

def getY(self):

return self.Y

def getZ(self):

return self.Z

def getPos(self):

return self.Pos

def updateVisibility(self):

if (self.Visibility == True):       # ALIVE cell = apply rule1_visibility

self.rule1_Visibility()

else: #(self.Visibility == False)   # DEAD cell =  apply rule2_visibility

self.rule2_Population()

def rule1_Visibility(self):

if (self.N < 10):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

self.setVisibility(False)

def rule2_Population(self):

if (self.N == 0 or self.N == 5 or self.N == 10):

self.setVisibility(True)

elif (self.N < 5):

self.setVisibility(False)

elif (self.N < 15):

self.setVisibility(True)

else:

pass

#################################################################

# 2. SET OF CELLS

class SetOfCells():

def __init__(self):

self.ListCells = []     # list containing all cell classes

self.generateCells()    # these two functions automatically run when the class is initiated.

self.setSeeds()

def generateCells(self):

xCellList = []          # this is the outer list of nested list(ListCells)

for x in range(Xnumber):

yCellList = []      # this is the inner list of a nested list(ListCells)

for y in range(Ynumber):

zCellList = []

for z in range(Znumber):

c = Cell(x,y,z)

zCellList.append(c)

yCellList.append(zCellList)

xCellList.append(yCellList)

self.ListCells = xCellList  # returns the nested list into self.ListCells

def setSeeds(self):     # this function defines initial states of cells

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

if (x > 0 and x < 10 and y > 0 and y < 10 and z > 0 and z < 10): # initial condition

cell.setVisibility(True)

else:

cell.setVisibility(False)

def getCells(self):     # getter for self.ListCells

return self.ListCells

#################################################################

# 3. AUTOMATA CONTROLLER

class AutomataController():

def __init__(self):

self.ListCells = []

self.SC = SetOfCells()      # generate cells and contain them in a list

self.M = AutomataModel()    # initiates AutomataModel

def initiateModel(self):

self.ListCells = self.SC.getCells()     # gets the generated cells

self.M.setListCells(self.ListCells)     # passes the list of cells into AutomataModel

self.M.repeatProcesses()                # calls repeating processes

#################################################################

# 4. AUTOMATA MODEL

class AutomataModel():

def __init__(self):

self.ListCells = []         # will be passed by AutomataConroller

self.V = AutomataView()     # initiates View class

def setListCells(self, lc):     # s etter

self.ListCells = lc

def repeatProcesses(self):      # repeats the two processes and make geometries

iterationNumber = 5

for i in range(iterationNumber):

self.checkNeighboringCells()

self.updateCellVisibility()

self.V.setListCells(self.ListCells) # passes self.ListCells into View

points = self.V.getCoordinates()             # makes Geometries

self.V.makeBoxes (points)

self.V.moveGeometries()           # deletes geometries for the next iteration

def checkNeighboringCells(self):            # the “1)” process

for i in range(1,Xnumber-1):

for j in range(1,Ynumber-1):

for k in range(1,Znumber-1):

cell = self.ListCells[i][j][k]     # gets each cell information

x = cell.getX()

y = cell.getY()

z = cell.getZ()

n = self.calculateNumberOfNeighboringCells(x,y,z)

cell.setN(n)

def calculateNumberOfNeighboringCells(self, x, y, z):

cell0 = self.ListCells[x-1][y-1][z-1]

cell1 = self.ListCells[x][y-1][z-1]

cell2 = self.ListCells[x+1][y-1][z-1]

cell3 = self.ListCells[x-1][y][z-1]

cell4 = self.ListCells[x][y][z-1]

cell5 = self.ListCells[x+1][y][z-1]

cell6 = self.ListCells[x-1][y+1][z-1]

cell7 = self.ListCells[x][y+1][z-1]

cell8 = self.ListCells[x+1][y+1][z-1]

cell9 = self.ListCells[x-1][y-1][z]

cell10 = self.ListCells[x][y-1][z]

cell11 = self.ListCells[x+1][y-1][z]

cell12 = self.ListCells[x-1][y][z]

cell13 = self.ListCells[x+1][y][z]

cell14 = self.ListCells[x-1][y+1][z]

cell15 = self.ListCells[x][y+1][z]

cell16 = self.ListCells[x+1][y+1][z]

cell17 = self.ListCells[x-1][y-1][z+1]

cell18 = self.ListCells[x][y-1][z+1]

cell19 = self.ListCells[x+1][y-1][z+1]

cell20 = self.ListCells[x-1][y][z+1]

cell21 = self.ListCells[x][y][z+1]

cell22 = self.ListCells[x+1][y][z+1]

cell23 = self.ListCells[x-1][y+1][z+1]

cell24 = self.ListCells[x][y+1][z+1]

cell25 = self.ListCells[x+1][y+1][z+1]

v0 = cell0.getVisibility()

v1 = cell1.getVisibility()

v2 = cell2.getVisibility()

v3 = cell3.getVisibility()

v4 = cell4.getVisibility()

v5 = cell5.getVisibility()

v6 = cell6.getVisibility()

v7 = cell7.getVisibility()

v8 = cell8.getVisibility()

v9 = cell9.getVisibility()

v10 = cell10.getVisibility()

v11 = cell11.getVisibility()

v12 = cell12.getVisibility()

v13 = cell13.getVisibility()

v14 = cell14.getVisibility()

v15 = cell15.getVisibility()

v16 = cell16.getVisibility()

v17 = cell17.getVisibility()

v18 = cell18.getVisibility()

v19 = cell19.getVisibility()

v20 = cell20.getVisibility()

v21 = cell21.getVisibility()

v22 = cell22.getVisibility()

v23 = cell23.getVisibility()

v24 = cell24.getVisibility()

v25 = cell25.getVisibility()

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

return sum

def updateCellVisibility(self):             # the “2)” process

for x in range(1,Xnumber-1):

for y in range(1,Ynumber-1):

for z in range(1,Znumber-1):

cell = self.ListCells[x][y][z]

cell.updateVisibility()

#################################################################

# 5. AUTOMATA VIEW

class AutomataView():

def __init__(self):

self.ListCells = []     # will be passed by AutomataModel

def setListCells(self, lc):

self.ListCells = lc

def getCoordinates(self):

ptlist = []

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

ptlist.append (pos)

length = len (ptlist)

return ptlist

def makeBoxes (self, points):

length = len (points)

print “point list =”, points

print “point list length =”, length #prints # of POINTS

percent = 0.8 * length # set PERECNTAGE

minority = int(percent) # count of input percentage of all POINTS

print “minority # =”, minority

majority = length – minority # count of remaining percentage of all POINTS

########################################################################

#for minority units

minorityrandomlist = []

for i in range(minority):

randomvalues = random.randint (0, length-1)

minorityrandomlist.append (randomvalues)

for r in minorityrandomlist :

rs.AddLayer(“Small Unit”, Color.Red)

rs.CurrentLayer(“Small Unit”)

rectangle = rs.AddRectangle(points[r], 0.5, 1)

path = rs.AddLine([0,0,0], [0,0,1]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

rs.CapPlanarHoles(extrusion)

rs.DeleteObject(path)

minorityrandomlist = list (set(minorityrandomlist)) #removes duplicate numbders

minorityrandomlist.sort() #sorts the list in ascending order

print “minority random list =”, minorityrandomlist

########################################################################

#for majority units

majorityrandomlist = []

for i in range (length):

majorityrandomlist.append (i)

print “majority random list =”, majorityrandomlist

for x in minorityrandomlist:

majorityrandomlist.remove (x)

for r in majorityrandomlist: #Makes Large Unit

rs.AddLayer(“Large Unit”, Color.Blue)

rs.CurrentLayer(“Large Unit”)

rectangle = rs.AddRectangle(points[r], 1, 1)

path = rs.AddLine([0,0,0], [0,0,1]) # Height

extrusion = rs.ExtrudeCurve (rectangle, path)

rs.CapPlanarHoles(extrusion)

rs.DeleteObject(path)

def moveGeometries(self):

#rs.Sleep(1000)

allObjIDs = rs.AllObjects()

trans = [20,0,0]

rs.MoveObjects(allObjIDs, trans)

#################################################################

# 6. RUN AUTOMATA CONTORLLER

ac = AutomataController()

ac.initiateModel()

juney jaeyual 20120416 CORE + STAIR

This slideshow requires JavaScript.

 

juney jaeyual 20120416 CORE

import rhinoscriptsyntax as rs

 

class Site():

def __init__ (self):

self.p = rs.WorldXYPlane()

self.w = 100

self.h = 100

def makeSite(self):

site_boundary = rs.AddRectangle(self.p, self.w, self.h)

site = rs.AddPlanarSrf(site_boundary)

 

s = Site()

site = s.makeSite()

 

class Core():

def __init__ (self):

self.center = [40,40,0]

self.p = rs.WorldXYPlane()

self.w = 20

self.h = 20

self.core_h = 400

def makeCore(self):

core_boundary = rs.AddRectangle(self.p, self.w, self.h)

core_boundary = rs.MoveObject(core_boundary, self.center)

path = rs.AddLine([0,0,0], [0,0,self.core_h])

core = rs.ExtrudeCurve(core_boundary, path)

rs.DeleteObject(path)

core = rs.CapPlanarHoles(core)

return core

 

c = Core()

core = c.makeCore()

 

class Elevator():

def __init__ (self):

self.core_h = 400

self.ptS = [50,0,0]

self.ptE = [50,100,0]

self.p = rs.WorldZXPlane()

self.h = 6

self.w = 7

self.trans = [42,60,0]

self.trans2 = [52,60,0]

self.n_floors = 40

self.f_h = 10

def makeECoreWall(self):

pt1 = [41,51,0]

pt2 = [49,51,0]

pt3 = [49,59,0]

pt4 = [41,59,0]

pts = [pt1,pt2,pt3,pt4,pt1]

ecorefloor_l = rs.AddPolyline(pts)

path = rs.AddLine([0,0,0], [0,0,self.core_h])

ecorefloor = rs.ExtrudeCurve(ecorefloor_l, path)

rs.DeleteObject(path)

ecorefloor2 = rs.MirrorObject(ecorefloor, self.ptS, self.ptE, True)

return ecorefloor

return ecorefloor2

def makeEdoor(self):

Edoor_l = rs.AddRectangle(self.p, self.w, self.h)

Edoor_l = rs.MoveObject(Edoor_l, self.trans)

path = rs.AddLine([0,0,0],[0,-1,0])

Edoor = rs.ExtrudeCurve(Edoor_l, path)

rs.DeleteObject(path)

rs.DeleteObject(Edoor_l)

return Edoor

 

def makeEdoor2(self):

Edoor_l = rs.AddRectangle(self.p, self.w, self.h)

Edoor_l = rs.MoveObject(Edoor_l, self.trans2)

path = rs.AddLine([0,0,0],[0,-1,0])

Edoor2 = rs.ExtrudeCurve(Edoor_l, path)

rs.DeleteObject(path)

rs.DeleteObject(Edoor_l)

return Edoor2

 

def copyEdoor(self, Edoor):

index = range(1, self.n_floors)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(Edoor, trans2)

 

def copyEdoor2(self, Edoor2):

index = range(1, self.n_floors)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(Edoor2, trans2)

 

def makeECore(self):

ecore_wall = self.makeECoreWall()

edoor = self.makeEdoor()

edoors = self.copyEdoor(edoor)

edoor2 = self.makeEdoor2()

edoors2 = self.copyEdoor2(edoor2)

 

 

e = Elevator()

e.makeECore()

 

#################################################################################

 

juney jaeyual 20120416 STAIRS

import rhinoscriptsyntax as rs

 

class BuildStairs ():

def __init__ (self):

self.o = [46.5,40,0]

self.riser = 0.5

self.tread = 1

self.w = 3.5

self.n_steps = 10

self.f_h = 10

self.n_floors = 40

self.stair = []

 

def createStep(self):

pt1 = [self.o[0], self.o[1], self.o[2]]

riser_r = self.o[2] + self.riser

pt2 = [self.o[0], self.o[1], riser_r]

tread_r = self.o[0] + self.tread

pt3 = [tread_r, self.o[1], riser_r]

pts = [pt1, pt2, pt3]

pline = rs.AddPolyline(pts)

path_start = [0, 0, 0]

path_end = [0, self.w, 0]

path = rs.AddLine(path_start, path_end)

step = rs.ExtrudeCurve(pline, path)

construction_lines = [pline, path]

rs.DeleteObjects(construction_lines)

return step

 

def copyStep(self, step):

stairs = []

index = range(0, self.n_steps)

for i in index:

trans1 = [self.tread * i,  0, self.riser * i]

objID1 = rs.CopyObject(step, trans1)

stairs.append(objID1)

return stairs

 

def makeStair(self):

step = self.createStep()

stair = self.copyStep(step)

return stair

 

def makeStair2(self, stair):

stair2 = rs.CopyObjects(stair)

stair2 = rs.RotateObjects(stair, [51.5,45,0], 180)

trans = [0,0,self.f_h/2]

stair2 = rs.MoveObjects(stair2, trans)

return stair2

 

def makeCoreFloor(self):

pt1 = [40,40,0]

pt2 = [46.5,40,0]

pt3 = [46.5,50,0]

pt4 = [40,50,0]

pts = [pt1,pt2,pt3,pt4,pt1]

corefloor_l = rs.AddPolyline(pts)

corefloor = rs.AddPlanarSrf(corefloor_l)

rs.DeleteObject(corefloor_l)

return corefloor

 

def makeCoreFloor2(self):

pt1 = [56.5,40,0]

pt2 = [60,40,0]

pt3 = [60,50,0]

pt4 = [56.5,50,0]

pts = [pt1,pt2,pt3,pt4,pt1]

corefloor2_l = rs.AddPolyline(pts)

corefloor2 = rs.AddPlanarSrf(corefloor2_l)

trans = [0,0,self.f_h/2]

corefloor2 = rs.MoveObject(corefloor2, trans)

rs.DeleteObject(corefloor2_l)

return corefloor2

 

def copyStair(self, stair):

index = range(1, self.n_floors)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(stair, trans2)

 

def copyStair2(self, stair2):

index = range(1, self.n_floors)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(stair2, trans2)

 

def copyCoreFloor(self, corefloor):

index = range(1, self.n_floors+1)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(corefloor, trans2)

 

def copyCoreFloor2(self, corefloor2):

index = range(1, self.n_floors)

for i in index:

trans2 = [0, 0, self.f_h * i]

objID2 = rs.CopyObject(corefloor2, trans2)

 

def makeStairs(self):

stair = self.makeStair()

stairs = self.copyStair(stair)

stair2 = self.makeStair2(stair)

stairs2 = self.copyStair2(stair2)

corefloor = self.makeCoreFloor()

corefloors = self.copyCoreFloor(corefloor)

corefloor2 = self.makeCoreFloor2()

corefloors2 = self.copyCoreFloor2(corefloor2)

 

bs = BuildStairs()

bs.makeStairs()

 

 

juney jaeyual 20120411 + 20120412

This slideshow requires JavaScript.

juney jaeyual 20120412

 

The core and stairs work properly, but had to be moved manually to be located correctly within the building.

 

import rhinoscriptsyntax as rs

from System.Drawing import Color

 

Xnumber = 8

Ynumber = 8

Znumber = 16

 

#################################################################

# 1. CELL (Condition/Rules)

class Cell():

def __init__(self, x, y, z):

self.X = x

self.Y = y

self.Z = z

self.Pos = [x,y,z]

self.Visibility = False     # Cell’s visibility(True means On/Alive, False means Off/Dead)

self.N = 0                  # Number of Neighboring Cells

 

def getVisibility(self):

return self.Visibility

 

def setVisibility(self, v):     # v will be True or False

self.Visibility = v

 

def getN(self):

return self.N

 

def setN(self, n):              # n is the number of neighbors

self.N = n

 

def getX(self):

return self.X

 

def getY(self):

return self.Y

 

def getZ(self):

return self.Z

 

def getPos(self):

return self.Pos

 

def updateVisibility(self):

if (self.Visibility == True):       # ALIVE cell = apply rule1_visibility

self.rule1_Visibility()

else: #(self.Visibility == False)   # DEAD cell =  apply rule2_visibility

self.rule2_Population()

 

def rule1_Visibility(self):

if (self.N < 12):

self.setVisibility(False)

elif (self.N < 22):

self.setVisibility(True)

else:

self.setVisibility(False)

 

def rule2_Population(self):

if (self.N <5):

self.setVisibility(True)

elif (self.N < 10):

self.setVisibility(False)

elif (self.N < 22):

self.setVisibility(True)

else:

pass

 

#def rule1_Visibility(self):

#if (self.N < 50):

#self.setVisibility(False)

#elif (self.N < 15):

#self.setVisibility(True)

#else:

#self.setVisibility(False)

#

#def rule2_Population(self):

#if (self.N == 0 or self.N == 5 or self.N == 10):

#self.setVisibility(True)

#elif (self.N < 5):

#self.setVisibility(False)

#elif (self.N < 10):

#self.setVisibility(True)

#else:

#pass

 

#################################################################

# 2. SET OF CELLS

class SetOfCells():

def __init__(self):

self.ListCells = []     # list containing all cell classes

self.generateCells()    # these two functions automatically run when the class is initiated.

self.setSeeds()

 

def generateCells(self):

xCellList = []          # this is the outer list of nested list(ListCells)

for x in range(Xnumber):

yCellList = []      # this is the inner list of a nested list(ListCells)

for y in range(Ynumber):

zCellList = []

for z in range(Znumber):

c = Cell(x,y,z)

zCellList.append(c)

yCellList.append(zCellList)

xCellList.append(yCellList)

self.ListCells = xCellList  # returns the nested list into self.ListCells

 

def setSeeds(self):     # this function defines initial states of cells

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

if (x > 1 and x < 7 and y > 1 and y < 7 and z > 2 and z < 15): # initial condition

cell.setVisibility(True)

else:

cell.setVisibility(False)

 

def getCells(self):     # getter for self.ListCells

return self.ListCells

 

#################################################################

# 3. AUTOMATA CONTROLLER

class AutomataController():

def __init__(self):

self.ListCells = []

self.SC = SetOfCells()      # generate cells and contain them in a list

self.M = AutomataModel()    # initiates AutomataModel

 

def initiateModel(self):

self.ListCells = self.SC.getCells()     # gets the generated cells

self.M.setListCells(self.ListCells)     # passes the list of cells into AutomataModel

self.M.repeatProcesses()                # calls repeating processes

 

#################################################################

# 4. AUTOMATA MODEL

class AutomataModel():

def __init__(self):

self.ListCells = []         # will be passed by AutomataConroller

self.V = AutomataView()     # initiates View class

 

def setListCells(self, lc):     # s etter

self.ListCells = lc

 

def repeatProcesses(self):      # repeats the two processes and make geometries

iterationNumber = 7

for i in range(iterationNumber):

self.checkNeighboringCells()

self.updateCellVisibility()

self.V.setListCells(self.ListCells) # passes self.ListCells into View

self.V.makeGeometries()

self.V.moveGeometries()

 

def checkNeighboringCells(self):            # the “1)” process

for i in range(1,Xnumber-1):

for j in range(1,Ynumber-1):

for k in range(1,Znumber-1):

cell = self.ListCells[i][j][k]     # gets each cell information

x = cell.getX()

y = cell.getY()

z = cell.getZ()

n = self.calculateNumberOfNeighboringCells(x,y,z)

cell.setN(n)

 

def calculateNumberOfNeighboringCells(self, x, y, z):

cell0 = self.ListCells[x-1][y-1][z-1]

cell1 = self.ListCells[x][y-1][z-1]

cell2 = self.ListCells[x+1][y-1][z-1]

cell3 = self.ListCells[x-1][y][z-1]

cell4 = self.ListCells[x][y][z-1]

cell5 = self.ListCells[x+1][y][z-1]

cell6 = self.ListCells[x-1][y+1][z-1]

cell7 = self.ListCells[x][y+1][z-1]

cell8 = self.ListCells[x+1][y+1][z-1]

 

cell9 = self.ListCells[x-1][y-1][z]

cell10 = self.ListCells[x][y-1][z]

cell11 = self.ListCells[x+1][y-1][z]

cell12 = self.ListCells[x-1][y][z]

cell13 = self.ListCells[x+1][y][z]

cell14 = self.ListCells[x-1][y+1][z]

cell15 = self.ListCells[x][y+1][z]

cell16 = self.ListCells[x+1][y+1][z]

 

cell17 = self.ListCells[x-1][y-1][z+1]

cell18 = self.ListCells[x][y-1][z+1]

cell19 = self.ListCells[x+1][y-1][z+1]

cell20 = self.ListCells[x-1][y][z+1]

cell21 = self.ListCells[x][y][z+1]

cell22 = self.ListCells[x+1][y][z+1]

cell23 = self.ListCells[x-1][y+1][z+1]

cell24 = self.ListCells[x][y+1][z+1]

cell25 = self.ListCells[x+1][y+1][z+1]

 

v0 = cell0.getVisibility()

v1 = cell1.getVisibility()

v2 = cell2.getVisibility()

v3 = cell3.getVisibility()

v4 = cell4.getVisibility()

v5 = cell5.getVisibility()

v6 = cell6.getVisibility()

v7 = cell7.getVisibility()

v8 = cell8.getVisibility()

v9 = cell9.getVisibility()

v10 = cell10.getVisibility()

v11 = cell11.getVisibility()

v12 = cell12.getVisibility()

v13 = cell13.getVisibility()

v14 = cell14.getVisibility()

v15 = cell15.getVisibility()

v16 = cell16.getVisibility()

v17 = cell17.getVisibility()

v18 = cell18.getVisibility()

v19 = cell19.getVisibility()

v20 = cell20.getVisibility()

v21 = cell21.getVisibility()

v22 = cell22.getVisibility()

v23 = cell23.getVisibility()

v24 = cell24.getVisibility()

v25 = cell25.getVisibility()

 

sum = v0+v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16+v17+v18+v19+v20+v21+v22+v23+v24+v25

 

return sum

 

def updateCellVisibility(self):             # the “2)” process

for x in range(1,Xnumber-1):

for y in range(1,Ynumber-1):

for z in range(1,Znumber-1):

cell = self.ListCells[x][y][z]

cell.updateVisibility()

 

#################################################################

# 5. AUTOMATA VIEW

class AutomataView():

def __init__(self):

self.ListCells = []     # will be passed by AutomataModel

 

def setListCells(self, lc):

self.ListCells = lc

 

def hexagonpoints(self, origin, x):

rs.AddLayer(“POINTS”, Color.Magenta)

rs.CurrentLayer(“POINTS”)

trans = [x,0,0]

point = rs.AddPoint(origin)

pt0 = rs.MoveObject(point, trans)

pt0c = rs.PointCoordinates(pt0)

pt1 = rs.RotateObjects(pt0, origin, 60, axis=None, copy=True)

pt1c = rs.PointCoordinates(pt1)

pt2 = rs.RotateObjects(pt0, origin, 120, axis=None, copy=True)

pt2c = rs.PointCoordinates(pt2)

pt3 = rs.RotateObjects(pt0, origin, 180, axis=None, copy=True)

pt3c = rs.PointCoordinates(pt3)

pt4 = rs.RotateObjects(pt0, origin, 240, axis=None, copy=True)

pt4c = rs.PointCoordinates(pt4)

pt5 = rs.RotateObjects(pt0, origin, 300, axis=None, copy=True)

pt5c = rs.PointCoordinates(pt5)

ptlist = [pt0c, pt1c, pt2c, pt3c, pt4c, pt5c, pt0c]

return ptlist

rs.DeleteObject(origin)

rs.DeleteObject(point)

rs.DeleteObject(pt0)

rs.DeleteObject(pt1)

rs.DeleteObject(pt2)

rs.DeleteObject(pt3)

rs.DeleteObject(pt4)

rs.DeleteObject(pt5)

def floors(self, pts):

rs.AddLayer(“FLOOR”, Color.Gray)

rs.CurrentLayer(“FLOOR”)

pline = rs.AddPolyline(pts)

thickness = -0.04

start = [0,0,0]

end = [0,0,thickness]

path = rs.AddLine(start, end)

slab = rs.ExtrudeCurve(pline, path)

rs.CapPlanarHoles(slab)

rs.DeleteObject(path)

rs.CopyObject(slab, [0,0,0.5])

rs.CopyObject(slab, [0,0,1])

rs.DeleteObject(pline)

rs.DeleteObjects(pts)

 

def wallcurves (self, outpts, inpts):

rs.AddLayer(“CURVES”, Color.Blue)

rs.CurrentLayer(“CURVES”)

lines = []

for i in range (0, 6):

connection1 = rs.AddLine (outpts[0], inpts[0])

connection2 = rs.AddLine (outpts[2], inpts[2])

connection3 = rs.AddLine (outpts[4], inpts[4])

lines = (connection1, connection2, connection3)

return lines

rs.DeleteObject(connection1)

rs.DeleteObject(connection2)

rs.DeleteObject(connection3)

rs.DeleteObject(outpts)

rs.DeleteObject(inpts)

def wallsrf (self, crv, height):

rs.AddLayer(“WALL”, Color.Red)

rs.CurrentLayer(“WALL”)

 

start = [0, 0, 0]

end = [0, 0, height-0.04]

path = rs.AddLine (start, end)

walls = []

for i in range (0, 3):

surfaceID = rs.ExtrudeCurve (crv[i], path)

walls.append (surfaceID)

return walls

rs.DeleteObject(crv)

rs.DeleteObject(path)

 

def glass (self, pts, height):

rs.AddLayer(“GLASS”, Color.Aqua)

rs.CurrentLayer(“GLASS”)

 

start = [0, 0, 0]

end = [0, 0, 0.5-0.04]

path = rs.AddLine (start, end)

pline = rs.AddPolyline(pts)

glass = rs.ExtrudeCurve (pline, path)

rs.CopyObject(glass, [0,0,0.5])

rs.DeleteObject(pts)

rs.DeleteObject(path)

 

def coretube (self, coreradius):

rs.AddLayer(“CORE”, Color.White)

rs.CurrentLayer(“CORE”)

base = [0, 0, 0]

rs.AddCylinder (base, Znumber, coreradius, cap=True)

 

def stairarray (self, coreradius):

rs.AddLayer(“STAIRS”, Color.Beige)

rs.CurrentLayer(“STAIRS”)

plane = rs.WorldXYPlane()

 

 

 

 

width = 0.1

height = coreradius+0.2

stairnumber = 20

rotation = 360/stairnumber

rise = 1/stairnumber

start = [0, 0, 0]

end = [0, 0, -0.02]

path = rs.AddLine (start, end)

rectangle = rs.AddRectangle (plane, width, height)

move = [Xnumber/2, Ynumber/2, 0]

path2 = rs.AddLine(start, move)

movedrectangle = rs.MoveObject(rectangle, path2)

stair = rs.ExtrudeCurve (rectangle, path)

if stair:

rs.CapPlanarHoles (stair)

stairgroup = []

for i in range (0,stairnumber,1):

rotatedstair = rs.RotateObjects (stair, start, rotation)

copiedstair = rs.CopyObjects (rotatedstair, [0, 0, i*rise])

stairgroup.append(copiedstair)

return stairgroup

 

 

 

 

 

 

 

def staircopy (self, stair):

index = range (Znumber-1)

for i in index:

copiedstairs = rs.CopyObjects (stair, [0, 0, i*1])

rs.DeleteObjects (stair)

return copiedstairs

 

 

 

 

 

 

def makeGeometries(self):

for x in range(Xnumber):

for y in range(Ynumber):

for z in range(Znumber):

cell = self.ListCells[x][y][z]

visibility = cell.getVisibility()

if visibility == True:

pos = cell.getPos()

outpts = self.hexagonpoints(pos, 0.6)

inpts = self.hexagonpoints (pos,0.25)

curves = self.wallcurves (outpts, inpts)

self.wallsrf (curves, 1)

self.floors(outpts)

self.glass(outpts, 1)

#self.coretube (0.3)

#

#

#stairgroup = self.stairarray (0.3)

#

#

#self.staircopy (stairgroup)

 

 

rs.DeleteObject(outpts)

rs.DeleteObject(inpts)

rs.DeleteObject(curves)

 

def moveGeometries(self):

#rs.Sleep(1000)

allObjIDs = rs.AllObjects()

trans = [20,0,0]

rs.MoveObjects(allObjIDs, trans)

 

def deleteGeometries(self):

#rs.Sleep(1000)

allObjIDs = rs.AllObjects()

rs.DeleteObjects(allObjIDs)

 

#################################################################

# 6. RUN AUTOMATA CONTORLLER

ac = AutomataController()

ac.initiateModel()

 

av = AutomataView()

 

av.coretube (0.2)

stairgroup = av.stairarray (0.2)

allstairs = av.staircopy (stairgroup)

 

start = [0, 0, 0]

move = [Xnumber/2, Ynumber/2, 0]

path2 = rs.AddLine(start, move)

rs.MoveObjects(allstairs, path2)

juney jaeyual proposal

This slideshow requires JavaScript.

The purpose of the final project

We want to further investigate Cellular Automata using 3d cell list.

What we’ve been experimenting was more or less random iteration

of CA using arbitrary setSeed() function with no control of mass generation.

We want to investigate more specific and functional rule in place of just

visibility and re-population rules for generating mass, whether it is a public

promenade through the mass, or spatial quality of multiple height spaces

in a controlled sequence.