Skip to content

feat(gridlock): isometric neon city-builder with pure simulation core - #17

Draft
cloudygetty-ai wants to merge 1 commit into
mainfrom
claude/city-sim-game-design-deckz7
Draft

cloudygetty-ai wants to merge 1 commit into
mainfrom
claude/city-sim-game-design-deckz7

Conversation

@cloudygetty-ai

Copy link
Copy Markdown
Owner

GRIDLOCK — Everything runs through you.

A SimCity-style isometric city-builder at games/gridlock/. Open index.html — no build step, no dependencies, no server.

What makes it not-SimCity

Three pressures turn zoning from painting into a decision:

  1. Adjacency synergy — 11 rules where the same building is worth materially more or less depending on what it touches. Commerce beside housing sells more (+8%/neighbour, cap 4). Housing beside a foundry loses approval. A server farm on the waterfront dumps heat into the bay. The inspector shows what a tile would score before you commit.
  2. The Heat Index — generators, factories, and server farms emit heat. Past 55 it raises city-wide cooling demand and costs approval; past 88 the city is in crisis and the map takes a red cast. Parks, sky gardens, and carbon scrubbers pull it back.
  3. Crisis cards — 12 condition-triggered cards that pause the world and force a trade with no clean answer (Grid Surge, Heatwave, Corporate Bid, Transit Strike, Arrival Wave, Data Breach, Ground Tremor, Smog Alert, Blackout Riots…). Unseen cards are 3× as likely, so the deck stays surprising.

The three chains

road ──▶ power ──▶ water ──▶ live. A structure produces nothing unless all three hold. Utility rationing is deterministic and priority-ordered — water plants and clinics stay lit, factories brown out first — and water resolves after power, so an unpowered pump makes no water and the cascade runs one way.

Architecture

  • config/ is data only; core/ is a pure simulation: tickMonth(state) → state, no DOM, no clock, no Math.random. It runs headless under node --test, which is what makes any of this testable.
  • Every stochastic decision draws from (seed, rollCount), so a save file replays exactly and crisis outcomes are reproducible.
  • Buildings are catalog entries — adding one to config/buildings.js makes it appear in the palette, on the map, and in the economy with no other code change. The renderer draws all 31 structures procedurally; there is no art pipeline.
  • HEALTH / PRESSURE / EFFICIENCY telemetry behind ` or ?debug=1. A built-out city ticks in <1ms and draws in ~3ms at 58fps.

Tests

77 tests, no framework and no dependencies: placement rules, road connectivity and orphan islands, rationing order, synergy caps, tick purity/determinism, crisis gating, directive streaks, and a 10-year fixture-district balance regression (fills up, pays for itself, stays cool; dirty industry demonstrably overheats it; severing a street takes the district offline).

Two real bugs were caught and fixed during verification:

  • Grid Surge fired every single month — its condition compared power.ratio (clamped at 1) against 1.05. There is now a test asserting no crisis condition does this.
  • Structures stranded from the road graph were invisible — the sim was correct but silent, so the HUD now shows a pulsing N CUT OFF chip alongside BROWNOUT / WATER SHORT / GRIDLOCK / DEFICIT / OVERHEATING.

Verification

  • npm run test:gridlock — 77/77 pass
  • Browser-driven smoke test in headless Chromium: intro → build a district by dragging → run at 3× → resolve a live crisis → cycle overlays → save/load round-trip. No console errors (the only network failure is Google Fonts being blocked in the sandbox; fallback stacks are in place).
  • Repo type-check / lint / jest are unaffected — tsconfig includes only src/**, eslint targets only .ts,.tsx, and jest's testRegex does not match .mjs. (Those commands fail in this container only because node_modules is not installed.)

Also included

  • /gridlock route in vercel.json (plus static passthrough for games/**)
  • An isolated, dependency-free CI job on Node 20 for the simulation core
  • npm run test:gridlock at the repo root

Generated by Claude Code

GRIDLOCK — "Everything runs through you." A SimCity-style builder with three
pressures that make placement a decision rather than painting:

- Adjacency synergy: 11 rules where the same building is worth materially more
  or less depending on what it touches (Foot Traffic, Downwind, Coolant Draw…)
- Heat Index: industry and compute warm the planet; past 55 cooling demand and
  approval start to bite, past 88 the city is in crisis
- Crisis cards: 12 condition-triggered cards that pause the world and force a
  trade with no clean answer

Architecture:
- Zero build step, zero dependencies, native ES modules
- config/ is data only; core/ is a pure simulation (tickMonth(state) -> state,
  no DOM, no clock, no Math.random) so it runs headless under node --test
- Every stochastic decision draws from (seed, rollCount), so saves replay exactly
- Buildings are catalog entries: adding one makes it appear in the palette, on
  the map, and in the economy with no other code change
- Deterministic priority-ordered utility rationing: water plants and clinics stay
  lit, factories brown out first; water resolves after power so the cascade runs
  one way
- HEALTH / PRESSURE / EFFICIENCY telemetry behind ` or ?debug=1

77 tests covering placement rules, road connectivity, rationing order, synergy
caps, tick purity and determinism, crisis gating, directive streaks, and a
10-year fixture-district balance regression. Includes a guard against comparing
the clamped utility ratio to a value above 1 — a bug that made Grid Surge fire
every month.

Also: /gridlock route on Vercel, an isolated dependency-free CI job, and
npm run test:gridlock.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EjP7McK858rKp62kZajpi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants