algorithmic modeling for Rhino
Scripted with Python in Grasshopper
Tags:
Comment
Hi Pieter, many thanks!
This is a work I've done more than a year ago, so sorry but I do not remember exactly, anyway:
-at the beginning the cells are all white
-if the cell where the ant passes it is white> ant turns 90 degrees counterclockwise around the z axis and the cell where it is passed to red
-if the cell where the ant goes it is red> the ant rotates clockwise around the x axis and the cell where it is passed becomes black
-if the cell where the ant goes is black> the ant rotates clockwise around the x axis and the cell where it is passed again becomes white
-The Mesh is formed only from the white cells.
This is the piece of code that concerns the rules and colors render:
def render(self):
colors = []
for val in self.vals:
if val==0 :
colors.append([255,255,255])
elif val==2:
colors.append([0,0,0])
else:
colors.append([255,0,0])
return colors
def move(self, myAntFarm):
#check the state (val) of the cell this ant is on
if state == 0:#if the cell is white
self.vec = rs.VectorRotate(self.vec, -90,[0,0,1])
myAntFarm.vals[self.index] = 1
elif state == 1:#if the cell is red
self.vec = rs.VectorRotate(self.vec, 90, [1,0,0])
myAntFarm.vals[self.index] = 2
else:#if the cell is black
self.vec = rs.VectorRotate(self.vec, 90, [0,1,0])
myAntFarm.vals[self.index] = 0
Very nice Massimiliano. Can I ask what rules you used?
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by
You need to be a member of Grasshopper to add comments!