Cellular Automata

Simple rules, complex emergent behavior

Cellular Automata

What Are Cellular Automata?

A cellular automaton is a grid of cells, each in one of a finite number of states. At each time step, every cell updates its state based on a simple rule that considers only the cell's current state and the states of its immediate neighbors. No cell knows anything about the global state of the grid. There is no central controller. Yet from these purely local rules, large-scale patterns emerge: spirals, fractals, waves, and structures of striking complexity.

The concept was invented by John von Neumann and Stanislaw Ulam in the 1940s. Von Neumann was trying to understand self-replication: could a machine build a copy of itself? He showed that a cellular automaton could, in principle, contain a universal constructor capable of building any pattern, including a copy of itself. The most famous cellular automaton, John Conway's Game of Life (1970), demonstrated that a simple two-state rule on a square grid could produce structures that move, grow, reproduce, and even perform computation.

How These Automata Work

The automata below use a square grid where each cell has a state represented by a number (0, 1, 2, ...). At each step, a rule computes a new value for each cell based on its neighbors. The rule used here is modular arithmetic: sum the values of the cell and its four cardinal neighbors (up, down, left, right), then take the result modulo N (the number of states). Different values of N, different initial patterns, and different neighborhood definitions produce radically different behavior.

There is a subtle but important distinction between two update modes:

In-Place Update: The grid is modified as we scan through it. When computing cell (5, 3), the cells to its left and above have already been updated to their new values, while cells to its right and below still hold their old values. This asymmetry makes the evolution less predictable and more complex, because each cell is computed from a mixture of old and new states.
Double-Buffered Update: A snapshot of the grid is taken before the step. All cells read from the snapshot and write to the live grid. Every cell is computed from the same consistent state. This is the standard approach and produces more symmetric, predictable patterns.

Interactive Visualization

Use the controls to change the rule, the number of states, the initial pattern, and the update mode. Click Step to advance one generation, or Play to watch the automaton evolve continuously.

Generation: 0
Modular Sum: Each cell becomes (self + up + down + left + right) mod N. Simple arithmetic, surprising patterns.

The Rules

Modular Sum is the simplest rule: add the cell's value to its four cardinal neighbors, take the result modulo N. With 3 states and the "Modular Stripes" initial pattern, this produces the patterns from the original automata above. Switch between in-place and double-buffered modes to see how the update order changes the outcome dramatically.

XOR Automaton replaces addition with bitwise XOR. XOR (exclusive or) outputs 1 when inputs differ and 0 when they match. XOR automata tend to produce fractal-like, self-similar patterns reminiscent of Sierpinski triangles. They are reversible: XOR-ing again with the same value returns to the original.

Rock-Paper-Scissors simulates a spatial competition. Each cell is one of N species. A cell is "eaten" by the next species in the cycle (species 0 beats N-1, species 1 beats 0, species 2 beats 1, and so on). If enough of a cell's neighbors are its predator, it is converted. This rule produces traveling spiral waves that chase each other across the grid, a phenomenon observed in real biological systems like competing bacterial colonies.

Conway's Game of Life is the most famous cellular automaton. Cells are either alive (1) or dead (0). A live cell survives if it has 2 or 3 live neighbors; otherwise it dies. A dead cell becomes alive if it has exactly 3 live neighbors. From these two rules, an extraordinary zoo of patterns emerges: stable "still lifes," oscillating "blinkers," moving "gliders," and self-replicating "guns" that shoot gliders across the grid.

1D Wolfram (Rule 30) is a one-dimensional automaton displayed as a two-dimensional image: each row is one generation, with time flowing downward. Each cell looks at itself and its two immediate neighbors (3 cells, 8 possible configurations) and applies Rule 30 to determine the next state. Rule 30 is notable because it generates apparent randomness from a single seed cell. Stephen Wolfram used it as a random number generator.

What to Try

  • Start with Modular Sum, 3 states, Modular Stripes, In-Place to see the original automaton. Then switch to Double-Buffered mode and compare.
  • Increase the number of states to 5, 7, or 12 and watch how the patterns change.
  • Try Rock-Paper-Scissors with 5+ states and Random init for spiral waves.
  • Run Game of Life with Random init and watch structures self-organize. Look for gliders (small shapes that move diagonally).
  • Set Wolfram Rule 30, Center Seed and step through to watch a fractal-like pattern grow from a single cell.
  • Try every combination. The parameter space is large and most of it has never been explored.

Why Simple Rules Produce Complex Behavior

Cellular automata are existence proofs that complexity does not require complex rules. A three-state modular sum is about as simple as a rule can get, yet it generates patterns that no one would predict from reading the rule alone. Conway's Game of Life has two rules and produces structures capable of universal computation (you can build a Turing machine inside it). Wolfram's Rule 30 has one rule operating on three cells and generates output indistinguishable from randomness.

The complexity comes from interaction. Each cell's behavior is trivial in isolation. But each cell's output becomes its neighbors' input on the next step, and their outputs become its input on the step after that. Information propagates, interferes, amplifies, and cancels across the grid. The result is emergent behavior: global patterns that exist in the system but are not written into any individual cell's rule. No cell "knows" it is part of a spiral or a glider. The structure exists only at the level of the whole.

This is the same principle that governs flocking birds, ant colonies, market economies, and neural networks. Local rules, no central controller, complex global behavior. Cellular automata are the simplest possible demonstration of the principle.