PolyCity a54f04ed5f Auto-Build advisor + resilient simulation loop
- New advisor button (toolbar, purple wand): one click per planning pass
  * Genesis: founds a town from a blank map (main street + zone bands)
  * Keeps power ahead of demand (wind/solar/coal by deficit size)
  * BFS road spurs to reach orphaned zoned land
  * Stamps new districts when demand is high and empty plots run out
  * Places the weakest service coverage; parks/plazas for land value
  * Never spends below an emergency reserve; recomputes power per action
- Simulation no longer dies when rAF throttles: interval watchdog
  compensates only after 3s of total frame silence
- preserveDrawingBuffer now opt-in via ?cap=1 (software-GL perf)
- Smoke test drives via game API, prefers headless_shell binary,
  tolerates stalled screenshots; engine suite at 51 assertions
2026-08-23 03:28:17 +00:00
2026-08-22 19:30:46 +00:00

🏙️ PolyCity — 3D City Builder

PolyCity is a full-featured, free, open-source city-building simulation that runs entirely in your browser. Zone districts, wire up power, keep citizens happy, fight fires, balance the budget — and grow a tiny island outpost into a glittering megalopolis.

Built with Three.js + Vite, zero runtime dependencies beyond the engine, procedural graphics (no asset downloads), and a simulation modeled on the classics.

gameplay

Features

🗺️ Procedural islands Every new map is unique — winding rivers, beaches, forests
🏘️ RCI zoning Residential / commercial / industrial with demand-driven growth
Power grid Coal, solar & wind plants; brownouts when demand exceeds supply; wind turbines get +50 % on the coast
📈 Land value & upgrades Parks, plazas, services and waterfronts raise land value; buildings grow through 3 density tiers
🚓 City services Police, fire stations, hospitals and schools shape happiness and value
🔥 Disasters Pollution-driven fires spread and are contained by fire coverage; mature cities face tornadoes that flatten whole streets (toggle in settings)
💰 Budget & taxes Live tax slider, itemized income/upkeep ledger, debt warnings
🚗 Traffic Animated cars flow along your road network
🌗 Day/night cycle Windows light up as the sun sets
🪄 Auto-Build advisor One click founds a town, then keeps power ahead of demand, connects zoned land, adds districts and services where coverage lags — always keeping an emergency reserve
🎯 Goals & milestones From Outpost to Megalopolis, with an onboarding quest list
💾 Saves Autosave, 3 manual slots, JSON export/import
📱 Touch support Paint with one finger, pinch-zoom, two-finger rotate
🔌 PWA Installable, offline-capable via service worker

🎮 Controls

Action Input
Use tool / paint Left-drag or one finger
Orbit camera Right-drag or two fingers
Pan Middle-drag, or WASD / arrow keys (Shift = faster)
Zoom Mouse wheel / pinch
Pause · speed Space · 1 2 3
Tools Q inspect · B bulldoze · R road · Z/X/C zones
Close / cancel Esc · Help: H

How to play in 30 seconds

  1. Drag an L-shaped road from the coast inland.
  2. Paint homes beside it, then some shops and industry.
  3. Drop a coal plant anywhere — power is a city-wide grid.
  4. Press ▶▶ and watch the neighborhood fill in.
  5. Add police/fire/parks to push land value past the upgrade thresholds.

🚀 Run it locally

pnpm install
pnpm dev        # dev server → http://localhost:5173

📦 Production build

pnpm build      # outputs static site to dist/
pnpm preview    # serve dist/ locally

The build is fully static and relative-path based — drop dist/ on any host.

🌍 Publish it

GitHub Pages — this repo ships .github/workflows/deploy.yml; push to main and enable Pages (Settings → Pages → Source: GitHub Actions).

Netlify / Vercel / Cloudflare Pages — import the repo, build command pnpm build, publish directory dist. A ready-made netlify.toml is included.

itch.io — zip the contents of dist/ (keep index.html at the zip root), upload as an HTML5 game, check sharedarraybuffer is not needed and any resolution; the game auto-fits.

🧪 Tests

node tests/engine.mjs   # 40-assertion simulation suite (pure Node)
node tests/soak.mjs     # 40-year economy/growth/power soak test
node tests/smoke.mjs    # headless-browser end-to-end run
node tests/capture.mjs  # renders promo screenshots into shots/

🛠️ Tech notes

  • One shared MeshStandardMaterial + instanced meshes draw the entire city in a handful of draw calls; geometry is merged & vertex-colored at load time.
  • Simulation runs on typed arrays (64×64 tiles) with monthly ticks decoupled from rendering; speeds pause / 1× / 2× / 3×.
  • Adaptive resolution keeps frame times sane on weak GPUs.
  • All audio is synthesized WebAudio — no assets, no tracking, no network calls.

License

MIT — build, remix, ship it. 🏗️

S
Description
PolyCity — full-featured 3D city-builder (Three.js + Vite), playable in the browser
Readme MIT
7.2 MiB
Languages
JavaScript 91%
CSS 7.1%
HTML 1.8%
Shell 0.1%