Cellular Automata

First appeared 1970 · John Conway — Conway's Game of Life (1970); roots in von Neumann & Ulam, 1940s; Wolfram, 1983. · timeline ↗

community / folk Name — Descriptive term from the von Neumann / Ulam work (1940s); Conway's Game of Life (1970) is the best-known instance. Not a personal eponym.

In one line A discrete system in which each cell on a grid updates its state in step, according to a fixed rule applied to its neighbours' states. Simple local rules produce complex global behaviour — Conway's Game of Life, Wolfram's elementary CA, and a discrete cousin of reaction-diffusion.

Cellular Automata · Open in new tab ↗ · Motion begins only when you press Run.

The code

The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.

cellular-automata/index.html
const SEED = Math.floor(Math.random()*1e9);

// Conway's Game of Life. Live cells are coloured by "age" (how many
// consecutive steps they've been alive) for visual depth.
let cols, rows, cell, grid, age;

function setup() {
  randomSeed(SEED);
  const s = Math.min(windowWidth, windowHeight);
  createCanvas(s, s);
  cell = Math.max(4, Math.floor(s / 110));
  cols = Math.floor(width / cell);
  rows = Math.floor(height / cell);
  grid = new Uint8Array(cols * rows);
  age = new Uint16Array(cols * rows);
  for (let i = 0; i < grid.length; i++) grid[i] = random() < 0.32 ? 1 : 0;
  colorMode(HSB, 360, 100, 100);
  noStroke();
  frameRate(14);
}

function draw() {
  background(0, 0, 6);
  const next = new Uint8Array(cols * rows);
  for (let y = 0; y < rows; y++) {
    for (let x = 0; x < cols; x++) {
      let n = 0;
      for (let dy = -1; dy <= 1; dy++)
        for (let dx = -1; dx <= 1; dx++) {
          if (dx === 0 && dy === 0) continue;
          const nx = (x + dx + cols) % cols;
          const ny = (y + dy + rows) % rows;
          n += grid[ny * cols + nx];
        }
      const idx = y * cols + x;
      const alive = grid[idx] ? (n === 2 || n === 3) : (n === 3);
      next[idx] = alive ? 1 : 0;
      age[idx] = alive ? Math.min(255, age[idx] + 1) : 0;
      if (alive) {
        const a = age[idx];
        fill((200 + a * 2) % 360, 70, 95);
        rect(x * cell, y * cell, cell - 1, cell - 1);
      }
    }
  }
  grid = next;

  // Reseed a patch occasionally to keep it lively.
  if (frameCount % 240 === 0) {
    for (let k = 0; k < 200; k++) {
      const i = Math.floor(random(grid.length));
      grid[i] = 1;
    }
  }
}

Open the demo source ↗

How it works

Define a grid of cells, a finite set of states, a neighbourhood (e.g. the 8 surrounding cells — Moore — or the 4 orthogonal — von Neumann), and a transition rule. Then iterate in lockstep: 1. For every cell, read the current states of itself and its neighbours. 2. Look up the rule to compute that cell's next state. 3. Apply all updates simultaneously (use a second buffer so a cell's update doesn't affect its neighbours within the same step). Conway's Life uses birth/survival counts (B3/S23); 1D elementary CA map the 8 possible neighbourhoods of three cells to an 8-bit "rule number" (e.g. Rule 30, Rule 110). Despite trivial rules, CA can be chaotic or Turing-complete.

Parameters

Lineage

Precedents
John Conway
Related
Reaction-Diffusion, Wave Function Collapse, 10 PRINT, Truchet Tiles

Frequently combined with

Works using this algorithm (15)

Abstraction
hevey
Bomb
scott-draves
Calculating the Universe
troika
Dive
rafael-rozendaal
Gen 3
dca
Mental pathways
fabianospeziari-x-donnoh
mono no aware
ixnayokay
Patterns of Life
vamoss
Pre-Process
casey-reas
Rain Blooms
kazuhiro-tanimoto
Rechnender Raum
ralf-baecker
RGB Elementary Cellular Automaton
ciphrd
Rule 110
raven-kwok
Swimming Pool
paul-brown
Zoologic
ixnayokay

References

Last updated 2026-07-16