How it works

Game of Life

← Back to the demos

The grid is a set of cells that are either alive or dead. Every generation, each cell looks at its eight neighbors and decides its next state from one small rule table. Each cell sees only its neighbors, and the patterns emerge from that.

One generation

flowchart TD
  A["Start a new empty grid for the next generation"] --> B["Pick a cell in the current grid"]
  B --> C["Count live cells among its 8 neighbors, wrapping at the edges"]
  C --> D{"Is the cell alive?"}
  D -- yes --> E{"2 or 3 live neighbors?"}
  E -- yes --> F["Stays alive"]
  E -- no --> G["Dies"]
  D -- no --> H{"Exactly 3 live neighbors?"}
  H -- yes --> I["Becomes alive"]
  H -- no --> J["Stays dead"]
  F --> K["Write the result into the new grid"]
  G --> K
  I --> K
  J --> K
  K --> L{"More cells?"}
  L -- yes --> B
  L -- no --> M["Replace the old grid with the new one and redraw"]

Two details that matter

The four rules

Cell isLive neighborsNext generation
Alive0 or 1Dies (isolation)
Alive2 or 3Survives
Alive4 or moreDies (crowding)
DeadExactly 3Becomes alive

← Back to the demos