Skip to content

Repository files navigation

🏛️ Statecraft · 庙堂

A pure text-and-numbers nation simulator — govern a fictional country, make real statecraft decisions, and watch interlocking systems chain-react.

No map. No graphics. Just you, your country, and one hard decision after another.

▶ Play now · 中文说明


What is this

Statecraft is a "Civilization for the spreadsheet-minded" — a nation-level government simulator that runs entirely on text and numbers. You take charge of one of 16 fictional countries and steer it year by year: set the budget, tune taxes, enact policy, weather crises, and manage the cascading consequences across economy, demographics, politics, diplomacy, and the environment.

Every country is invented, but its numbers are calibrated to a real-world archetype's order of magnitude — a manufacturing exporter, a debt-laden aging economy, a young petro-state, a tiny rich trade hub. The names, flags, and politicians are pure fiction; only the scale is real.

Play

https://culturesandbox.vercel.app — runs fully in the browser, offline-capable, saves to localStorage. Nothing to install.

Features

The core loop

  • 16 interlocking systems — economy, fiscal (debt dynamics: credit rating → interest rate), demographics, technology, society (inequality / health), politics (approval / unrest / stability / elections), military (coups), diplomacy, war, resources & climate, scoring.
  • A single growth equation at the hub — education, R&D, infrastructure, trade, and resources push growth; high taxes, aging, instability, sanctions, and climate stress drag it. Everything feeds one number, then consumes its output.
  • Deterministic + seeded — the RNG lives inside the save file, so reload is bit-identical.

Playability — the "is this actually fun" layer

  • Tenure mandate — every game opens with a country-fitting objective and a progress bar, so you always know what you're playing toward. Hints are a compass, not a GPS — collapsed by default.
  • Decision preview — drag a tax/spending slider and see the exact predicted deltas before you commit. Because the engine is deterministic, the preview is precise, not a guess.
  • Annual national focus — each year you commit to ONE mutually-exclusive strategic bet (grow the economy / stabilize politics / rearm / repair finances / invest in people / bet on tech). Every choice is a real tradeoff.
  • Dynamic crises — when debt, unrest, or coup risk enters a danger band, a counting-down crisis opens. Reverse it in time, or it fires its end-state.

Political figures — the game has people

  • Each country seeds 4–6 procedurally-generated fictional politicians (name, title, stance, personality, loyalty) — different every game.
  • Their loyalty drifts with how the country is going — a thriving leader keeps the cast onside; a failing one loses friends.
  • Push someone past their breaking point and they act: the military chief attempts a coup, the opposition leader forces a no-confidence vote, a magnate defects. The end screen names who betrayed you and who stayed loyal to the last.

A living world

  • All 16 countries run the full engine in parallel — NPCs make rational fiscal decisions, relations drift, and nations go to war with each other, not just you.
  • World events (pandemics, financial crises, tech leaps) strike every country at once and headline a news feed.

Narrative layer

  • Year reports, a milestone chronicle, and a per-run narrative — hand-written templates, no LLM. Your reign reads like a story, not a changelog.

Tech

  • TypeScript + Vite, zero-runtime-dependency single-page app. No backend. Saves to localStorage.
  • Architecture: pure-function engine + thin UI. A single GameState; each system is a step(state, ctx) → state reducer; advanceTurn composes them in a fixed order. 100% unit-testable, no DOM.
  • Seeded Mulberry32 RNG serialized inside the state → save / reload is deterministic by construction.
  • Vitest suite: determinism, save round-trip, fail/victory reachability, world-fuzz, and balance sims.

Run locally

npm install
npm run dev      # local dev server
npm run build    # tsc typecheck + static bundle
npm test         # Vitest

Project structure

src/
  engine/        pure simulation — reducers/ (economy, fiscal, politics, figures, crisis…),
                 advanceTurn, rng, save, world layer, *.test.ts
  data/          countries (16 fictional), characters, events, policies, mandates, focuses, scenarios
  ui/            DOM rendering (full re-render per turn)
  main.ts        assembly, save/load, country select
docs/            design contracts + build reports

Notes

All countries, flags, and political figures are entirely fictional. Starting numbers loosely track real-world magnitudes for gameplay believability, but nothing maps 1:1 to any real nation, government, or person.

Built as an experiment in compound engineering — an AI agent iterating overnight through brainstorm → plan → build → review → improve loops. See docs/ for the build reports.

About

Statecraft / 庙堂 — a pure text + numbers nation simulation game (TypeScript + Vite, no backend)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages