# How Can Tiny Rules Build Complex Worlds? # Book: Cellular Automata From First Principles # Chapter URL: https://programmer.ie/books/cellular-automata-from-first-principles/01-chapter/ # Prose fingerprint (sha256, normalized): 451d1276d9965eba477005cb563e2e6ea69882493bb0be7f596786454ec8e69a # Snapshot generated at build time by Hugo. This is the complete rendered prose # of the chapter; it is not a transcript of the source file. A cellular automaton begins with almost nothing. You need: a collection of cells, a state for each cell, a neighborhood, and a rule that tells each cell what to become next. That is enough. There is no central controller. There is no object that knows what the final pattern should look like. There is only local state changing through time. And yet some local rules produce stripes, fronts, oscillators, moving structures, traffic waves, cave systems, self-repairing patterns, and systems rich enough to perform computation. That last sentence needs a qualification the whole book will respect: not every simple rule produces interesting behavior. Most produce something dull — a uniform blank, a frozen pattern, a short cycle. The claim is narrower and more surprising: some very simple local rules produce behavior that is difficult to predict from the rule alone, and a few can support signals, collisions, and computation. That is what makes cellular automata such a useful subject for programmers: they force us to study a deep engineering question in an unusually clean form. How much global behavior can emerge from repeated local decisions? This book is going to answer that question by building the systems ourselves. The smallest useful model Imagine a row of cells. Each cell is either off or on: 0 0 0 1 0 0 0 At the next step every cell examines itself and its immediate neighbors: left | centre | right The three bits form one of eight possible neighborhoods: 111 110 101 100 011 010 001 000 A rule assigns a new bit to each neighborhood. That is the entire mechanism behind an elementary cellular automaton. We can represent the global update as: state_t | local neighborhoods | shared update rule | state_t+1 The important phrase is shared update rule. Every cell follows the same law: flowchart LR R[One shared rule] --> A[cell in state 0] R --> B[cell in state 1] R --> C[cell in state 0] R --> D[...] A --> A2[next state] B --> B2[next state] C --> C2[next state] Complexity does not come from giving every cell different code. It comes from interaction between identical local rules and different local states. One convention matters from the start: unless a chapter says otherwise, every cell updates at the same time, using the states from the previous step. That synchronous update is the classical assumption, and it is what makes the evolution reproducible. Later chapters will deliberately break it — with stochastic and asynchronous updates — to see what changes. A cellular automaton has four parts We will keep returning to four concepts throughout the book. They match the standard definition used in the literature: a discrete lattice of cells, a finite set of states, strictly local interaction, and a discrete update applied in parallel. 1. Space The cells need somewhere to live: a lattice. That space might be: 1D line 2D square grid hexagonal grid 3D lattice graph continuous field Classical cellular automata usually use a regular discrete grid, but later we will relax almost every assumption. 2. State A cell might contain one bit: 0 or 1 Or several discrete states: empty burning burned Or a vector of continuous values: [r, g, b, alive, hidden_1, hidden_2, ...] The last form will become important when we reach neural cellular automata. 3. Neighborhood A cell cannot normally inspect the whole world. It sees only nearby cells. For a 2D grid two common neighborhoods are: Von Neumann x x o x x and: Moore x x x x o x x x x That locality is the constraint that makes the subject interesting. There are no actions at a distance: everything a cell learns about the world arrives through its neighbors, one step at a time. 4. Update rule The rule maps local information to a new state: new_state = rule(neighborhood) For a one-dimensional binary rule with one neighbor on each side, the update for cell i is conventionally written: sigma_i(t+1) = phi(sigma_{i-1}(t), sigma_i(t), sigma_{i+1}(t)) Here sigma_i(t) is the state of cell i at time t and phi is the transition function — the lookup table that assigns each of the eight neighborhoods an output bit. We will make this concrete in the next two chapters. Classical rules are handwritten. Later we will make them stochastic, continuous and eventually learned. Two further choices complete a runnable model: the schedule (when cells update) and the boundary (what happens at the edge of the lattice). Chapter 2 makes both explicit. The four parts at a glance — the reference this book keeps returning to: Part Specifies Example in this book Space where cells live 1D row, 2D grid, continuous field State what each cell holds one bit, empty/burning/burned, hidden vectors Neighborhood what each cell can see 3-cell row, Moore 8-cell, radial kernel Update rule how local state becomes next state Rule 22 table, B3/S23, learned network Where this idea came from The four-part structure above was not obvious from the start. It emerged over several decades. In the late 1940s John von Neumann, following a suggestion by Stanislaw Ulam, adopted a discrete lattice of cells to study self-reproduction: could a machine embedded in such a grid construct a copy of itself? His construction used 29 states and complicated dynamics, and it was also the first discrete parallel model formally shown capable of universal computation. The details belong to history, but the move matters: biology looked continuous, and von Neumann chose to model its logic discretely and locally. In 1970 John Conway’s Game of Life showed how little was needed for striking two-dimensional behavior: two states and a tiny birth/survival rule on the eight-cell Moore neighborhood. In the 1980s Stephen Wolfram studied the one-dimensional rules systematically — all 256 of them — and gave the field its first qualitative taxonomy of behavior, from uniform to periodic to chaotic to locally complex. Each of those steps narrowed the question. Von Neumann asked what a grid of simple parts could construct. Conway showed what it could grow. Wolfram asked what the whole space of tiny rules typically does. This book follows the same narrowing: build a rule, watch it run, measure what happened, and only then generalize. Why programmers should care Cellular automata sit at the intersection of several useful ideas. Simulation Local rules can model processes such as: spreading fire, traffic flow, diffusion, infection, erosion, crowd-like movement. The goal is not always physical accuracy. Often the value comes from understanding what behavior a simple interaction model can generate. Procedural generation Games and generative systems use cellular-style rules to create: caves, islands, terrain masks, textures, rooms and corridors, organic-looking boundaries. A few smoothing rules can turn random noise into surprisingly plausible structure. Emergence Cellular automata make emergence visible. Instead of saying that a system is “complex,” we can watch structure appear generation by generation — and check whether our low-level rule really explains the high-level pattern, or whether we are just giving a suggestive name to something we do not yet understand. The book treats emergence as an observation to be demonstrated, not a principle that explains itself. Computation Some automata can support persistent signals and interactions between those signals. This means the grid itself can become a computational substrate — for a few specific rules, in a precise sense we will define when we reach them. The ability to compute, Turing completeness, and practical programmability are different claims, and we will keep them separate. Artificial life Later systems such as continuous cellular automata and neural cellular automata let us explore growth, persistence, regeneration and self-organization. That gives us a path from: bit rule -> pattern -> moving structure -> computation -> self-organization -> learned local behavior Build before theory We are going to use Python because it lets us move rapidly between ideas and experiments. Our first implementation will deliberately be small. import numpy as np state = np.zeros(41, dtype=np.uint8) state[len(state) // 2] = 1 print(state) That creates a one-dimensional world with one live cell. The next chapter will give that world a rule. We will not begin by building a framework. We will not begin with inheritance hierarchies or plugin systems. We will begin with the smallest possible transition function and earn the abstractions later. That is important because cellular automata are fundamentally about the transition: current local state -> next local state If we understand that operation clearly, everything else becomes composition. The progression of the book The book moves through several layers, from discrete rules to measurement to continuous and learned systems, then to the engineering needed to run honest experiments. Foundations one-dimensional rules rule encoding Rule 30, Rule 110 Conway's Life, patterns as data Richer worlds multi-state and Life-like rules stochastic systems forest fires, traffic, diffusion reaction-diffusion, ecosystems caves, terrain, textures Measurement density, activity, entropy and search periodicity, attractors, sensitivity rule classification exhaustive and evolutionary search automata as computation Continuous kernels, growth functions artificial life Lenia, robustness, Flow-Lenia Learned rules differentiable automata neural cellular automata growth, persistence, regeneration pathfinding and hidden state Engineering profiling, vectorization, GPU, FFT reusable engines, reproducibility sweeps, figures, laboratory Capstone build a candidate, measure it, challenge it, and reject it if the evidence fails The destination is advanced. The starting point is one bit. One idea to keep A cellular automaton is not interesting because each cell is clever. It is interesting because each cell is not clever. The power comes from repeated interaction. That gives us the central idea for the entire book: Some very simple local rules produce global behavior that is difficult to predict from the rule alone. In the next chapter we will see that for ourselves by implementing an elementary cellular automaton from scratch. Research Berto, F. & Tagliabue, J. — Cellular Automata (Stanford Encyclopedia of Philosophy). The best single entry point for the chapter’s foundations: the four-part definition (lattice, states, locality, synchronous update), the von Neumann–Ulam origin, Garden-of-Eden and Hedlund results, Life, Wolfram’s classification, and the philosophical uses and abuses of emergence. Use it to check what is established versus interpreted. https://plato.stanford.edu/entries/cellular-automata/ Wolfram, S. — Statistical Mechanics of Cellular Automata (Reviews of Modern Physics 55, 1983). The original systematic paper on one-dimensional rules: enumerates the rule space, introduces the qualitative behavioral classes, and treats automata as objects of statistical study rather than curiosities. Grounds the book’s build-then-measure approach. https://doi.org/10.1103/RevModPhys.55.601 Weisstein, E. W. — Elementary Cellular Automaton (MathWorld). Compact reference for the definition the next two chapters depend on: two states, nearest-neighbor dependence, 256 rules indexed by an 8-bit number, with Rule 30/90/110 as worked examples. Useful for verifying the rule-table encoding before implementing it. https://mathworld.wolfram.com/ElementaryCellularAutomaton.html