Elementary Cellular Automata, Explained

After reading this you can take any rule number from 0 to 255, work out the next row by hand, and know why rule 30 looks random while rule 90 draws a perfect Sierpiński triangle.

What an elementary cellular automaton is

Picture a single row of cells. Each cell is either black (1) or white (0). To make the next row, you look at every cell together with its left and right neighbours, read off that group of three, and decide the new colour of the middle cell. Apply the same decision to every cell, and you have produced row two from row one. Repeat, and the rows stack downward into a triangle of history.

The decision rule is the whole model. A group of three cells has 2^3 = 8 possible patterns, from 111 down to 000. For each of those eight patterns you choose an output bit, 0 or 1. Eight bits gives one byte, so there are 2^8 = 256 distinct rules. That is why you enter a number between 0 and 255.

Here is the hook. Start with a single black cell in the middle of a white row, run rule 30 for a few hundred steps, and the left half looks structured while the right half looks like static. That static is good enough that Mathematica once used the centre column of rule 30 as a random number source. All of it comes from one black cell and a fixed 8-bit table.

When to reach for this model, and when not to

Elementary cellular automata are the cleanest place to see complex behaviour grow from a trivial rule. Use them to build intuition about determinism, sensitivity to initial conditions, and self-similar patterns. They are also a fair sandbox for the question "how simple can a system be and still compute anything?" Rule 110 answers that: it is Turing complete.

Do not use them as a physical model of anything specific without care. A one-dimensional row updating in lockstep is a toy. It will not predict traffic, forest fires, or crystal growth just because the pictures resemble those things. The value is conceptual: you learn what kinds of behaviour a local rule can and cannot produce. If you want a two-dimensional automaton with moving structures, look at Conway’s Game of Life instead.

The update rule, written down

Let s_i^t be the state (0 or 1) of cell i at row t. The new state depends only on three cells above it:

s_i^{t+1} = R\left( s_{i-1}^t,\ s_i^t,\ s_{i+1}^t \right)

Here R is the rule: a function from the three input bits to one output bit. The three inputs form a binary number from 0 to 7, and that number picks which bit of the rule byte to read. Writing the rule number as N, the output for neighbourhood value n is bit n of N:

R(n) = \left\lfloor N / 2^n \right\rfloor \bmod 2

The neighbourhood value is just the three cells read as a binary number: n = 4 s_{i-1} + 2 s_i + s_{i+1}. So neighbourhood 101 has value n = 5, and its output is bit 5 of the rule number. That is the entire mechanism. Everything else is bookkeeping about edges and width.

The convention orders neighbourhoods from 111 (value 7) down to 000 (value 0), matching the bits of the byte from most significant to least. Rule 30 in binary is 00011110, so patterns 100, 011, 010, 001 give a black cell and the rest give white.

Working out rule 30 by hand

The demo uses the field defaults: rule 30, a single black cell start, on a modest width. Reproduce the first few rows yourself.

Rule 30 from one black cell

First decode the rule. 30 = 16 + 8 + 4 + 2, so bits 1, 2, 3 and 4 are set. The lookup table is:

Rule 30 output for each neighbourhood
NeighbourhoodValue nBit of 30Output
111700
110600
101500
100411
011311
010211
001111
000000
  1. Row 0 is a single black cell. Write it as ...0001000... with white on both sides.
  2. Look at the black cell's left neighbour. Its neighbourhood is 001, value 1, output 1. So the cell just left of centre turns black.
  3. The centre cell sees 010, value 2, output 1. It stays black.
  4. The right neighbour sees 100, value 4, output 1. It turns black.
  5. Everything further out sees 000, value 0, output 0, and stays white. Row 1 is ...0011100..., three cells wide.
  6. Repeat for row 2. The left edge of the block sees 001 (black), the interior triple 111 gives 0, and the pattern splits. Row 2 is ...0110010....

By row 2 the symmetry is already broken toward one side, which is the seed of the mixed order-and-chaos look. Keep going and the right side keeps producing fresh, hard-to-predict cells while the left side settles into stripes.

Rule 30 turns the centre cell black exactly for neighbourhood values 1 through 4. Reading the bars right to left spells the byte 00011110 = 30.

Reading the three preset rules

Three rules on the tool cover the range of behaviour Wolfram classified.

