# brainrot 015: outbreak Live: https://brainrot.runfridge.dev/015/ Source: https://github.com/hwhang0917/brainrot/tree/main/015 License: MIT (see LICENSE at repo root); attribution only, no warranty. ## What it is A seeded 480×270 pixel city where up to ten thousand people (about 8,700 on seed 1: one family a room, and that is the housing) live through a day and night: work, college, shops and farms by day, home at night. A setup dialog picks the population, police (POLICE 60), medics (MEDICS 30) and firefighters (FIREFIGHTERS 20) first, then the city is built and a quiet day starts. The bar counts the alive, the infected, the zombies, the dead, the police, the medics, the prison guards, the soldiers, the firefighters and the open calls (fire alarms among them). Controls: - Tools: the hand (key 1) drags the view and clicking someone opens their card: the name and handle, then rows (`facts` in people.ts) for age and sex, job, coins, belly with the days of food left, fear, a bite, a weapon, a record and the household (alone, a family of so many, or the care home), with a bar under the coins (full at COINS_FULL 60), the belly and the fear; then the family, a line each (a dot in their colour, first name, age, job, dead if they are) which leads to that person when clicked; then the status sentence; the view follows them; right click lets go. The bullseye button beside the name zooms in on them and follows again after the view was dragged away. The card is refreshed in place (`write` and the node-keeping `showFacts`/`showKin`): only text that changed is written, so a selection made on the card survives the refresh. The rows are rebuilt when their shape changes (the labels, and which have a bar: `cardFacts.dataset.shape`); the labels alone once left a grown-up's coins bar to be written into a row built for a child, which threw inside the frame loop and froze the game (Zen, clicking an adult family member from a child's card). The family list compares its swatches from `dataset.sw`, not read back from the style (which comes back as rgb() and never matched, so the list was rebuilt ten times a second under the pointer and a real click could miss). Clicking the armory's rack, a shop's counter or shelves, or a fridge opens a card with its stock (weapons left, meals on the shelves, meals in the fridge), kept up to date. The legend names their colours: brass for the rack, green for shop stock, light blue for a fridge. The zombie (key 2) places a zombie where you click. The fire (key 3) lights the cell clicked, or the nearest with fuel in the ring round it, so a click on a wall or a doorstep still lights the house; a click on the street says there is nothing to burn. With either tool the mouse held down and moved places one on every cell crossed, the cells between moves filled in (`strokeTo`, Bresenham), as a line is drawn in a paint program; a finger does the same once it moves (`pointermove` turns the touch drag into a stroke), a tap places one, and nothing is placed till the finger moves or lifts, so the first finger of a pinch places nothing (a second finger ends the stroke). - Zoom: wheel, buttons, pinch or double-tap, up to 16×. Middle-drag always pans. - On a phone the map is the whole screen and the header, news, feed and bar lie over it; the bar is one row of icon buttons (the long labels are `.pc`, hidden, and `.ph` the phone's short ones, such as Reset's ↺; the tools keep their key numbers) with the counts in two rows of five upright. Held upright (`UPRIGHT_QUERY`) the map opens zoomed to fill the screen's height, centred, instead of a letterboxed strip; a double tap still goes out to the whole map. The ▾ tab folds the bar away (upright it takes the feed and the news with it, via `body:has(.bar.folded)`), and folded sits lifted clear of the screen's edge and the home bar's safe area, since at the very bottom a phone's home bar or gesture edge can take the tap (reported as the controls never coming back; headless Chrome could not reproduce it); sideways the feed is a drawer behind the 💬 tab. The danger stars and the card sit under the news strip, not on it. - Speed: a menu with pause, ½× to 8×; + and − step through it. - DNA: a 🧬 button in the bar opens a dialog (`#dna`) that pauses the run while open and puts it back at its speed on close (Done, Esc, the backdrop), with two checkboxes that mutate the virus, on or off at any time, for every zombie at once. Anger: every zombie runs (a person's pace instead of half of it) and a bite turns the bitten on the spot. Swarm: one mind; zombies with nobody in sight head where the swarm is headed, after the last person any of them saw, else to a roam picked near the swarm's middle, so they gather and move as one horde. A swarm zombie past SWARM_HUNGER (half its clock without a bite) leaves the horde and searches on its own, so a swarm that finds nobody spreads out thin; whoever finds someone calls the rest. - Reset goes back to the setup. What runs on its own: - People pass through each other: a cell holds a crowd, so no queue seals a doorway. A zombie keeps its cell to itself, and an officer holding a line is a wall to people. An ordinary person (unarmed, no crook, not fleeing) keeps off a cell with a human body on it (`shuns`: a dead zombie is a stain people step over, and a body in a doorway never seals a house) and walks round it as round a zombie; the rifle on a body is taken from the cell beside it as well as from on it. - Civilians who see a zombie flee indoors and shut doors. - Everyone has their own fright (`s.scare`, 0..SCARE_MAX, the card's fear row: calm, uneasy, shaken, frightened, terrified). A zombie in sight or a bite fills it; a crime seen within WITNESS_R cells adds to it (SCARE_LOOTING for a shop looted or the armory raided, SCARE_BURGLED for a burglary, and for the household burgled, SCARE_SHOOTING for gunfire from a resident's rifle), and whoever it tips past SCARE_HOME posts about it (EV.Witness) and stays home till it fades (SCARE_FADE a poll; a full fright in most of a day). Fright works like public fear for the one person: the worse of the two sends them home early and keeps them off the shops. - The old (OLD_AGE) have heart attacks (HEART_P a poll): they go down where they stand (S.Down, EV.Collapse) and the hospital is called (`s.downs`); a medic on standby takes the nearest call, a medic in sight of them comes as to the bitten, and at their side brings them round with REVIVE_P (EV.Revived) or they die (CAUSE.Heart, `s.hearts`, a headline). Nobody comes within DOWN_TICKS: they die where they fell. - Zombies shamble at half a person's pace whatever they are doing (only the runner strain runs), so they catch the cornered, the old and the bitten; they bite, pound doors and wear walls through. A zombie drops a day after its last bite (ZOMBIE_FOOD), so one shut in an empty home is gone by the next morning. Unmutated, three zombies take about two and a half days to empty the city, the last of them starving as the living run out; the anger strain does it in eight hours; the swarm turns most of the city in a day, then starves out and leaves a few hundred survivors at home. - Under a strain the zombies are drawn in that strain's red: a hot rose red for runner, a deep pink for instant, a deep crimson for swarm, against the plain zombie's pure red (runner before instant before swarm when several are on); the legend lists both. - Police answer calls, shoot, hold cordons and lines; medics carry the bitten to hospital wards and clear bodies. The wards: a patient is strapped to the bed, and their chance of recovery is fixed on arrival from how much of the clock is left (`cureChance`: CURE_BEST 0.6 with the whole clock, down to CURE_FLOOR 0.02 at the last minute; the clock keeps running on the medic's back, so a fast medic is the cure). A patient who turns in the ward is S.Restrained: a zombie that takes no step and bites nobody, that nobody but a medic sees (`nearest` skips them for everyone else, so no fright, no calls, no police fire, no swarm pull), and that the next medic in the room puts down (CAUSE.Sedated, EV.Lost, a post) before doing anything else. Triage: a medic takes a bitten person only with a ward bed free somewhere (`freeBed`) and no zombie within MEDIC_CLEAR of the medic (or the pickup is a bite: a medic reaching for a patient with the zombie still beside them was most of the force's losses); with the hospital full the bitten are left where they are. A medic goes to clear a body only with no zombie in sight, and backs off from a body or a pickup when one comes within MEDIC_CLEAR (`backOff`: the mark dropped, MEDIC_WAIT ticks at the hospital before the next job); clearing bodies where the fighting was is what killed the crew, and answering police calls (a medic goes with the officers) and lingering at the scene the rest: those back off the same way; only a carry, a collapse or a strapped patient is seen through with a zombie near. Whoever turns inside a hospital room (a patient on a trolley, a medic, an officer who chased a zombie in) is strapped down, never loose in the wards. A bitten medic who is in the hospital (and not carrying) takes a bed at once: a patient like any other, cured by the ward's chance or turned strapped down and put down by a colleague; a medic turned loose inside once ate the rest of the crew. A patient set down in a full hospital is admitted all the same (a trolley), so no free zombie is ever made inside it. The hospital's wards have beds on every row, staggered (about a hundred on seed 1). Before all this nine patients in ten turned loose in the wards and ate the medics. A carrier (a medic with a patient, an officer with a looter) wears a bundle in the carried person's colour on their shoulder at sprite zoom, on both paths. - Someone carrying loot (`s.loot`) is a criminal: violet (`crook` in PALETTE and the legend), a sprite with a sack over the shoulder, after the bite and before the scare in the worse-news order (`colourOf` in draw.ts gives the one name used by the dots, the GL squares, the swatches and the bundles). - Street lamps stand along the streets (`lamps`): a post with a grey head by day, lit in the lamp colour from the first light level, on both paths, with the glow they always had. - The police station, the hospital and the fire station (K.FireStation, `city.fireStation`, dark red on the map, desks in its rooms) are the three biggest downtown buildings, in that order. - Ruin: once nine tenths of the people are dead or undead (RUIN), there is no society left and the state is sticky. Nobody goes to work or shopping, nobody calls the police, the open calls are dropped, the police arrest nobody, a shop is nobody's so taking from it is looting (the card says "off to loot a shop"), the danger label reads "ruin", the news desk is off air, and money holds no value: nothing is paid out or paid for, and the card says the coins are worth nothing. The hungry still go out for food, by day, or at night once desperate. - A 0-5 star danger rank changes how the police work; the stars are always on the bar, five empty ones in peace. Public fear keeps people home. A call shows on the map as a pixel for CALL_SHOW (an hour) only, though it stays queued for the police till it is answered or stale: the marker used to outlive the caller. - Hunger leads to looting and arrests. - Crime: desperation and birth. Somebody broke, hungry and with a bare fridge may turn to crime for good (`s.crook` 1, CROOK_P per poll): they take without paying. A few in a thousand grown-ups are criminals from the start, by the seed (`s.crook` 2, BORN_CROOK_P through `hash` with CROOK_SALT; 'a criminal' on the card's record row): at home at night in peace they go out on a job (JOB_P per poll): a burglary or a shut shop, or, living within RAID_R of the station with no weapon yet, the armory (S.Raid in peace: `arm(…, 3)`, EV.Heist, a charge of CRIME_HEIST days, a headline, no mob break-in). Out in the street with a rifle they hold somebody up now and then (MURDER_P per poll, checked in the armed block since the schedule poll never runs mid-walk; `holdUp`): the nearest resident in range on a clear line is shot (CAUSE.Murdered, `s.murders`, EV.Murder, a MURDER headline, 'murdered' in the death report), the purse taken, a fright for the witnesses and a call. Officers take in on sight anyone with a loot bag and a criminal with a murder on them (`wanted`): a rifle under a coat is not seen, so the heist alone does not get them caught (it did, within the hour, when any armed criminal was wanted). A born criminal's charges stick when they get home; a sentence is JAIL_TICKS × (charge + record − 1), four days for a murder. Measured on seed 7: a heist a day or so, a murder every day or two, each gunman caught within a day. - The economy: everyone has money (coins, on the card's household line). A worker is paid a daily wage on arrival at work (WAGE by the kind of workplace), the old a pension and jobless grown-ups a dole at dawn (PENSION, DOLE). A meal costs MEAL_PRICE at a shop with somebody serving; a grown-up with money and a low fridge shops for the household (MEALS_A_HEAD each, as far as the money goes), and the shop keeps the takings in its till. The farms grow the food: a farm worker's day yields FARM_YIELD meals, hauled to the nearest shop at the end of it (then home); shops hold SHOP_CAP and have no other supply after the first day's SHOP_STOCK. Shopping trips, the hungry's included, are made within SHOP_HOURS (9 to 16, when the keepers are surely in); an honest person who finds a shop shut takes nothing unless starving, so in peace nobody loots by mistake (people used to arrive in the evening after the keeper had gone home and walk out with the food, two hundred lootings a day). A grown-up broke and hungry, or broke with a bare fridge, turns to crime with CROOK_P per poll, for good: a crook takes without paying (looting), and an officer on patrol with no zombie in sight takes a looter to the cells at any rank, for JAIL_TICKS (under lockdown till it lifts). Care home residents have no money of their own and never shop. - Nobody is under 18. Homes are one family a room (FAMILY_MAX six): one or two grown-ups, then students (STUDENT_P, aged STUDENT_AGE 18 to 24, at the college while it has desks, on a grant of WAGE[K.College] 5 a day), grandparents (GRANDPARENT_P) and grown children or lodgers who work. The college (K.College, once the school) is the wide first lot of a college district; the children and the school went on 2026-10-25. The care home (K.Senior, the biggest house outside the downtown, lilac on the map) houses the old with nobody: they never go out, their pensions go to the home's till, and the nurses who work there (NURSES_PER_ROOM) shop for its fridge on that money (an errand). - Posts and headlines about payday, being broke, turning to crime, the harvest run, bare shelves, crime waves, fright on the doorsteps, heart attacks and revivals. On a quiet day the desk reports crime and death (arrests, looting, crime waves, fright, heart attacks, bare shelves, a cure or a revival) and otherwise keeps quiet: the filler and the harvest come once a day (FILLER_HOURS, HARVEST_HOURS 24), and the broke are news only under the outbreak. - The prison (K.Prison, the next biggest house outside the downtown after the care home, slate on the map): rows of cells, kept by GUARDS prison guards (A.Guard, teal, capped and armed), who stay in the prison, shoot a zombie within RANGE on a clear line and do nothing else. The police take looters there (the station's cells only without a prison). The sentence is by the crime and the record: a day for looting a shop, two for a burglary (`s.crime`, the worst thing in the bag, dropped at home), and a day more for each earlier conviction (`s.record`); under lockdown at least till it lifts. The card's record row shows convictions, the charge and the days left. Once the guards are down to GUARD_HOLD of the force, or the city is overrun, the inmates break out (BREAK_P per poll, EV.Break, a headline from BREAKS_WORTH an hour) and head home. - Clicking a rack, counter, shelf or fridge rings the cell in pink as a chosen person is ringed. - The station has an armory: a rack with three weapons per starting officer. Under lockdown (rank 4), once a fifth of the officers are lost, the station calls up the men of working age who live within 90 cells: they queue at the rack, take one each and go home. Overrun (rank 5), the scared within 90 cells break in through the doors and take what is left. Armed residents stay residents, but shoot a zombie within six cells on a clear line, slowly; the weapon goes with them when they turn or are arrested; a dead officer, guard or armed resident keeps it on the body (`s.armed` 3 on the dead slot, outside `armedCount`), and once the outbreak is on, the next unarmed person to stand on the body takes it (EV.Scavenged, 'a rifle taken off a body' on the card); a medic clearing the body takes the gun with it (`release`). - A zomstagram feed posts what people say, and a news strip above the map gives headlines (over the map only on a phone, where the map is the whole screen); the latest stays up, dimmed once it is old. - When nobody is left, "See the report" ends the run with a chart and a timeline. - The military dispatch (🪖 on the bar, design under docs/superpowers/specs/2026-10-26-outbreak-military-design.md): a confirm dialog with the force's size (SQUADS 16 squads of SQUAD 6, up to MAX_SQUADS), then `dispatchArmy`. One shot, no undo. The city is sealed: the desk's last headline (QUARANTINE in news.ts) goes up as the button is pressed and the desk says nothing ever again (`look` returns null with `s.army`); the ribbon reads NO SIGNAL once it fades. The danger label reads "quarantine" (over the stars and the ruin), "zone sterilised" or "quarantine · no one is coming". Squads set out one every CONVOY_GAP ticks: even ones by truck along the ring road from the corner before their entry point (ENTRY, eight points clockwise from the top-left corner, on the ring's middle row), odd ones by chopper from the nearest edge to a street of the suburb or downtown. `s.convoy` holds the vehicles as CONVOY_N numbers each, drawn by interpolation on the overlay (`drawConvoy`): a truck parks at its entry point for good, a chopper hovers a second and flies back out. A squad lands when its vehicle does (`placeSquad`, free street cells round the drop; `s.squadSlots` remembers its slots), SENTRIES of a truck's squad stay at the entry point in S.Hold; a parked truck raises its stretch of the barricade (`raise`: the ring's outer row from halfway to each neighbouring entry point, painted PALETTE.barricade into `base`; the edge is impassable already, so the barricade is paint, not tiles) and whatever stretches no truck reached go up when the last vehicle lands (`s.army` 2). Soldiers (A.Soldier, olive, helmeted, a weapon bar; not residents: their own bar count, not in `alive`) shoot what they see on a clear line within RANGE every ARMY_COOL ticks (an officer's is SHOT_COOL 30): a zombie first (restrained ward patients included), and after the squad's grace (`s.grace[k]` = landing + GRACE, two hours) anyone at all (LOOK.Anyone: residents, police, medics, guards, the jailed, the strapped down), CAUSE.Executed, 'shot by the military' in the report. A squad holds where it landed through its grace, then follows its leader (`leaderOf`: the lowest living slot of the squad not on sentry duty; a fallen leader is replaced on the next scan with nothing stored) who sweeps: the lowest unclaimed room of the building being swept (`s.work`), else the nearest unclaimed room of any building with a door (`nextSweep`, `s.swept` per room, claimed on the way; every room claimed, the sweep begins again), a room given up after SWEEP_TICKS; the leader takes every other step while a follower is more than SQUAD_GAP behind; a follower's place is its own cell beside the leader (FORM by its place in the squad, `formUp`: a knot, not six on one cell, which is what it was in the first screenshot). A truck's squad stands two cells clear of the parked truck, which hid it. A sentry whose squad has no sweeper left goes in after them (a beaten army once held the ring for ever). The people: while `s.trust` holds, anyone idle or hiding within RUN_R of a soldier (heard through walls, `nearest(…, heard)`) comes out to them with RUN_TO_P per scan, whatever the lockdown or the fear says (EV.Rescue once, `s.dread` 1); the first person shot ends the trust for the whole city, and from then a soldier in sight is a zombie in sight (`s.dread` 2), and outdoors half of them (EDGE_P) flee for the ring road's inner row instead of home, where the sentries wait; a hider on a doorstep with a soldier in sight runs again. An armed resident with a soldier within CIV_RANGE on a clear line shoots it (CAUSE.Gunned, 'shot by a resident'). Soldiers are bitten and turn like anyone, and leave their gun on the body. The endings, on the dispatcher's beat: nothing alive but the army and no zombie left → `s.army` 3 (`sterilise`: every stain restored, every body slot freed, the soldiers sent to the nearest entry point and gone on arrival; the end banner reads "zone sterilised" and the run report carries the toll chart); no soldier left → 4 (lost; the quarantine stands, and with the last resident the old "no survivors" end). Measured (balance.txt in the session's scratchpad, 2026-10-26): on a quiet seed 1 sixteen squads execute 8,600 people in three days and lose one soldier to a resident's rifle; against a day-3 outbreak (50 zombies on day 1: 1,300 zombies, 4,400 alive) they lose 80 of 96 soldiers in four days, mostly bitten opening doors on packed rooms, and the sentries go in last; six squads lose outright. The army can lose, by design. - Fire (design under docs/superpowers/specs/2026-10-26-outbreak-fire-design.md): per cell `s.fire` (fire ticks of fuel left) and `s.charred`; the burning cells in `s.blaze`. Every FIRE_EVERY ticks (`fireTick`) each burning cell burns down one, is repainted PALETTE.fire over whatever painted it (a body, a door toggle), and may light a neighbour: a cell with fuel (`fuelOf`: a floor FUEL_FLOOR, a door FUEL_DOOR, a wall FUEL_WALL; street, ground, field and hole never) in the same building by SPREAD_P, another building's wall, touching or across a cell or two of ground, by EMBER_P, so a block burns and a city does not. Burnt out (`burnOut`): a floor is charred (PALETTE.char, `s.charred`), a door DoorBroken, a wall a Hole, all pushed on `s.damage` for the builders. Then one room drawn at random catches with `s.fireP` (FIRE_P; the tests set 0), EMPTY_MULT times that with nobody in it. `ignite(s, at)` lights a cell. A burning cell is a wall to the living in `tryMove`; a medic's clear-away and the clean-up repaint through `repaint`, which knows fire and char. - Builders (`isBuilder`: office workers by the seed, BUILDER_P through `hash` with BUILDER_SALT; 'builder' on the card): the horde's holes and broken doors and the fire's charred floors go on `s.damage`. At the poll by day, in peace (under RANK_LINES, not locked, not frightened, not hungry), an idle builder takes the nearest listed damage (`takeJob`: off the list, skipped if mended already) and goes S.Build to a stand beside it (`besideFire`); there, REPAIR_TICKS standing (`s.mark` 1, `s.cool` the countdown), then `repair` (a Hole a Wall with `wallHp` 0, a DoorBroken a DoorClosed with DOOR_HP, a charred floor relaid and repainted), EV.Rebuilt, the next job or the office. A job that outruns BUILD_BUDGET, or a builder frightened off it (aware > 0), gives the cell back to the list. 'rebuilding a wall' / 'hanging a door' / 'relaying a floor' on the card by what stands beside them. - The fire brigade (A.Fire, FIREFIGHTERS 20, MAX_FIREFIGHTERS 100; `createSim`'s sixth argument; the setup slider and `?fire=`): on standby at desks in the fire station, a beat now and then in peace (BEAT_EVERY), home to the station off duty whatever the rank, like the medics. `fireDispatch`, on the dispatcher's beat: the oldest standing alarm (the fire's cell; stale after CALL_STALE; all dropped under ruin) goes to the FIRE_PER_CALL nearest free firefighters (`nearestFree`), S.Respond to the building's anchor with `mark` the building. There, S.Douse: each scan the nearest burning cell of the building (`nearestBlazeOf`, over `s.blaze`) is the target (`zx, zy`) and the nearest free side of it the stand (`besideFire`, never the ground round a building: the way there is found only from the building's own street, and crews sent to the strip between two buildings from another street paced its end for good; the floor inside or the street reaches as well); an inner doorway as a stand is reached through its room (`targetCell` gives it `doors.b`; with no room it was taken for a cell outside, and the crew walked into the wall between it and the street, back and forth, for good); beside it, a burst every SPRAY_EVERY ticks (`spray`: SPRAY_HIT off the cell's fire, out at 0 and repainted; `s.sprays`/`nSpray` for the page, as the shots); the building cold, off duty after RESPOND_LINGER. A burning person within SPRAY_R comes before any cell (`douse` by the firefighter, EV.Doused the firefighter's post); a burning cell beside the way gets a burst in passing, on the way to a stand too, where it may be the fire that blocks the way (crews used to stand beside a burning cell, blocked, without spraying it). A zombie within MEDIC_CLEAR: `backOff` to the station and the alarm back on the queue. Firefighters turn and burn like anyone. - Burning (`alight`, called first by every kind): a cold slot on a burning cell catches (`catchFire`: `s.burn` = BURN_TICKS, EV.Burning; a person drops their load and runs), a burning zombie's bite lights the bitten, and now and then (CATCH_P per scan) a burning slot lights the cell underfoot and the people on or beside its cell, never a zombie. A burning person is S.Frenzy: a new dash every FRENZY_EVERY ticks to anywhere within FRENZY_R (`frenzy`), at a run, nothing else (an inmate runs out of the cell, a patient out of the ward; a strapped-down zombie burns where it lies); a burning zombie is a zombie. The burn survives the turn, but BURN_TICKS is under the infection's shortest clock, so most burn to death first. At 0: CAUSE.Burned, a charcoal body (PALETTE.char), 'dead: burned'. `douse` (a firefighter's): the force shake it off and go back to work; a resident is `s.hurt`, S.Down for BURN_WAIT on `s.downs`, 'down with burns': a medic carries them to a ward (not the revival), where `admit` sets HEAL_TICKS and they go home healed, else they die Burned where they lie. Measured (2026-10-26, fire-balance.ts in the session's scratchpad): a quiet seed 1 with the default brigade had four fires in nine days, none past six cells, two dead; seed 7 two fires, one in a crowd that reached 76 cells and 22 dead; with no brigade seed 1 lost a house of about a hundred cells to each fire and 83 people in six days. A fire in sight (`nearestFire` over `s.blaze` within SIGHT, through walls: the smoke over the roof, so an empty house's fire is called in early) is a fright (SCARE_FIRE), an EV.Fire post once, a fire call on `s.alarms` (the fire's cell; the `called` cadence per bucket; dropped stale or under ruin, EV.FireCall), and the flight: from inside, straight out of the building to its anchor (`flee` with a burning cell as the danger); while any cell of the home room burns (`homeBurns`) home is off limits to the poll and the flee, and they wait where they are till it is cold. - Fire on the page: burning cells are painted PALETTE.fire into `base` (both paths), and the overlay (`drawFire`) adds a flame tongue that moves round each burning cell in view, a column of PUFFS smoke puffs climbing SMOKE_HEIGHT cells, swelling, drifting and thinning by the tick (nothing stored: arithmetic on tick and cell), and from the first light level a glow with 'lighter' (GLOW_R). Somebody on fire is PALETTE.fire as a dot (`colourOf` puts the burn before everything) and wears a flickering flame over the sprite (`drawBurning`; a quad in gl.ts). Extinguisher bursts (`s.sprays`, cleared each frame like the flashes) are a pale jet and a puff (`drawSpray`). Charred floors are PALETTE.char. Sprites: 'firefighter' (a red helmet, a tank on the back), 'builder' (a yellow hard hat, worn while at a repair). Legend: firefighter, fire station, fire, charred floor. `window.__ignite(x, y)` lights a cell for a test or a look. - News: a fire call is a story every FIRE_HOURS at most; a home lost to fire (EV.Blaze, told by a resident when the last floor cell of a room burns out) and the dead by fire (`s.burned`) are headlines; DOUSED_WORTH rescues in an hour a tally; a burning zombie is told once (`see(events, sim)` reads the kind). - Posts: Rescue ("the army is here. running out to them"), Fired (what the witnesses of an execution post: "they're shooting everyone"), Scavenged; Dispatch, Executed, Sterile and ArmyLost post nothing (the dead do not type; the station's news is off the air). A carrier (a medic turning, an officer with a looter) who cannot set their load down, with zombies or walls on every side, loses them: CAUSE.Eaten, the body on the carrier's cell (it used to free the slot with no cause, the 'lost' row of the report). A ☠ button on the bar opens the death report at any time: the dead by cause as a bar chart (`toll`, `tollChart`, `deathReport` in report.ts), who of the force died, and how many turned are still walking. There is no sound, and no CRT toggle (removed 2026-10-25). URL params: - `?seed=` (random when absent; the setup shows it in a number box with a 🎲 to draw another; reset draws a new one, so pin it to repeat a run); - `?pop=&police=&medics=&fire=`: the setup form submits these (a link without `fire=` runs the default brigade); - `?z=N` opens with N zombies; - `?hour=` and `?zoom=&cx=&cy=`; - `?gl=0|1` forces the 2D or WebGL2 path; - `?dna=runner,instant,swarm`: the mutations, which the checkboxes keep up to date; the old `anger` reads as runner and instant together. ## How it was built - **City generation (`city.ts`)** works on a cell grid with one tile per cell. A ring road and streets come from recursive splitting. Lots get walled buildings with BSP rooms, doors per split and street doors per 40 floor cells. Zones run from downtown to rural with district-dealt kinds (home, office, shop, farm, college). The two biggest downtown buildings become the police station and the hospital (big, not central: the force on standby, the cells, the wards and the rack need rooms). Rooms are furnished by kind (beds, fridges, desks, counters, shelves, cells, wards). Navigation is tables: a street segment next-hop matrix plus a door tree per building. - **Simulation (`sim.ts`)** runs at TICK_HZ 30, and a day is DAY_TICKS 3600. PACE 0.5 means 1× runs the sim at 15 ticks/s, so a day takes 4 minutes. - **No stored paths.** Everything is flat typed arrays. Nobody keeps a path or a reference to anybody else, only a target cell and a waypoint recomputed from where they stand, so a broken door never leaves a stale plan. This is the core design rule. - **Crowds.** `s.occ` names one agent on a cell and `s.crowd` counts them; `enter`/`leave` keep both, and every placement goes through them. People share cells (`tryMove` lets a person onto any cell without a zombie or an officer on a line), so there is no push, swap or nudge any more. `leave` renames a cell after someone else on it from the bucket list; whoever came in from the next bucket this tick is missed, and the cell is nobody's till the next move (the crowd count still keeps zombies off it). Anything that must see everyone in a room (`staffed`, a looted household) walks the buckets over it with `eachIn`, not the occupant record. - **Arriving.** One rule for everyone going somewhere (`arrived`): on the cell picked, or in its room off the doorstep with that cell taken or no way through. Police and medics once had only the no-way-through clause, and a step aside reset the counter behind it, so an officer back at a full station stepped aside and back again for good. - **Sidesteps.** A walker blocked (by a zombie, an officer's line or a shut door) for BLOCKED_RANDOM ticks steps aside at random; `s.side` remembers the axis of that sidestep, and the next step tries the other axis first, or it would undo the sidestep and the two would loop for good (a medic two cells below a door in the west wall, a standby medic on the cell between, looped for two days). - **Doors.** Stepping onto a closed door opens it; stepping off closes it. Zombies can't open doors and pound them instead (DOOR_HP 90). Under lockdown a horde of 12 or more wears a wall into a Hole (WALL_HP 900). - **Awareness** comes from line of sight plus a per-bucket alarm, and it fades. - **Shots** check `los` and `lineClear`, both Bresenham walks; `lineClear` returns true at once for a target on the shooter's own cell, which happens under the instant strain when someone sharing an officer's cell turns on the spot. Without that it stepped away from the target and never arrived: the page froze with a few thousand swarm zombies. - **Looking around (`nearest`)** is where the time goes once there are thousands of zombies, and three things keep it linear. Each bucket's `order` list holds the living first and the zombies after `bSplit`, so a look walks only the kind it wants (a swarm's thousand zombies in one bucket used to be walked by every one of them). The buckets are read nearest ring first (`RINGS`) and a bucket whose nearest edge is farther than the best find is skipped. `s.open` counts each room's open or broken doors and holes (kept by `setTile`/`opened`), and a look skips a raycast at anyone in a shut room, or at everyone when the looker's own room is shut: a horde against a full house used to fire a raycast at every hider inside, twenty thousand a step. Together: 6.6 ms to 2.8 ms a step at four thousand zombies. - **Danger rank** comes from DANGER_Z thresholds on the bitten and turned. **Ruin** (`s.ruined`, set in `step` from `s.dead + zombies`) is what keeps fifty survivors from going back to the shops once the horde has starved and the rank has fallen: `locked` includes it, calls and arrests check it, and `take`/the arrival at work ignore a shop's keeper under it. - **Fear** comes from FEAR_W weights per event and halves every FEAR_HALF ticks. **Fright** is per person (`scare`/`witness` in sim.ts): `witness` walks the living in the buckets within WITNESS_R of a culprit, through walls (a looting is heard as well as seen), and `scare` returns whether the fright crossed SCARE_HOME, which is when EV.Witness is emitted. - **Hunger:** a day without eating is hungry and three days is death. Fridges and finite shop stock are refilled each morning. Zombies starve a day after their last bite (ZOMBIE_FOOD), and STARVE_FAST once nobody is alive. - **Who people are (`people.ts`).** Identity (name, sex, age, job) is derived from the seed and the slot and never stored. Posts are built from templates, half of them combined from an opener, a core line for the event and a closer. - **Rendering (`draw.ts`, `gl.ts`).** The terrain is painted once at TILE 4 px per cell and patched only where cells change. Night is a light-level wash with street lamps and lit windows. People are dots when zoomed out and 8 px sprites from SPRITE_ZOOM 3. The atlas holds ATLAS_SORTS (eight) sorts per column block, the rest in a block to the right (`spriteXY`), so it stays under the 4096 px texture height some phone GPUs stop at. The camera eases towards where it is sent. - The WebGL2 path does the terrain texture, the night in the shader, additive glow quads, instanced people and the fire (`GlRenderer.fire`: a flame tongue quad, PUFFS soft puffs from the glow sprite in smoke grey, and at night an added glow quad per burning cell; `puffAt` in draw.ts is the puff arithmetic both paths share), with labels, shot flashes and extinguisher bursts on a 2D overlay. The fire moved off the overlay on 2026-10-26: Firefox rasterises that overlay in software, about 2 ms a megapixel per big draw, and a block ablaze by night cost 10 ms a paint there; as quads it is 1.5. - Software GL (SwiftShader, llvmpipe) is skipped, because the 2D path beats it. - A GPU path that costs over 12 ms/frame after 120 frames reloads with `?gl=0`. - The page paints only when the picture can have changed: a tick ran, the camera is still easing, or something is dirty (a pick, a resize), and at most PAINT_HZ 30 a second unless dirty. At 1× that is 15 paints a second, not 60; at 2× and up it was the display's 60 and is 30 (2026-10-26: the fan); paused and still, nothing. The GL watchdog counts paints, not frames. - The lamps' glow is painted once per light level onto a map-sized layer (`drawNight` keeps it per city) and laid on with one `drawImage`; the windows are still a rect per roof. - `Terrain.update(changed)` repaints a 3×3 round each cell the sim lists in `s.changed` (every write to a cell's tile or colour pushes there: `setTile`, `die`, `repaint`, the barricade), except a door that only opened or shut, which repaints itself alone: doors are most of the changes at rush hour, and no neighbour's look depends on them. It used to scan all 130,000 cells against a copy every paint. - Fire's cost: `s.fireB` counts burning cells per bucket, and `nearestFire`/`homeBurns` read the buckets round them before walking `s.blaze` at all; a block ablaze used to cost every resident's scan a walk of a thousand cells (7.7 ms a step, now 1.9). - Unless `?gl=0`, the terrain canvas is made `willReadFrequently`, so the GPU path's per-cell `getImageData` is a memory copy instead of a GPU readback. - The GPU path uploads the terrain's changes by chunk (CHUNK 32 cells, a cell of margin for the repainted neighbours; gl.ts `chunkDirty`), not by cell: a crowd through the doors of a block ablaze changes some 250 door cells a tick (each crossing opens and shuts one), and a `texSubImage2D` for each was hundreds of GL calls a frame. - Fire's drawing on the 2D path is bounded (2026-10-26, the freeze with a lot of fire, seen in Firefox on a GPU): the night glow is one gradient sprite stamped on a small layer (GLOW_PX 2 px a cell) with 'lighter' and laid on with one smoothed `drawImage` over the burning cells' box, where a `createRadialGradient` per burning cell per paint cost 30 ms a frame; a smoke puff is a `drawImage` of one round sprite (PUFF_PX), not an `arc` filled; and past SMOKE_MAX 250 burning cells in view only one cell in n (by `hash`) smokes, past GLOW_MAX 200 one in n is stamped n times as strong, so a block ablaze costs the same whatever its size. The flame tongue is still on every cell. - **The armory (`sim.ts`, `city.ts`).** `city.armory` is the station's smallest room, with one `O.Rack` cell placed corner-first (`generate`); `s.arms` is `ARMS_PER_OFFICER × s.force`, set by `setForce` only before the outbreak. `dispatch` flips `s.callup` (one `EV.Callup`/`EV.CallupOver` per edge) when the rank is exactly 4, the rack has stock and living officers are under `CALLUP_FORCE` of the force. A called-up man goes `S.Muster` to the rack cell and arms (`arm()`) once at the rack, beside it, or on any floor cell of the armory room off a doorstep (`atRack`): a target cell somebody holds is re-rolled to a random cell of the room on the way in by `nextWaypoint`, so the room has to count as the rack or men wait in it for good. `dispatch` keeps `s.spare` (weapons not yet spoken for by a man on his way) so the queue is as long as the stock, not the district. He walks home armed; he ignores bucket alarms and flees only from a zombie he sees within `MUSTER_FLEE`. At rank 5 `tryRaid()`, on the poll, sends a scared, unarmed adult within `RAID_R` of the rack into `S.Raid` instead of hiding; raiders flee only from a zombie within `RAID_FLEE`, and then wait `RAID_HOLD` before trying again (without the poll and the hold a raider turned round on the spot into the same zombie, a thousand times a run); they arm (or `EV.RaidEmpty`) at the rack and then flee as anyone would; the first raid is `EV.BreakIn`. Raiders use doors, never a `Hole`: the hole rule (zombies in, not people through) is kept. Armed residents check for a zombie within `CIV_RANGE` with `lineClear` before anything else each tick; `civilian()` now counts `cool` down. `disarm()` runs in `turn`, `die` and the arrest. `who.ts` holds the seeded `hash` and `female` so the sim can ask who is a man without importing people.ts. - **The economy (`sim.ts`, `city.ts`).** `s.money`, `s.paid` (the day last paid), `s.haul`, `s.crook`, `s.errand` per slot; `s.household` and `s.till` per room. `pay()` pays once a day; a care home resident's pension goes to the room's till. `take()` buys when the shop is staffed and the taker is honest and the city not ruined, from the errand's till or the buyer's purse, else it is looting as before. `forage(s, i, raid)` only raids homes for the hungry. The poll sends a farmer with a haul to `nearestShop` before home; the arrival at a shop with a haul fills the shelves (`EV.Haul`). The generator settles a family per home room (`settle`, `workplace`), picks the care home after the civic buildings, and fills its rooms with the old first. A haul goes to the nearest shop under half full, else the emptiest anywhere (`nearestShop`, picked once per haul and kept in `s.errand`): the nearest alone filled the rural shops to the cap and left the downtown bare, and picked afresh each poll it sent farmers wandering between shops till they starved. In peace a standby officer walks a beat every BEAT_EVERY ticks and watches for looters on the way back too; without that nobody was ever arrested before the lockdown. Balance on seed 1 (a six-day quiet run): 498 farmers × FARM_YIELD 40 against 8,692 mouths keeps the shelves at three to eleven thousand meals; the fridges start at FRIDGE_START four a head so the first mornings do not strip the shelves; nobody starves; a hundred or two of six thousand grown-ups are broke at any time, half a dozen a day turn to crime, and the police jail thirty to fifty looters a day (the cells hold about thirty; the rest are set down at the door). A wage of 10 to 12 buys three or four meals at MEAL_PRICE 3, the pension one and a bit, the dole exactly one, so a working household is fine and one on the dole alone eats and nothing else. SHOP_CAP is 2000: at 500, a seed with twenty shops for ten thousand people could not shelve a day's eating, the shelves ran dry from day five whatever the farms grew, and starvation and a looting wave followed (seed 7). Measured after (nine quiet days, seeds 1 and 7): nobody starves, the shelves hold twenty to forty thousand meals, under four in a hundred are hungry at any time, nobody turns to crime from hunger. - **The DNA (`sim.ts`).** `s.dna.{runner,instant,swarm}` are plain booleans the page flips; nothing is stored per zombie. Runner: `zombie()` skips the `SHAMBLE_EVERY` gate. Instant: it calls `turn()` straight after the bite. The two were one 'anger' strain till 2026-10-25. Swarm: `step()` sums the zombies' positions into `s.swarmX/Y` and, with no prey seen by anyone within `LOSE[A.Zombie]` ticks, picks a heading `s.hiveX/Y` within `SWARM_ROAM` of the middle whenever the middle is within `SWARM_NEAR` of the old one or it is `SWARM_STALE` ticks old (a heading behind a wall); a zombie that sees someone writes them to the hive (`s.hiveSeen`), and a zombie that sees nobody takes the hive as its target, on its own cell of a `SWARM_SPREAD` square round it, at `S.Chase` while the hive has prey and `S.Wander` otherwise. The wander re-roll is skipped under swarm: the heading is the swarm's to change. - **History (2026-10-19 to 10-21).** Changes that are easy to break: - The doorstep traffic rule once sealed packed rooms; then walkers passed idlers and pushed queues; since 2026-10-25 people pass through each other and none of that exists. - Runtime force sliders were replaced by the setup dialog with a fixed SCENARIO_SEED; since 2026-10-25 the seed is random unless the URL pins it. - 1× was halved. - Idle thoughts no longer add fear. - The dead don't post, and zombies and the turned don't post. - Once the undead outnumber the living, the news is only the emergency broadcast every three hours. - 2026-10-23: the armory, the call-up, the break-in and armed residents (design and plan under docs/superpowers). - 2026-10-25 (later): the economy, families, the care home (design under docs/superpowers/specs/2026-10-25-outbreak-economy-design.md). The housing was retuned for one family a room: a bigger downtown and suburb (ZONE_RADIUS), more home districts, bigger rural houses and narrower rural lots; seed 1 holds 8,656. - 2026-10-26 (later): fire, the fire brigade, builders and bodies kept clear of (design under docs/superpowers/specs/2026-10-26-outbreak-fire-design.md, plan under docs/superpowers/plans). - 2026-10-26: the military dispatch (above), and guns left on bodies for the living to take. - 2026-10-25 (latest): the shelves four times bigger and the dole a meal (the quiet-day starvation and looting wave on shop-poor seeds); crooks from hunger only; born criminals with heists and hold-ups; the death report; the seed drawn at random and shown on the setup. Earlier the same day: the card with bars and the clickable family; fright from crime; heart attacks and revivals; the criminal colour and the carried bundle; lamp posts; the quiet desk; the police at 60 and the medics at 30 by default (the sim tests that assumed 24 pin the count or take the zombie out of a dispatch scenario the officer could lose by the luck of the walk); the CRT toggle removed. Then: the shop hours and the shut-shop rule (crime in peace was all honest people at shut shops), the point-blank fix for the freeze, and spec.md. Then the wards: restraints, the cure by arrival time, triage, four times the beds; the stars always shown; the bullseye; the call marker made brief. Then the children went: everyone is 18 or over, the school is a college with students of 18 to 24 on a grant. - 2026-10-25: the DNA tab (anger, since split into runner and instant; swarm). A chasing or starving zombie used to keep a person's pace; now no unmutated zombie ever runs, which is what the anger strain is for. Then: strain colours, the civic buildings picked by size, the shared `arrived` rule, the sidestep memory, and the zombie's clock cut from three days to one. Then the swarm's CPU: the looks made linear (above), and ruin (survival mode for the last tenth). The night queues at packed homes went with the crowds change: people pass through each other. Also then: the rack, the shop stock and the fridge in their own colours with a stock card on click. - The page was vibe coded: prompted into existence with a coding agent and iterated commit by commit. ## Files - 015/index.html: page shell, map plus overlay canvases, snackbar, the news strip above the map, end banner, danger stars, person card, zomstagram aside, the control bar (speed menu, tools, DNA button, zoom, clock, counts), legend, the DNA dialog, the report dialog, the setup dialog form, and all CSS including the phone and landscape HUD layouts. - 015/main.ts: setup, city/sim creation, the fixed-step accumulator, camera/zoom/pan/touch, tools, card, feed and fear, news and report wiring, 2D drawing, the GL watchdog, paint skipping, and the `window.__*` hooks. - 015/city.ts: `generate(seed, population)`, tile/zone/kind/furniture enums, PALETTE, and the los/doorChain/meet helpers. Uses `seeded` from `lib/rng.ts`. - 015/sim.ts: `createSim`, `step`, `spawnZombie`, `counts`, `setForce`, `dispatchArmy`, lighting, and all behaviour constants and state enums (A, S, EV, CAUSE, DANGER). - 015/people.ts: `identity`, `status` (card text), `facts` (the card's rows, some with a bar), `family`/`household`, `post` (zomstagram lines), and POST_P per event. - 015/who.ts: the seeded `hash` and `female`, shared by people.ts (which re-exports `female`) and sim.ts. - 015/news.ts: the `Desk` class, which looks once an hour and yields headlines, filler or emergency broadcasts, rotating phrasings. - 015/news.ts: `Desk.see(events, sim)` tallies events (the kind of a burning slot read from the sim), `look` once an hour. - 015/report.ts: `report()` and `chart()` (SVG of alive/bitten/zombies/dead by hour) plus the timeline, with the toll chart when a sim is passed; `toll`, `tollChart`, `deathReport`. - 015/draw.ts: the Terrain painter (lamp posts included), sprite atlas (a row of looks per sort, the strains, the crook and the soldier among them), `strainOf`, `colourOf`, night/lamps/windows, Camera, drawFlash and drawConvoy. - 015/gl.ts: `GlRenderer` (WebGL2 path; `make` returns null on software GL unless forced). - 015/city.test.ts, sim.test.ts, people.test.ts, news.test.ts, report.test.ts: pure node tests on small seeded cities and scenarios. - 015/spec.md: the engine-agnostic specification of the whole game (rules, numbers, invariants, test scenarios), for building it again elsewhere; update it when a rule or a number changes. - 015/page.test.ts: headless-browser tests covering the quiet city, outbreak spread, speeds, fit/no scroll, setup, the DNA dialog and its pause, wheel zoom, tools, card/feed, GPU vs 2D paths, phone pinch/double-tap/finger strokes, the upright zoom and the fold tab, the report, paint skipping, and the military dispatch. ## Extending it - Run: `npm install && npm run dev`, open http://localhost:5173/015/ . Tests: `npm test`. Typecheck+build: `npm run build`. Without `pop/police/medics` in the query the setup dialog shows first, so tests and links should pass them. - Debug hooks on `window`: `__spawn(x,y)`, `__someone(n)`, `__tick()`, `__counts()`, `__view()`, `__selected()`, `__following()`, `__labels()`, `__speed()`, `__frameMs()`, `__gl()`, `__fear()`, `__sim()`, `__news()`, `__paints()`, `__step(n)` (runs n ticks without painting). - Knobs: the constants at the top of `sim.ts` (sight, infection ticks, rank thresholds, fear weights, the fright: SCARE_SHOOTING, SCARE_BURGLED, SCARE_LOOTING, SCARE_HOME, SCARE_FADE, WITNESS_R; the heart: HEART_P, DOWN_TICKS, REVIVE_P; hunger and stock, the prison: GUARDS, GUARD_HOLD, BREAK_P, JAIL_TICKS; the economy: MEAL_PRICE, WAGE, PENSION, DOLE, START_MONEY, FARM_YIELD, SHOP_CAP, MEALS_A_HEAD, CROOK_P, JAIL_TICKS; the news thresholds CROOKS_WORTH, BROKE_WORTH, HAULS_WORTH, FRIGHTS_WORTH, DRY_PER_SHOP, FILLER_HOURS in news.ts; COINS_FULL in people.ts; police/medic counts and maxima, the armory: ARMS_PER_OFFICER, CALLUP_FORCE, CALLUP_R, RAID_R, MUSTER_FLEE, RAID_FLEE, CIV_RANGE, CIV_SHOT_COOL; RAID_HOLD; the pace SHAMBLE_EVERY, the zombie's clock ZOMBIE_FOOD and the swarm's SWARM_NEAR, SWARM_ROAM, SWARM_STALE, SWARM_SPREAD; the news thresholds ARMED_WORTH and CIV_SHOTS_WORTH are in news.ts), `city.ts` (zones, street widths, district odds, CELLS_PER_DOOR, the families: FAMILY_MAX, SECOND_ADULT_P, CHILD_P, GRANDPARENT_P, SENIOR_FILL, NURSES_PER_ROOM, PALETTE with the strain colours `raging` and `swarming`, the criminal's `crook` and the stock colours `rack`, `food`, `fridge`), and `main.ts` (PACE, POST_EVERY by rank, zoom limits, GL thresholds). - Invariants: - Keep sim state in typed arrays indexed by slot, with no object graphs or stored paths. - Identity must stay derivable from (seed, slot). - Event arrays are indexed by EV, so adding an EV means extending FEAR_W (sim.ts), POST_P, TEXT and CORE (people.ts); an event nobody posts about (the station's own) gets POST_P 0, empty TEXT/CORE, and a place in the exemption list of the "every event has a post" test. - Keep `sim.ts` free of DOM. - A canvas that has given out a WebGL context won't give a 2D one, so the WebGL2 probe runs on a scratch canvas. - Browser tests use `test/browser.ts` (vite plus headless chrome, SwiftShader, raw CDP for touches). They skip without Chrome (CHROME_PATH), so CI skips them. An outbreak test seeds three zombies, since one alone can be shot before it bites. - Conventions: keep pure simulation in its own module with a `node --test` file beside it; match the surrounding code style; Conventional Commits `type(015): message`.