Grasshopper

algorithmic modeling for Rhino

Scripted with Python in Grasshopper

Views: 294

Comment

You need to be a member of Grasshopper to add comments!

Comment by Massimiliano Trave on January 16, 2017 at 1:58am

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

I hope it is understandable ...my english is very bad :)
Cheers!
Comment by Pieter Segeren on January 13, 2017 at 2:17pm

Very nice Massimiliano. Can I ask what rules you used?

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service