Files
polycity/README.md
T
PolyCity 209d8efdf5 Professional City Advisor rewrite + wall-clock simulation
Advisor v2:
- Phased policy (founding/village/town/city) with scaling reserves
- Maximal-coverage siting: services score candidate spots by count of
  previously-uncovered developed buildings in radius
- RCI gradient genesis: homes north, commerce buffering, industry
  set back 2 extra tiles; per-tile separation filters on new districts
- District placement scored by runway length and distance from housing
- Power sized to PROJECTED demand (history-smoothed growth x14 months)
  with tech diversity cap (<=3 per type) and home-distance scoring
- Collector roads: cluster orphaned plots, one straight L-path
- Budget discipline: one big-ticket purchase max per pass

Simulation core:
- City clock now advances in wall time (tick-guard bounded), decoupled
  from render fps — slow devices no longer freeze the city
- Smoke test polls in game-time (monthIndex targets), not wall time
2026-08-23 04:59:48 +00:00

4.4 KiB
Raw Blame History

🏙️ 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
🪄 City Advisor (Auto-Build) Phased planning policy: founds towns with an RCI gradient, projects power demand ~14 months ahead with tech diversity, connects orphaned plots with collector roads, sites services by maximal marginal coverage, keeps industry set back from homes — one big purchase per pass, emergency reserve always intact
🎯 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. 🏗️