Hi everybody,
A couple of years ago, when I first encountered the concept of Conway’s Game of Life, oftentimes referred to as cellular automaton, during my early architecture studies, I was kind of baffled and intrigued by it. For those of you, not familiar with architectural academia, the Game of Life, like the Vornoi diagram, particles, and other geometrical curiosities are often times experimented with to produce seemingly avant-garde design objects and/or buildings. Back then my overall CG and coding skills were still in early development, and the Game of Life remained a pretty much unrealised side-project.
I’ve revisited the concept the past weekend and am eager to share the results with you all.
For those of you not familiar, I’m not reporting about the parlor game, created in 1860 by Milton Bradley, although that would also be a great topic, but about the conceptual Game of Life devised by British mathematician John Conway in 1970.
It is basically a zero-player game, meaning that merely the initial conditions are set, and no further input is required beyond that. The initial configuration can then be observed evolving over generations, following a rather simple, yet ingenious set of rules.
The initial setup is an infinite, orthogonal, two-dimensional grid of rectangular cells, each of which is either alive or dead (populated or unpopulated). It is often referred to as seed of the game.
At each generation, the current state of every cell is reevaluated in function of its immediate neighbourhood. The following rules apply here:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
All concerned cell states are changed simultaneously, following the above rules, in a discreet moment called the thick, making each generation purely a function of the preceding one.
I’ve devised a fully animated Grasshopper User Object that is highly customisable (and even features a custom icon).
Inputs
- Plane: A base plane for the Game of Life (by default a world XY-plane)
- ExtendX: A number of grid cells in the base plane x-direction (by default 10)
- ExtendY: Number of grid cells in the base plane y-direction (by default 10)
- SizeX: Grid cell size in the base plane x-direction (by default 1.0)
- SizeY: Grid cell size in the base plane y-direction (by default 1.0)
- Max: Maximum number of generations (by default no restrictions)
-
Wrap: True to wrap the grid boundary, or False (by default True).
- Wrapping means that grid cells that form the grid boundary look for neighbours beyond the boundary on the opposite side, basically like in the Asteroids game from 1979, where you could pass the screen boundary with you spaceship and pop out on the opposite side. This is by default turned on, because the Game of Life is meant to be infinite!
-
Wrapping can be switched off though to prevent flying geometries, when stacking individual game generations to produce a three-dimensional Game of Life in recording mode.
-
Rec: True to record and output the full Game of Life history, or False to only to output only the current generation (by default False).
-
Recording allows you to produce a three-dimensional, stacked version of the Game of Life.
-
- Seed: Random seed for the initial setup of alive or dead cells
- Run: True to iterate the Game of Life, or False to pause it
- Reset: True to reset the Game of Life completely
Outputs
Non-recording mode:
- Count: The current generation count
- Cells: A tree of grid cell outlines with branches for each grid row
- States: A tree of current cell states (1 = alive, 0 = dead) with branches for each grid row
-
Ages: A tree of current cell ages with branches for each grid row
-
The cell age can for instance be used to color a cell.
-
Recording mode:
- Count: A tree of generation counts with branches for each generation
- Cells: A tree of grid cell outlines with branches for each generation that each include branches for each grid row
- States: A tree of current cell states (1 = alive, 0 = dead) with branches for each generation that each include branches for each grid row
- Ages: A tree of current cell ages with branches for each generation that each include branches for each grid row
Downloads
User object:
conways_game_of_life.zip (6.7 KB)
Example files:
conways_game_of_life_example_files.zip (40.8 KB)
Installation
In order to install the component, simply move it to the Grasshopper user objects folder (File > Special Folders > User Objects Folder).
Feel free to alter, manipulate, adapt or bastardize the Python code in any way you like. It is accessible by double clicking the component.
Please, leave feedback or report any bugs here! I would also be interested in seeing project images, if anybody uses the component to realise a design.