← Writing · CELLAGA

Project: CELLAGA

A fixed-scroll shooter where ship, bullets, and debris are live Game of Life cells.

  1. One Bit Short of a War
  2. One Grain Per Cell Event

One Bit Short of a War

Why classic Conway can't host a fight, and how one extra bit of state turns Life into a war.

Ship, bullets, and enemies are all live cells in one cellular automaton. Why classic Conway can’t host a fight, and how one extra bit turns Life into a war.

Life, in two clauses

Each cell alive or dead. Each tick, eight neighbors, rule B3/S23: dead cell with exactly 3 live neighbors is Born; live cell with 2 or 3 Survives; else dead.

FIG. 01

The complete rulebook

BIRTH — B3dead center, 3 neighbors→ born next tickSURVIVAL — S23alive, 2 (or 3) neighbors→ survivesDEATH — everything elseunder 2 (lonely) · over 3 (crowded)→ dead next tick
The complete rulebook. Every pattern you have ever seen in Life — gliders, guns, computers — is downstream of these three panels.

Click/drag to paint. Presets: glider (swims — Cellaga’s bullets), pulsar (period-3 oscillator — the ship), R-pentomino (methuselah, ~1,100 generations of chaos), soup (random noise → ash).

click / drag to paint · edges wrap
gen 0 · pop 0

Why classic Life can’t host a fight

Fly a glider into a pulsar: cells die, cells born, chaos. Whose cells? Did the bullet damage the ship or the ship absorb the bullet? Kill credit?

One bit — alive or dead. Identity isn’t in the rules. Two patterns touch and become the grid. No ownership → no damage attribution, no score, no “your ship.”

Ownership outside the sim in game code fakes collisions. Ownership has to live in the automaton and propagate by its rules.

Immigration: one extra bit

Immigration Game (early Life-hacking era): two colors — amber and cyan. Counting unchanged: birth needs exactly 3 live neighbors of any color, survival 2-or-3. New clause: newborn takes majority color of its three parents. Three parents → majority always exists.

FIG. 02

The whole diff

MAJORITY BIRTH — 2v13 parents: 2 amber, 1 cyan→ amber childMAJORITY BIRTH — flippedsame geometry, colors swapped→ cyan childSURVIVAL — color keepsa surviving cell never converts —only births carry the flag forward
The whole diff. Counting ignores color; only newborns consult it. Squint — ignore the colors entirely — and every panel is just classic Life.

Immigration projects onto classic Life exactly. Erase colors → identical evolution. Known oscillators, spaceships, and guns work unmodified; color is a tracer through unchanged physics.

Paint both teams or load presets: glider duel (head-on; ash has owners), pulsar under fire (Cellaga in miniature), border war (half-and-half soup).

click / drag paints the selected team · edges wrap
gen 0 · 0 v 0

What the flag buys

Damage: health is pattern integrity — Hamming distance to the pulsar’s canonical form. Conversion: contested borders flip territory via majority birth. Readability: every pixel of ash has an owner.

One impurity: before each generation, tagged cells translate rigidly with input — ship moves because you moved it, then the universe ticks. Everything else is B3/S23 + majority birth.

One Grain Per Cell Event

GPU delta pass, clz32 extraction, AudioWorklet grains — one birth/death → one grain.

Every cell birth and death becomes exactly one audio grain — panned by x, pitched by y. A lone glider is an audible object crossing stereo at four events per period; colliding soup is granular static; ship damage is a distinct grain type from the ship’s screen position.

Engine prerequisites

State: one RGBA8 texture, one texel per cell (R alive, G team, B age, A player tag). Generations: ping-pong FBOs — translate, inject, step. Ship health = pattern integrity: 48×48 ROI → 1×1 every 30 ticks, async PBO readback with fence

  • non-blocking poll, one in flight. CPU oracle gates the shader against known sequences. Grid 2048×512.

Ping-pong means prev and curr are both resident → birth/death mask is a per-texel compare. Integrity path already gets bytes off the GPU without a sync stall.

FIG. 01

The audio thread is another readback consumer

Diagram tracing one birth event from ping-pong state textures through a GPU delta pass, PBO pool, clz32 scan, and AudioWorklet grain scheduler
The audio thread is another readback consumer. One exemplar birth event traced from a texel in the current state texture to a scheduled grain; stages right of the state textures are the design path (dashed).

Delta pass

One pass after step. Each fragment reads 64 consecutive cells from both textures, packs two bitmasks into an RGBA32UI texel: births (curr && !prev) in R/G, deaths (!curr && prev) in B/A. Output 32×512 × 16 B = 256 KB/gen, 15.4 MB/s at 60 Hz vs 4 MB/frame (240 MB/s) naive full-grid — 16× reduction, exact.

Four-channel packing forced by ES 3.0: readPixels on unsigned-integer buffers only in RGBA_INTEGER/UNSIGNED_INT, so RG32UI would still read 16 B/texel. Packing four meaningful channels halves texel count instead.

Delta between consecutive post-inject states → enemy stamps register as birth bursts (spawn-in as audible crackle). Readback: three-PBO pool tagged by generation, non-blocking poll; gen N events on audio side within two frames of N stepped.

Bitmask → event list

Scan as Uint32Array; skip zero words with one compare — cost tracks activity, not grid size. Set bits via Math.clz32 → exact (x, y). Pack into Uint32: x:12 | y:10 | type:2. Type 2 (player-cell death) = death ∩ player ROI bbox.

Frames above MAX_EVENTS_PER_FRAME = 4096 reservoir-sample down. Batch to worklet as one postMessage per gen with transferable ArrayBuffer.

Grains

Precomputed Hann-windowed tables — sine ping ~8 ms (births), band-passed noise ~6 ms (deaths), ~20 ms detuned pair (player deaths) — added into the worklet output at a resampled rate.

  • x → equal-power pan (cosine/sine; power position-independent)
  • y → pitch: births quantize into three octaves of pentatonic (no semitone-adjacent pairs → no minor-second clashes under arbitrary simultaneous events); deaths map exponentially, unquantized. Scale table swappable via setScale
  • Batch gain ∝ 1/√N — uncorrelated grains sum in power; tanh soft limiter backstop (≤ −1 dBFS on 30%-density soup)
FIG. 02

One event, one grain, two axes

Diagram of a grid patch with a birth and a death mapping to stereo pan by column and pitch by row, with birth pitches quantized to a pentatonic scale
One event, one grain, two axes. A birth and a death from the same grid patch project to pan by column and pitch by row; only the birth snaps to the scale, and both onsets land at jittered offsets inside the tick.

Events arrive quantized to the sim tick. Schedule directly → impulse train at 60 Hz. Onset jittered uniformly across the following tick (~16.7 ms) — whitens the train, keeps every event inside its generation. Player-initiated sounds (firing) trigger on input, not sim confirm.

Acceptance gate

Delta masks must match CPU oracle bit-exact on gated sequences, including a glider on the wrap seam (texelFetch + mod), and a still-life field must produce all-zero masks for 100 consecutive generations. Downstream: lone glider event counts match oracle for 32 gens; pan moves monotonically L→R within one 64-cell bucket; still-life leaves master bus ≤ −60 dBFS RMS after 1 s.