esolang
Learn · Ideas12 languages show it

Cellular automata

A grid of cells, one tiny rule, applied everywhere at once. No program, and yet things move, copy themselves and compute.

●○○ easy · where to see it

The idea

A cellular automaton (CA) is a row or grid of cells. Each cell is in one of a few states. At every tick, all cells update at the same time, and each one looks only at its neighbours. The rule is the same everywhere.

Read the story

There is no instruction pointer and no program in the usual sense. The "program" is the starting pattern, and the rule decides everything after it.

John von Neumann, working with Stanislaw Ulam in the 1940s, used a CA to answer whether a machine can build a copy of itself. He designed a 29-state automaton with a self-reproducing pattern; it was published after his death, in 1966. John Conway's Game of Life (1970) made CAs famous, and Stephen Wolfram's study of one-dimensional rules in the 1980s gave them a number system.

How it works

The simplest kind is a row of cells, each 0 or 1.

An elementary CA

The simplest kind is a row of cells, each 0 or 1. A cell's next state depends on itself and its two neighbours, 3 bits, so 8 cases. Write the 8 answers as a binary number, and you have the rule's name. This is Rule 110.

neighbourhood   111  110  101  100  011  010  001  000
new cell         0    1    1    0    1    1    1    0      = 01101110 in binary = 110

Start with one live cell at the right and run it (# live, . dead) for 12 rows.

..............................#
.............................##
............................###
...........................##.#
..........................#####
.........................##...#
........................###..##
.......................##.#.###
......................#######.#
.....................##.....###
....................###....##.#
...................##.#...#####

Check row 2 → row 3 by hand. Number the last three cells 28, 29, 30; in row 2 they are .##.

  • Cell 28 sees ..# (cells 27–29), case 001 → 1.
  • Cell 29 sees .##, case 011 → 1.
  • Cell 30 sees ##. (the row wraps; the far left is dead), case 110 → 1.

So .## becomes ###, as printed. The pattern grows to the left and fills with triangles that collide in irregular ways.

Wolfram conjectured in 1985 that Rule 110 is universal. Matthew Cook proved it, published in 2004, by showing that moving patterns ("gliders") in Rule 110 can simulate a cyclic tag system.

Wolfram's four classes

Run many rules and most fall into one of four kinds.

  1. die out or settle to a uniform state;
  2. settle into stable or repeating blobs;
  3. look random forever;
  4. complex, with long-lived structures that move and interact. Rule 110 and Life are here.

Seen in

  • Game of Life. 2D, two states, birth on 3 neighbours, survival on 2 or 3. Gliders, guns, and a proof that it is universal.
  • Rule 110. The smallest kind of CA, proven universal.
  • Langton's ant. One moving cell that turns by colour; after a long chaotic phase it builds a repeating "highway".
  • Langton's loops. Christopher Langton's 1984 self-reproducing loop, far smaller than von Neumann's machine.
  • Wireworld. Four states that model electrons in wires; people have built working computers in it.

Try this

  1. Compute the next row of ..#.. under Rule 110 by hand (treat the edges as dead).
  2. Run Rule 30 by hand from one live cell for eight rows. Which class does it look like?
  3. Hard: in the Game of Life, draw the glider and run it four ticks by hand. Where does it end up?

Further

Where to see it