2-state Cellular Automaton in Python for Grasshopper


I just got my hands on Python for rhino last week (more specifically on a package called ironpython), because I wanted to try out the capabilities and the adaptive character of this powerful scripting/coding language. What is interesting in the case of ironpython is the import of both the rhinoscript syntax and the Rhinocommon elements within the Grasshopper3d environment. Having prior programming experience python is fairly easy to learn and quite user friendly. The  feature of debugging without compiling the code is also really useful.

To test the scripting possibilities of Python I wrote a 2-state cellular automaton based on this code from Processing on Worlfram 2d CA’s. I have implemented both Rhinocommon and rhinoscript syntax commands and members in the code, plus I have introduced some time based evolving  just to make the simulation dynamic.


The algorithm can create a variety of patterns, emerging from the initial rule defining the state relation between the automata (ie. the famous rule 110). The parameters of the python component are the number of the rule  used, the width of the drawing grid, the size of the cell and the time. The process becomes kind of slow after a few iterations because lots of geometry is being generated, thus if the boxes were to be replaced by simple points the algorithm would have a much better performance.



Here is a small video documenting the process.

This is a snapshot of the grasshopper definition. I plan to release the code after I clean it up a little bit, so stay tuned if you want to try it out.


4 thoughts on “2-state Cellular Automaton in Python for Grasshopper

  1. Hi! It is very interesting.
    I’m wondering, how you control de Color output (in your video) is it a grasshopper component or is it inside the code. I come from a Processing world and I find Python quite difficult to have color .
    Thank you very much!

    • Hi Giselle,
      Thanks for your comment. Yes it’s indeed a GH component. But you can easily replicate its functionality in processing by mapping a set of values (in this case the distance of each new cellular automaton from the initial source of the growth) to rgb values of a gradient range.

      Hope this helps,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s