Conway's Game of Life: how simple rules create complexity
What is Conway’s Game of Life?
In 1970, mathematician John Horton Conway published a zero-player game: a cellular automaton on a grid of cells, each either alive or dead, that evolves in discrete steps according to four rules. No strategy, no input, just the rules and a starting grid.
The four rules
- A live cell with fewer than two live neighbors dies (underpopulation).
- A live cell with two or three live neighbors stays alive.
- A live cell with more than three live neighbors dies (overpopulation).
- A dead cell with exactly three live neighbors becomes alive.
That’s all of it, and a lot comes out of it.
Why it fascinates me
What draws me in is what emerges from the rules.
Emergence
Emergence is when complex behavior comes out of simple interactions. No rule says “make a glider” or “make an oscillator”, yet those structures show up on their own. A glider is a five-cell pattern that walks diagonally across the grid indefinitely. Nobody told it to move; it moves because of the rules.
The same idea, complexity without complex foundations, shows up all over the place. Ants follow simple chemical signals, and the colony builds nests, farms fungus, and fights wars. Each bird in a flock follows three rules (separation, alignment, cohesion), and the flock moves as one. Individual neurons fire or don’t, and minds run on billions of those binary decisions. Individual buy and sell orders aggregate into booms and crashes that no trader intended.
The Game of Life is about the cleanest version of this you can point at.
The patterns people have found
Over the decades enthusiasts have catalogued a lot of structures: still lifes that never change (blocks, beehives, loaves), oscillators that cycle through a fixed set of states (blinkers, pulsars, pentadecathlons), spaceships that travel across the grid (gliders, lightweight spaceships), glider guns that emit a glider on a period, and methuselahs, tiny starting patterns that churn for hundreds of generations before settling down.
The Gosper Glider Gun, found in 1970, was the first known pattern that grows without bound. It fires a new glider every 30 generations: a fixed structure that manufactures moving objects, out of four rules about counting neighbors.
The Game of Life is also Turing complete. You can build logic gates and memory inside it, and in principle a whole computer. Four rules about counting neighbors can, in principle, simulate anything computable.
My implementation
My implementation is in TypeScript with a canvas renderer and a cyberpunk look.
Architecture
The code keeps concerns separate. GameOfLife is the simulation engine and knows nothing about rendering. It holds a 2D boolean grid and applies the rules:
nextGeneration(): void {
const newGrid = this.createEmptyGrid();
for (let row = 0; row < this.rows; row++) {
for (let col = 0; col < this.cols; col++) {
const neighbors = this.countNeighbors(row, col);
const isAlive = this.grid[row][col];
if (isAlive) {
newGrid[row][col] = this.survivalRule.has(neighbors);
} else {
newGrid[row][col] = this.birthRule.has(neighbors);
}
}
}
this.grid = newGrid;
}
CanvasRenderer handles the visual output, with glow effects and a neon palette. GameController wires up the UI: buttons, speed control, grid resizing, keyboard shortcuts, and the animation loop.
Custom rules
The classic Game of Life uses B3/S23 notation: birth with 3 neighbors, survival with 2 or 3. The engine takes arbitrary birth and survival sets, so it also runs other cellular automata:
| Rule set | Notation | Behavior |
|---|---|---|
| Conway | B3/S23 | The classic, balanced dynamics |
| HighLife | B36/S23 | Like Conway, plus a self-replicating pattern |
| Day & Night | B3678/S34678 | Dead and alive behave identically |
| Seeds | B2/S | Explosive; every cell dies each turn |
| Diamoeba | B35678/S5678 | Large amoeba-like blobs |
Same grid, same renderer, different behavior, just by changing which numbers go into the birth and survival sets.
Try it
Below is a compact interactive demo. The full version adds speed control, grid resizing, drag-to-resize edges, rule presets, and keyboard shortcuts. Click or drag to draw cells, then hit Start.
Why it stays with me
I keep coming back to what the patterns imply. Our universe seems to run on fairly simple physical laws, particles interacting through a handful of forces, and out of that come atoms, molecules, cells, brains. The Game of Life is a toy version of the same thing: a few lines of code, four rules about counting neighbors, and a large space of structure and motion falling out of them.
Source for my implementation is on GitHub, if you want to fork it or try your own rules.