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:

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:

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:

The code is on GitHub. Back to the simulator.