I grew up on Age of Empires, Sid Meier's Civilization, and Rise of Nations. The thing that hooked me was never the graphics — it was the systems. You set a few rules in motion and a whole world spills out of them: economies, rivalries, alliances, betrayals.
Years later I watched OpenAI's hide-and-seek multi-agent video (writeup), where agents that were only rewarded for hiding and seeking invented tools and counter-strategies nobody coded — ramps, box-surfing, fort-building. Emergent behavior from simple pressure. That broke something open for me.
So I asked a smaller question: forget winning a game — what if AI agents just had to live in a society together? Would they behave like us? Hold grudges? Gossip? Make peace because they're tired of fighting?
That became Tiny Civilization — a browser sim where 2–8 agents with distinct personalities live on a small island, gathering, building, trading, stealing, gossiping, holding grudges, making peace, and remembering it all across lives.
👉 ** Live demo** — runs keyless in "instinct mode," or plug in a key for LLM minds.
The whole thing — every line — was built with Claude Code, using the Fable model, right before Fable retired. It felt fitting to send a storytelling model off by having it build a world full of little stories.
The first design decision was the hardest. Two obvious options, both bad:
So I split the brain in two:
| Layer | Decides | Cadence | Cost |
|---|---|---|---|
| LLM mind | |||
Strategy (gather /build /trade /befriend /aggress /reconcile /defend ), per-neighbor stances, an inner thought, and all dialogue |
|||
| ~every 15 sim-days | ~150 calls / 1,000 days | ||
| Utility engine | |||
| Each day's concrete action — eat, sleep, gather, steal, attack, gift, trade, make peace | every tick | free, local |
The LLM declares intent — "aggress against Kai, he raided my base" — and that biases the utility scores for the next two weeks. The body runs on instinct (hunger, energy, storms); the mind sets direction. This is the trick that makes it both affordable and alive.
When a run ends, each agent's life is distilled into memory lines:
Stored in localStorage
, keyed by agent name, and injected into next run's prompts. Agents start referencing past lives in dialogue, pre-emptively paying reparations to remembered enemies, trusting remembered allies — sometimes to their own ruin.
This is the part I'm proudest of, and it's pure childhood-strategy-game energy: you can't balance a society by vibes. So the workflow was:
runTick
powers the browser, the tests, and a batch runner.npm run experiment -- --runs 30 --days 1000 --seed 1
runs 30 reproducible lifetimes and spits out a win-rate/score table. Every balance change landed with a before/after table. (Example: a Hermit rebalance moved one agent from 0/30 wins to 9–11/30 Change a dial in constants.ts
→ run the experiment → read the table. That was the entire loop.
Running the same island over and over, with memory on, produced a coherent arc:
The recurring lesson: every time I patched one form of conflict, the agents found the next-cheapest one. Massacres → wars → theft → litigation. Exactly like us.
TypeScript, React, Zustand, Vite, Recharts. Default mind is z.ai GLM, but any OpenAI-compatible provider works per-agent — so you can literally pit Claude vs GLM vs Gemini in the same village and watch model-vs-model diplomacy. Keys never touch the browser (server-side proxy), and an adaptive-pacing controller learns each key's real rate ceiling.
**Try it:** [https://multiagentciv.netlify.app/](https://multiagentciv.netlify.app/)
**Code:** [https://github.com/dhrupo/multi-agent-civilization](https://github.com/dhrupo/multi-agent-civilization)
If you played the same strategy games I did, I think you'll feel right at home watching this thing run.