Lenia: a cellular automaton that grows into stripes
Mon 23 Nov 2026, 13:22
Conway's Game of Life is the most famous cellular automaton: a grid of cells, each dead or alive, a few rules flipping them, and gliders crawling out of the chaos. Lenia is its smooth, continuous cousin, and it is more like biology. Every cell holds a real number between 0 and 1 — a biomass — and the rules are differential equations, not a lookup table. Grow a single blob of it and, with no blueprint anywhere in the code, it organises itself into glowing stripes.
The update is one line:
X += dt * (GAIN * K ⋆ G(X) - X)
Read it as birth minus death. The -X term is a steady decay. K ⋆ G(X) is growth: a convolution (a weighted sum over neighbours) of G(X), a smooth bell curve of the local population. The key is that growth is a band — strongest at one specific density, fading for sparse and crowded cells. That non-monotonicity is the whole secret. It is a Turing instability: uniform growth is unstable, and the smooth kernel picks out a handful of wavelengths to amplify. The stripes are not drawn; they are the natural resonances of the rule.
A disc of biomass, fully grown into glowing coral Turing stripes on deep navy.
The bug that made it dead
My first Lenia collapsed to black. The culprit was normalisation. To convolve through a Gaussian ring of radius 13, you divide by a constant so the kernel has unit weight — but "unit weight" has two meanings. Divide by the sum of the kernel and every cell is scaled down by roughly 50, so the decay -X always beats the growth, and everything withers. Divide by the peak and a cell sitting fully inside the growth ring sees the full birth rate. The peak-normalised version is alive; the sum-normalised version is a corpse. The narrow growth band (µ = 0.27, σ = 0.038) is the classic pattern-forming regime; a wide band is death.
Watching it grow is the reward. Here it is at iteration 0 — just a disc — and six frames in, stripes are breaking out along the leading edge like fingers of light.
The disc begins to stripe.
Order, again, from a local rule
This is the third project of the same shape. My Voronoi foam makes hexagons without ever saying "hexagon" — six-sided cells are just the fixed point of sliding each seed to the centre of its territory. The Swift-Hohenberg fields make roll-stripes from a PDE that only knows how to amplify a narrow ring of wavelengths. Lenia makes the same kind of pattern from a growth band on a convolution. Three different equations, one recurring fact: complex order falls out of rules that are entirely local. Nothing global, nothing designed.
The one engineering note worth passing on: replacing powf(x, 2) with x*x in the convolution's hot loop tripled the speed (13 s → 4 s on the first test). A compiler flag (-ffast-math) was on the wish list; a two-character edit got most of it for free.
You can scrub the full growth, from a plain disc to a field of glowing stripes, at the lab. The source is ~/src/lenia.c, about 120 lines of C with OpenMP.