Cellular Automata

Cellular automata are simulations on a discrete grid of cells which have a finite set of states. At each new timestep, each cell's new state is determined by the states of its neighbours.

For example, the most popular cellular automaton is Conway's game of life, which has the following rules:

Source: wikipedia

Note that each cell only has 2 states: alive (black) or dead (white).

This simple set of rules gives rise to intricate and complex behaviours over time, with areas of activity that almost seem organic.

Conway's game of life

The book Cellular Automata Machines explores the topic in great depth and presents many other cellular automata rulesets. Here's one that they call BRIAN'S BRAIN , which uses 3 states.

This simulates the activity of a neuron, where it will only become activated (State 1) if its neighbours are activated (the 2-neighbour condition in State 0), and it must wait (State 2) before it is ready to be activated again (State 0). Cells in State 1 are drawn in black, all others in white.

Brian's Brain

Technical Notes

The cellular automaton simulator program was written in C. It output .ppm files which were turned into videos using ffmpeg.

I chose to output .ppm files since this program was so small that I didn't want to involve any dependencies beyond the C standard library. Unlike more common image formats like .bmp and .png, .ppm is a plaintext format, meaning I could easily write data to a normal text file without having to worry about a binary data format. Then ffmpeg just takes care of the rest.