complexification_net · cyclicCellularAutomaton
Cyclic Cellular Automaton
A Greenberg-Hastings / Rock-Paper-Scissors style cyclic cellular automaton on a 2D torus. Each cell holds a state in 0..N-1; a cell advances to state (s+1) mod N when at least T of its 4-neighbors already hold that next state. Starting from a low-density random seed the system self-organizes into expanding spiral waves, target patterns, and glider-like defects whose lifetime and texture depend on N and T. This kind of CA was popularized in generative art by Tarbell's contemporaneous CATwist / CAWorm experiments and by Fischner's 'Cyclic CA' applet, and produces visuals reminiscent of Belousov-Zhabotinsky reaction fronts and lichen colonies.
Original: https://web.archive.org/web/20041230042637/http://levitated.net/daily/levCAWorm.html
▶ Try the live demo (JS port) ▶ Run reference.py via Pyodide 10 formulas have instant JS ports. The Pyodide path runs the actual Python in your browser — first load is ~6 MB, then instant.
Math essence
Cyclic CA on a periodic N×N grid with K states, 8-neighborhood: each tick, cell (i,j) counts neighbors whose state equals (s_{i,j}-1) mod K; if that count >= threshold, the cell takes that prev state (the wave catches up from behind). With the right (K, threshold) the system develops persistent spirals and target patterns from a uniform random seed.
Parameters
| Name | Type | Default | Range | Description |
|---|---|---|---|---|
dim | int | 400 | 100–800 | Square grid side length |
n_states | int | 8 | 4–32 | Number of distinct states in the cycle |
threshold | int | 2 | 1–4 | Required neighbor count to advance |
palette | str | fire | null–null | Palette name (fire / lichen / ember) |
seed | int | null | 0–999999 | RNG seed |
Reference
First 60 lines of reference.py. Full source:
library_external/complexification_net/cyclicCellularAutomaton/reference.py
from __future__ import annotations
from typing import ClassVar
import imageio.v2 as imageio
import numpy as np
class CyclicCellularAutomaton:
family: ClassVar[str] = "complexification_net"
sketch: ClassVar[str] = "cyclicCellularAutomaton"
_PALETTES: ClassVar[dict[str, np.ndarray]] = {
"fire": np.array(
[
[10, 0, 30],
[50, 0, 60],
[110, 0, 60],
[180, 30, 40],
[230, 80, 20],
[255, 150, 30],
[255, 220, 80],
[255, 255, 200],
[240, 240, 240],
[200, 200, 220],
[150, 150, 200],
[100, 100, 180],
[50, 50, 150],
[20, 20, 110],
[5, 5, 70],
[0, 0, 40],
],
dtype=np.uint8,
),
"lichen": np.array(
[
[30, 20, 10],
[60, 40, 15],
[100, 70, 25],
[140, 100, 40],
[180, 140, 70],
[200, 170, 110],
[220, 200, 150],
[230, 220, 190],
[200, 210, 180],
[160, 190, 160],
[110, 160, 130],
[60, 120, 100],
[30, 80, 70],
[15, 50, 50],
[10, 30, 30],
[5, 15, 15],
],
dtype=np.uint8,
),
"ember": np.array(
[
[0, 0, 0],
[30, 5, 5],
[80, 15, 5], Try running it locally
The reference implementation is self-contained Python with numpy. Install the package and run:
python library_external/complexification_net/cyclicCellularAutomaton/reference.py Need help? See Learn for the standard environment setup, or Playground for an in-browser sketchbook.
More from complexification.net
Boundaries
complexification_net · boundaries
Boundaries traces gradient-magnitude contours on a fractal Brownian motion noise substrate.
Cellular Automata Worm
complexification_net · cellularAutomataWorm
The CA Worm is an expanding construction of a one-dimensional cellular automaton.
Diffusion Limited Aggregation
complexification_net · diffusionLimitedAggregation
DLA is a simulated growth process: a sticky seed sits in a 2D field, wandering particles spawn along an outer circle, take unit-length random-walk steps, and stick to the cluster whenever they touch it.
Fibers (curling brush)
complexification_net · fibers
A field of curling fibers grown from random seeds scattered across the canvas.
Main Vein
complexification_net · mainVein
A single, meandering recursive vein grows from the center of a dark substrate.
Reaction Diffusion (Gray-Scott)
complexification_net · reactionDiffusion
Gray-Scott reaction-diffusion on a torus: two virtual chemicals U (substrate) and V (catalyst) react and diffuse on a 2D grid.