What is this?
So you're asking the eternal question: what the heck is a generic cellular automata simulator? Here's the simplest explanation I can figure out.
A cellular automaton has three parts:
- a grid of cells, where each cell is in one of a small number of states (the simplest case: alive or dead),
- a neighborhood — which nearby cells each cell can "see", and
- a rule — a function that looks at a cell and its neighbors and decides the cell's next state.
Time advances in generations. Every generation, the rule is applied to every cell simultaneously, producing the next grid. That's the whole machine. The surprise is how much behavior falls out of it.
Conway's Game of Life
The best-known rule comes from John Conway. Each cell looks at its eight surrounding neighbors:
- A live cell with two or three live neighbors stays alive.
- A dead cell with exactly three live neighbors becomes alive.
- Every other cell dies (or stays dead).
Those three lines are enough to produce gliders — patterns that move:
The grid here wraps around at the edges (it's a torus), so the glider travels forever. "Alive" and "dead" don't mean anything deep — they're just names for states 1 and 0, and rules can use more than two states. In the forest fire rule, cells cycle through empty, tree, and burning. In the cyclic rule, twelve states chase each other in spirals.
One-dimensional automata
The simplest interesting automata live on a line instead of a grid: each cell sees only itself and its left and right neighbors. With two states and three visible cells there are only 28 = 256 possible rules, so they can all be numbered and studied exhaustively. Drawing each generation as a row, time flowing downward, you get pictures like this:
This one is Wolfram's rule 30, starting from a single live cell — famous because such a tiny deterministic rule produces output chaotic enough to be used as a random number generator.
How this simulator works
Everything on this site runs on one generic engine: you give it grid dimensions, a number of states, a neighborhood, and a rule function, and it does the rest. A few notes on its shape:
- Cells are squares, and the neighborhood is configurable — the von Neumann neighborhood (4 neighbors) or the Moore neighborhood (8 neighbors, used by Life).
- All cells update synchronously, the standard convention for cellular automata (asynchronous variants exist, but aren't supported here).
- Grids are toroidal: edges wrap around, so there is no boundary.
- Any rule you can write as a JavaScript function works. The demo page ships a menu of classics, and you can share a drawing with the Share button, which encodes the whole grid in the URL.
The code is on GitHub. Back to the simulator.