Rule 90
Output is the left neighbour XOR the right neighbour, ignoring the centre. Its byte is 01011010. From a single cell it draws the Sierpiński triangle exactly: at row t the black cells sit where the binomial coefficient \binom{t}{k} is odd. This is self-similar and completely predictable.
Rule 30
Byte 00011110. Chaotic: small changes in the start row spread and amplify, and the centre column passes standard randomness tests. Order on one side, noise on the other.
Rule 110
Byte 01101110. Localized structures drift across a patterned background and interact when they meet, like particles colliding. In 2004 Matthew Cook proved rule 110 can emulate any computation, so it is Turing complete.

Rule 90 gives a clean fractal, rule 30 gives noise on the right, and rule 110 gives drifting structures. Set the rule to 90 and you get the Sierpiński triangle; nudge it to 89 or 91 and the pattern collapses to something dull or chaotic, showing how sensitive the picture is to the exact byte.

What the triangle tells you and what it does not

The most useful reading is the density of black cells per row. For rule 90 from a single cell, row t has exactly 2^{b(t)} black cells, where b(t) is the number of 1s in the binary form of t. Check it: row 3 is binary 11, so b = 2 and there are 2^2 = 4 black cells. Row 4 is binary 100, so b = 1 and only 2 black cells. The count drops from 4 to 2 as you cross from row 3 to row 4, which is why the fractal has those sharp empty triangles.

For rule 30 there is no such formula. The black fraction hovers near 0.5 across most rows once the pattern fills out, which is exactly what you want from a randomness source. But "looks random" is not "is random" in any deep sense: the image is fully determined by the first row. Given the rule and row 0, every later cell is fixed. There is no probability anywhere in the model.

The count equals 2 raised to the number of 1-bits in t. It spikes to a power of two at rows 1, 3, 7, 15, 31 and drops back to 2 at rows 2, 4, 8, 16 where t is a pure power of two.

Common mistakes

Three errors account for most confusion.

Do not assume higher rule numbers mean more complex pictures. Rule 255 fills everything black and rule 0 stays white forever, while the interesting rules 30, 90 and 110 sit in the middle. The number is an 8-bit lookup table, not a difficulty setting.

The second mistake is ignoring the edges. A finite width has to decide what a cell at the far left sees to its left. This tool treats off-grid cells as white (0). Some references wrap the row into a ring instead. The two choices give different pictures near the boundary, so a mismatch with a textbook is often just an edge convention, not a bug.

The third mistake is expecting rule 30 to be truly unpredictable. It is deterministic. If you save row 0 and the rule, you can regenerate the exact image on any machine. Reproducibility is a feature here, not a contradiction of the randomness claim.

Related tools on this site

If the one-dimensional row feels limiting, Conway’s Game of Life extends the same local-rule idea to a two-dimensional grid where structures move and collide. For self-similarity of the kind rule 90 shows, but generated from complex arithmetic instead of a bit table, the Mandelbrot Explorer lets you zoom into endless fractal detail. And if you want to see a very different way of building a shape from simple parts, Fourier Epicycles reconstructs a drawing from a sum of rotating circles.

Frequently asked questions

Why are there exactly 256 rules?

Each cell's fate depends on three cells, giving 2^3 = 8 input patterns. You assign one output bit to each pattern, so a rule is 8 bits, and 2^8 = 256.

How does rule 90 draw the Sierpiński triangle?

Rule 90 sets a cell to the XOR of its two neighbours. Starting from a single cell, cell k in row t is black exactly when the binomial coefficient \binom{t}{k} is odd. The odd-binomial pattern is the Sierpiński triangle, a result tied to Lucas's theorem on binomials mod 2.

Is rule 30 actually a good random number generator?

The centre column passes many statistical randomness tests, and Mathematica used it. It is not cryptographically secure, because knowing the rule and seed lets anyone reproduce the sequence exactly.

What does it mean that rule 110 is Turing complete?

You can arrange its drifting structures to carry and combine information the way logic gates do, enough to simulate any computer program given a long enough row and enough steps. It is one of the simplest known systems with this property.

Why does my picture differ from a reference image?

Usually the edge handling differs. This tool pads off-grid cells with white; a wrap-around (toroidal) row produces different cells near the left and right borders. The interior of the triangle should still match.