# brainrot 009: living game of life Live: https://brainrot.runfridge.dev/009/ Source: https://github.com/hwhang0917/brainrot/tree/main/009 License: MIT (see LICENSE at repo root); attribution only, no warranty. ## What it is Conway's Game of Life drawn as living cells in a dish: each live cell is a soft glowing blob, and neighbouring blobs fuse into one gooey membrane, each with a drifting nucleus. Newborns grow in, the dying dissolve, and every cell breathes. Colour is age: lime when born, 5° further round the hue wheel per generation survived, up to violet (a "?" button opens a legend saying so). Drag to seed cells; the bottom bar has play/pause, step, speed (1-20 generations per second, default 5), random (28% density) and clear. A HUD shows generation and population. No sound, no URL params. ## How it was built - Rendering: pixi.js v8. One radial-gradient disc texture is drawn once on a 2D canvas; each live cell is a tinted `Sprite` of it inside a `goo` container whose filters are `BlurFilter` then a `ColorMatrixFilter` alpha threshold (GOO_GAIN 22, GOO_CUT 0.42): the classic metaball "goo" trick. Nuclei are a separate `Graphics` layer drawn on top every frame. - Simulation: `life.ts`, Game of Life on a torus; each cell stores its age in a Uint16Array (0 = dead, capped at 65535). `step` returns the born and died indices so main.ts can animate them. - Grid: 28 px cells, at least 12x12, sized from the window once at load and centred; it is not rebuilt on resize. - Animation: births ease in over 0.45 s, deaths dissolve over 0.5 s; the nucleus fades with `left ** 3` so it goes before the membrane does. - History: first commit was the whole page; then a fix so a dying cell's nucleus dissolves with its cytoplasm instead of lingering as a speck; then the "?" colour-is-age legend; then site-wide CRT and hide-HUD buttons and the move from /9/ to /009/. Vibe coded: prompted into existence with a coding agent, iterated commit by commit. ## Files - 009/index.html: page shell, meta tags, inline CSS, "?" legend (#tip) explaining the age colours, bottom bar. - 009/main.ts: pixi setup, blob texture, goo filters, cell sprite map (born/dying/phase), controls, pointer seeding, ticker; imports `hsl` from lib/color.ts, `mountCrt` from lib/crt.ts, `mountHud` from lib/hud.ts. - 009/life.ts: pure model: `Grid`, `create`, `index` (wrapping), `alive`, `set`, `randomize` (injectable rng), `population`, `step`. - 009/life.test.ts: blinker flips and block holds (with age counting), glider wraps the 8x8 torus, randomize hits the asked density. ## Extending it - Run: `npm install && npm run dev`, open http://localhost:5173/009/ . Tests: `npm test`. Typecheck+build: `npm run build`. - Knobs: all constants at the top of main.ts (CELL, BLOB_R, NUCLEUS_R, BIRTH/DEATH_SECONDS, WOBBLE, GOO_*, START_DENSITY, HUE_YOUNG/HUE_PER_AGE/HUE_SPAN). If you change the hue mapping, update the legend swatches in index.html to match. - main.ts keeps its own `cells` Map (sprite per index) in sync with `grid.age` via `spawn` and the born/died lists; any new way of changing the grid (patterns, rules) must call `spawn`/mark `dying` the same way `reseed` does, or sprites will drift from the model. - `step` replaces `g.age` with a new array each generation; do not hold onto the old reference. - The legend closes on any pointerdown outside it; lib/crt.ts and lib/hud.ts buttons stop pointerdown propagation so they never seed cells. - Conventions: keep pure simulation in its own module with a `node --test` file beside it; match the surrounding code style; Conventional Commits `type(009): message`.