What you are seeing
An elementary cellular automaton is a 1D world: a row of binary cells where each cell can only be off 0 or on 1. The canvas draws it as a 2D history: the first row is the initial seed, and every new row is a later generation. That is why a system that lives on a line can form triangles, bands, noise, or structures that seem to move.
With a single-cell seed, each rule reveals its signature very clearly. With a random seed, you can observe whether the rule tends toward order, chaos, or an intermediate regime.
Local rule
Each new cell is computed by looking at only three values from the previous generation: left, center, and right.
s(t + 1, x) = f(s(t, x - 1), s(t, x), s(t, x + 1))
f: {0,1}^3 -> {0,1}
Because there are three binary cells, there are eight possible neighborhoods:
111 110 101 100 011 010 001 000
A rule decides whether each of those neighborhoods produces 0 or 1. Those eight answers form a binary number. That is why there are exactly 2^8 = 256 elementary rules.
Reading the rule number
Rule 30 is written as 00011110 in binary. Read from 111 down to 000, it means:
111 -> 0
110 -> 0
101 -> 0
100 -> 1
011 -> 1
010 -> 1
001 -> 1
000 -> 0
It can also be read as a sum of bits:
N = Σ f(pattern_k) * 2^k, k = 0..7
Changing one bit of the rule is not a cosmetic tweak: it changes one local transition, and that difference is amplified generation after generation.
Wolfram classes
Stephen Wolfram proposed an empirical classification to describe the global behavior of these rules:
- Class I: the system converges to a uniform state. Examples: rule 0 and rule 255.
- Class II: stable or periodic patterns appear. Examples: rule 4, rule 108.
- Class III: chaotic and aperiodic behavior. Examples: rule 30, rule 45.
- Class IV: a mixture of order and chaos with localized structures that interact. Example: rule 110.
The classification is not understood from a single row; it emerges by observing the whole evolution.
Notable rules
- Rule 30: produces apparent chaos from a simple seed. Wolfram used it as a pseudo-random generator in Mathematica for years.
- Rule 90: generates the Sierpinski triangle. It can be interpreted as XOR between the left and right neighbors.
- Rule 110: is Turing-complete. Matthew Cook proved it can simulate universal computation through localized structures.
- Rule 184: models one-way traffic. Live cells behave like particles that move forward when space is available.
Boundaries, symmetry, and seeds
The Wrap mode turns the row into a ring: the left edge sees the right edge as its neighbor. Without wrap, edges are treated as dead cells. This difference can strongly affect behavior in small worlds.
Every rule has symmetry relations: reflecting left/right or complementing 0/1 produces rules that are equivalent under a different visual reading. That is why the 256 rules collapse into fewer behavioral families.
The seed matters too. A central cell is useful for seeing the clean mathematical structure; a random seed is useful for studying stability, density, and sensitivity to initial conditions.
Technical stack
The runtime precomputes the rule as an 8-value lookup table and uses two Uint8Array buffers: one for the current row and one for the next row. Each step costs O(W), where W is the row width.
index = (left << 2) | (center << 1) | right
next[x] = ruleTable[index]
The canvas does not simulate a full 2D grid. It computes only one new row per generation and keeps a visible row history to display the evolution as a texture.