Lenia, a continuous cellular automaton published by Bert Wang-Chak Chan in 2019, produces the specimen of posts tagged ai. The banner shows a few creatures called orbia swimming together, with the faded trace of their path.
From the Game of Life to the continuum
Conway’s Game of Life lives on a grid of two-state cells. At each generation, a cell counts its live neighbours among the eight around it: a dead cell is born if , a live cell survives if (the B3/S23 rule). Chan points out that this rule can be written in an additive form. Let be the state of the grid, the kernel that counts the eight neighbours and a growth function:
where clips the value to . The four cases check out: a dead cell with three neighbours goes to 1, a live one with two or three neighbours stays at 1, everything else drops to 0.
Written this way, the rule separates three things that Life fixes all at once: the set of states, the shape of the neighbourhood and the length of a step. Lenia (from the Latin lenis, “smooth”) makes all three continuous1. States become real numbers in , the neighbourhood becomes a smooth ring of radius covering hundreds of cells, and the time step becomes a fraction .
The update rule
The rule keeps the shape of Life’s:
Only the kernel and the function change.
The kernel
The potential is a weighted average of the state around each cell. The kernel depends only on the normalised distance and is zero outside the disc of radius . In its simplest form, it is a smooth bump sitting on the ring:
equals 1 in the middle of the ring () and vanishes, along with all its derivatives, at the centre and at the edge. The normalisation guarantees : a completely full neighbourhood gives . Chan also defines kernels with several concentric rings of different heights; orbia need only one.
The growth function
turns the potential into growth. It is a Gaussian rescaled to :
A cell whose neighbourhood has a density close to grows; all the others decay. sets the tolerance. is positive exactly when .
Time step and clipping
splits each unit of time into small steps. As grows, the rule tends to an integro-differential equation, , except at the bounds. Clipping to is the only nonlinearity outside ; it is what gives the creatures a saturated interior and a sharp edge.
In the blog’s engine, the update of one cell takes three lines:
const d = u - m; // u: potential K * A, m: μ
const v = a[i] + dt * (2 * exp(-d * d * inv2s2) - 1); // inv2s2 = 1 / 2σ²
b[i] = v < 0 ? 0 : v > 1 ? 1 : v;
Orbium and the bestiary
With a single-ring kernel, , , and , Chan describes a crescent shape that glides without deforming: Orbium unicaudatus, the orbium. Life’s glider is an exact pattern that repeats; the orbium is a stable state of the dynamics: perturb it and it recovers its shape.
The 2019 paper lists more than four hundred species, sorted into eighteen families following a taxonomy inspired by biology, many of them found through interactive evolution. Chan describes them as geometric, metameric (made of repeated segments), fuzzy, resilient, adaptive and rule-generic: a given species survives small changes in the parameters. Most of them move, some rotate, others oscillate in place.
The radius acts as a resolution. An orbium sampled at and then resampled at is still an orbium, just drawn with fewer cells. The engine takes advantage of this to fit into a character grid.
A narrow band of parameters
With and , a cell only grows if the density of its neighbourhood falls within . Everywhere else, the state decays by up to per step. The creatures depend on this fine tuning, and the viable zone is narrow:
- if goes down or widens, edge cells find a favourable neighbourhood too easily; the creature swells, then growth takes over the whole domain;
- if goes up or narrows, too few cells grow; the mass melts away and the creature disappears.
Chan maps these regimes in the plane: each species occupies a thin band between the region where everything explodes and the one where everything dies. So the engine does not draw these parameters at random. On its grid, orbia survive in every heading tested for and : a slanted band barely 0.0013 wide in , slightly above Chan’s point. At this resolution, a narrower kills the orbium in some directions. The seed draws , then within this band, with a small margin on each side. The sliders of the interactive specimen cover a slightly wider rectangle, and : you can watch the school die out when is narrow and high, or spread out when is wide and low.
Why under the ai tag
Nothing in the rule describes a creature. The kernel and the Gaussian are local and the same at every point; the orbium, its shape and its locomotion emerge from iterating them. In that sense Lenia is a clear example of self-organisation.
The link with machine learning is also structural. A Lenia step is a convolution, a pointwise nonlinearity and a residual connection: a convolutional network layer applied in a loop. Chan describes his multi-kernel, multi-channel version as a kind of recurrent convolutional network2. The neural cellular automata of Mordvintsev and coauthors (2020) learn the rule by gradient descent to grow a target shape and regenerate it3. Lenia, for its part, learns nothing: its species were found by search, by hand or with a genetic algorithm.
How the engine seeds and draws it
The specimen starts from an empty grid on which a school of orbia is laid down. The reference pattern, 20 × 20 values taken from Chan’s catalogue for , is resampled by bilinear interpolation, rotated and placed at regular intervals with a little noise. The orbia swim in horizontal lanes about a dozen rows tall, one way and then the other from one lane to the next; within a lane, they all head the same way to within 0.14 radian, far enough apart not to interact. Two orbia that come too close merge, explode or die. On the large full-screen frames, such as the home page’s, the lanes follow the long side of the frame (vertical on a phone) and each orbium is placed so that its whole trip stays inside the frame: the grid is a torus, and a swimmer leaving one side would come back cut in two on the other.
The simulation then runs 90 steps with , that is nine units of time. For a still image to show motion, each cell also keeps a trace: the maximum of its state and its previous trace multiplied by a forgetting factor close to 1. Cell by cell, the final image keeps the larger of the current state and that trace, like a long-exposure photograph, then goes through a character ramp. The state is first taken to its square root, which makes the creatures’ faint halo readable; the trace ignores values below 0.12 (the halo and old wakes) and never exceeds 45% of the ink, so it stays in the lighter tones.
The specimen’s label carries these three numbers; this post’s banner reads specimen 0xd12a · lenia · orbium μ=0.147 σ=0.0167 R=6.9. Together with the seed, which also sets the swimming direction and the layout of the school, and the modulations from the other tags, they are enough to reproduce the image.
Notes
-
In 2011 Stephan Rafler proposed a continuous generalisation of Life, SmoothLife, with a disc-and-ring neighbourhood and smoothed transitions. Lenia differs from it mainly in its growth function and its explicit time step. ↩
-
Bert Wang-Chak Chan, “Lenia and Expanded Universe”, ALIFE 2020. ↩
-
Mordvintsev and coauthors, “Growing Neural Cellular Automata”, Distill, 2020. ↩