Wolfram's elementary CA, Conway's Game of Life, and the stunning complexity that emerges from the simplest possible rules.
In this chapter, we take a major turn. No more vectors, no more forces. Instead, we build a system out of the simplest digital element possible: a single bit. A cell with a state of 0 or 1.
A cellular automaton (CA) is a model of "cell" objects with these characteristics:
| Component | Description |
|---|---|
| Grid | Cells live on a grid (1D, 2D, or higher). |
| States | Each cell has a finite set of states (simplest: 0 or 1). |
| Neighborhood | Each cell has a defined set of neighbors. |
| Rules | A cell's next state is a function of its current neighborhood. |
Stephen Wolfram asked: "What is the simplest cellular automaton we can imagine?" The answer is surprisingly powerful.
The simplest CA has: (1) a 1D grid — a line of cells; (2) two states — 0 or 1; (3) a neighborhood of three — the cell itself plus its left and right neighbors.
The standard approach: start generation 0 with all cells at state 0 except the middle cell at state 1. Apply the ruleset to compute generation 1, then generation 2, and so on. Stack the generations vertically, coloring 1 as dark and 0 as light.
A ruleset maps each 3-bit neighborhood to an output state. Since the neighborhood is a 3-bit binary number, we can index it directly. The ruleset for "Rule 90":
| Neighborhood | 111 | 110 | 101 | 100 | 011 | 010 | 001 | 000 |
|---|---|---|---|---|---|---|---|---|
| Output | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
The binary sequence 01011010 is decimal 90 — hence "Rule 90." It produces the Sierpinski triangle.
pseudocode next = new array(cells.length) for i in 1..cells.length-2: left = cells[i-1] middle = cells[i] right = cells[i+1] next[i] = ruleset[toBinary(left, middle, right)] cells = next
Of 256 rulesets, most produce boring results. Wolfram classified the outcomes into four categories:
| Class | Behavior | Example |
|---|---|---|
| 1: Uniformity | All cells become the same state | Rule 222 |
| 2: Repetition | Cells oscillate in a regular pattern | Rule 190 |
| 3: Random | Appears chaotic, no discernible pattern | Rule 30 (used in Mathematica's RNG!) |
| 4: Complexity | Mix of repetition and randomness — the sweet spot | Rule 110 |
In 1970, mathematician John Conway invented the Game of Life. It's a 2D cellular automaton with remarkably lifelike behavior.
The setup: a 2D grid of cells. Each cell is alive (1) or dead (0). Each cell has eight neighbors (the 3×3 block surrounding it, minus itself).
Instead of defining an outcome for all 512 possible 9-cell configurations, Conway defined rules based on the count of live neighbors:
These four rules produce an astonishing variety of patterns: static "still lifes," oscillating "blinkers," and moving "gliders" that travel across the grid.
The implementation mirrors the 1D CA, but with a 2D array and a nested neighbor-counting loop:
pseudocode next = new grid[cols][rows] for x in 1..cols-2: for y in 1..rows-2: neighbors = 0 for i in -1..1: for j in -1..1: neighbors += board[x+i][y+j] neighbors -= board[x][y] # Don't count self! if board[x][y] == 1 and neighbors < 2: next[x][y] = 0 elif board[x][y] == 1 and neighbors > 3: next[x][y] = 0 elif board[x][y] == 0 and neighbors == 3: next[x][y] = 1 else: next[x][y] = board[x][y] board = next
The Game of Life is just the beginning. Here are ways to push CA further:
| Variation | Idea |
|---|---|
| Hexagonal grids | Each cell has 6 neighbors instead of 8. Different dynamics. |
| Probabilistic rules | "80% chance of dying" instead of guaranteed death. Stochastic CA. |
| Continuous states | State is a float (0.0 to 1.0) instead of a binary. Smooth gradients. |
| Image processing | Pixel = cell, color = state. Blurring, ripples, ink dispersion. |
| Moving cells | Cells aren't fixed — combine CA with flocking or particle systems. |
| Historical | Cells remember past states. Adaptive behavior over time. |
Below is a live Game of Life. Click/tap cells to toggle them. Press Play to run the simulation, or Step to advance one generation at a time.
Click/tap to toggle cells. Watch still lifes, blinkers, and gliders emerge from random initial conditions.
| Topic | Key Takeaway |
|---|---|
| CA basics | Grid + states + neighborhood + rules |
| Elementary CA | 1D, 2 states, 3-cell neighborhood, 256 rulesets |
| Wolfram classes | Uniformity, repetition, randomness, complexity |
| Double buffer | Never overwrite cells while computing — use two arrays |
| Game of Life | 2D, 8 neighbors, 4 simple rules → lifelike behavior |
| Birth rule | Dead cell + exactly 3 neighbors = alive |
| Death rules | Too few (<2) or too many (>3) neighbors = death |
What we covered:
• Wolfram's elementary CA
• 256 rulesets, 4 classes
• Conway's Game of Life
• Birth, death, stasis rules
• Double-buffer technique
• OOP cells and variations
What comes next:
Chapter 8: Fractals. Recursion, self-similarity, the Koch curve, fractal trees, and L-systems. Nature's geometry, built from a function that calls itself.