Tiny Arcade five small games
  1. Tiny Arcade
  2. Life

Life

Conway's cellular automaton: three rules, infinite behaviour. Draw on the board, then watch simple patterns build gliders, oscillators and debris.

Your browser does not support the canvas element. The game cannot run, but the rules are described below.
Generation 0 Alive 0 State Paused

Click or drag to paint cells. Hold Space to step forward.Drag to paint cells. Use Step or Run to advance.

The rules

Conway's Game of Life takes place on a grid of cells, each of which is either alive or dead. Every cell looks at its eight neighbours — horizontally, vertically and diagonally — and three rules decide what happens next:

  • Survival. A live cell with exactly two or three live neighbours stays alive.
  • Birth. A dead cell with exactly three live neighbours becomes alive.
  • Death. Every other cell dies, or stays dead — from underpopulation (fewer than two neighbours) or overcrowding (more than three).

All three rules are applied to every cell at the same time, based on the state before the step. That simultaneity is what makes the system interesting: a naive loop that updates in place produces a completely different — and much duller — automaton, so this implementation writes each generation into a second buffer and swaps the two afterwards.

Controls

Click / tapToggle a cell; drag to paint
Space (hold)Advance generations
Run / pauseRun continuously at about nine generations per second
StepAdvance exactly one generation
RandomFill the board with random cells

Patterns to try

The board opens with a few known patterns. A glider is five cells that travel one cell diagonally every four generations — on this wrapped grid it will circle forever. A blinker is three cells in a row that flips between horizontal and vertical with period two. The board also seeds a lightweight spaceship, an R-pentomino (which famously churns for over a thousand generations) and a couple of still lifes.

Because the grid is toroidal, edges are not walls. Patterns that would normally escape the board reappear on the opposite side, which makes long-lived experiments possible in a space this small.

Notes on the implementation

The grid is 48 by 36 cells stored in two flat typed arrays. Neighbour counts wrap with modular arithmetic, so there are no edge special cases and no branches in the inner loop. Only live cells are drawn, which keeps a mostly empty board cheap to render.