Management and simulation games (tycoon, city builder lite, farm or restaurant management, colony sim, ecosystem or physics toys). Simulation architecture with a fixed tick separate from rendering, agents with needs and simple AI, resource flows and production chains, time controls (pause, ×1, ×3), feedback loops and stability, data-driven buildings and jobs, overlays and graphs that explain th...
Download skill (.zip) Files on GitHubSimulation game development
Core: set up a system, watch it run, understand why it behaves that way, and improve it.
Starter template
A playable starter for the game-scaffolding template is in assets/starter/. A town builder: houses, farms, shops and parks; a daily tick for food, jobs, taxes and upkeep; people who move in or leave; a status line that explains why; time controls (pause, x1, x3, x10); a population graph; a goal; and bankruptcy.
python3 <game-scaffolding>/scripts/scaffold.py my-game --title "My Game" --starter <this skill>/assets/starter
Controls: Tap the bar, then a tile; T changes speed. Keys: 1-4 build, 5/X bulldoze, arrows + Enter. Esc pauses. All numbers to tune are in src/config.js; the gameplay is in src/scenes/play.js.
A bot grew a town over 100+ days while the explanations changed.
Architecture
- Simulation tick (e.g. 10 Hz, or one tick per in-game minute) separate from rendering (game-render-loop-optimization). Time controls multiply ticks per second: pause / ×1 / ×3 / ×10, with a cap on ticks per frame.
- Pure state (plain objects, ECS-like arrays: game-architecture) so saving, testing and speeding up are easy.
- Data-driven buildings, recipes, jobs, needs (
data/buildings.json).
Building blocks (tested modules)
| Piece | Module |
|---|---|
| Money, costs, upkeep | game-economy (Wallet, cost curves, simulateEconomy for flows) |
| Production chains | crafting-system recipes as building inputs/outputs per tick |
| Agents moving around | pathfinding (flow fields to common destinations, A* for individuals), enemy-ai StateMachine for jobs |
| Agents’ needs | Small meters with decay; agents pick the most urgent need (utility scoring, enemy-ai chooseAction) |
| Many agents | game-spatial-partitioning, staggered thinking, game-object-pooling |
| Events / goals | quest-system for scenarios (“reach 100 citizens”) |
Making it understandable
- Explain the simulation: tooltips with why (“Unhappy: no food within 20 tiles”), overlays (heat maps for coverage, happiness, traffic), graphs of key numbers over time, and notifications for problems.
- Feedback loops need limits: positive loops (more people → more money → more people) capped by upkeep, space or demand; test stability by running ×10 speed for a long time (game-balance-testing).
- Start small: 3–5 building types, one resource chain, one goal.
UI and controls
Build menu with costs, grid placement with a ghost (green/red), select to inspect, time controls always visible. Touch: tap to select,
drag to pan, pinch to zoom (camera-system zoomAt), long-press for info.
Pitfalls
Opaque systems (“why is everyone leaving?”), runaway growth or collapse, the simulation slowing at scale (profile at 10×), and huge saves (store compact state; version it).