Game of Life — live coded
Inspired by Bret Victor's Inventing on Principle (2012) · see also worrydream.com.
Conway's Life with every rule in the editor. Edit the
BIRTH / SURVIVE sets to invent new automata
(Conway = B3/S23, HighLife = B36/S23, Day&Night = B3678/S34678,
Seeds = B2/S). Toggle WRAP? for a torus, swap
NEIGHBORHOOD between Moore and von Neumann, or rewrite
cell-color for a fresh palette. State is preserved across
every edit — click cells to toggle them while it runs.
Click toggle a cell · Drag paint cells alive · hold Alt/Ctrl + drag any number in the source for a live scrubber
How it works
- The grid lives in a
Uint8Arrayon the JS side, so re-evaluating the source never touches it. JS owns state, cljrs owns rules. - Every frame, JS sends a flat
[w h wrap? n0 n1 ...]packet to(next-grid ...)viarepl.call_ints; cljrs returns the next generation as a flat vector. One Clojure call per frame, no per-cell crossings. BIRTH/SURVIVEare sets — change them and the next frame uses the new rule. The grid keeps evolving.cell-coloris a pure function of(alive? neighbors age)returning a packed0xRRGGBBint. JS pulls the palette viacall_intstoo.