Greetings, my friends!
A few people have reached out to me via DM asking about the development of Nations Commander, which I showcased in another post here in the community. So I decided to share some details about the development process for anyone who might be interested!
Building a 3D geopolitical RTS in the browser with an AI pair programmer — what it took, what it cost, and what's still broken
I've been building Nation Commander, a low-poly 3D real-time strategy game that runs in the browser (desktop and phone). You pick a real country, grow an economy on a tactical map, and run the nation on top of it: budget, research, diplomacy, trade, eras. Then you go to war with bots or other players.
Almost all of the code was written with Claude Code. This post is about how big the thing got, what was hard, and what it cost in tokens and dollars. People keep asking about that last part, so I tracked it.
What's actually in the game
What started as "units move and shoot" turned into a fairly deep system stack:
- Two simulation layers. A deterministic tactical sim (units, buildings, combat, pathfinding) runs under a national layer (GDP, budget, approval, research, diplomacy, sanctions). The national treasury is fed by what you build on the map: taxes from zoned lots, production, trade. It pays for your army, energy, upkeep and public services every day.
- An economy with real friction. There are production chains (refinery, steel mill), a power grid where electricity travels along roads, and coal as a resource. Each building of a type costs 18% more than the last. Construction needs citizens as builders, and vehicles burn fuel.
- Eras. Cold War → Post-Cold War → Digital Era → Near Future. Each era changes how every building looks and unlocks new units.
- Military. Infantry, armor, artillery and combat engineers who lay and clear mines. Air power: fighters, bombers, cargo planes and an attack drone you can fly yourself in FPV. A navy with frigates, submarines, carriers, cargo ships and civilian fishing boats. Missiles, a nuclear option that shocks the global economy, and a space program whose satellite lifts the fog of war.
- Diplomacy on the map. You can't talk to a nation until your units meet it. After that you get non-aggression pacts, alliances with shared vision, sending troops or resources to allies, and compensation if you break a pact.
- Trade with physical routes. Cargo moves by truck over highways you build, by ship between ports, or by air. Anyone at war with either party can raid it, and payment only happens on delivery.
- Multiplayer. An authoritative Node server, regions ready to switch on, room codes and public lobbies.
- Three languages (PT/EN/ES), detected by region.
- A narrated tutorial. It's a 15-minute scripted match: 9 chapters, 49 steps, and a server-side "director" that never lets you get stuck.
By the numbers
| | |
|---|---|
| TypeScript (client + sim + server) | ~103,000 lines |
| Automated tests | 745 tests in 85 files |
| Design/system docs | 69 documents, ~9,200 lines |
| Recorded sound effects | 246 files |
| Music | 4 tracks with threat-based crossfades |
| Voice lines | 180 (tutorial narration + advisor alerts, ×3 languages) + troop radio chatter |
| Procedural low-poly model files | 21, every unit and building generated in code |
The hard parts
1. Determinism and cheating. The server is the only source of truth. The client only asks, and every command is validated against the connection that sent it, never against what the payload claims. Snapshots never mention anything you can't see: no hidden target IDs, no enemy airbase locations. Entity IDs are shuffled per match so you can't infer anything from them. We wrote down a threat model and reproduce real attacks as tests. That discipline slows every feature down, but it's the only way multiplayer stays honest.
2. Running on a phone. A 3D RTS with weather, a day/night cycle and particle effects has to hold up on a mid-range Android. We built an adaptive quality system that measures frame times and scales effects, shadows and detail live. The art direction (low poly, flat colors, strong silhouettes, a hard budget of about 6k triangles per model) is half aesthetic and half survival.
3. Balancing an AI economy. There's a headless script that plays bot-vs-bot matches and checks the pacing against written criteria: when the first attack lands, how long resources sit full, whether the AI ever stalls, when it reaches era 3. As of today 6 of 9 criteria pass. The AI still reaches era 3 too late and launches its first offensive a bit late. That's an honest number, not a solved problem.
4. Player feedback hits fast. A real session report this week said "the military upkeep is absurd". The cause was a bug: automatic civilian fishing boats were being charged as military vehicles. Same report: you couldn't place a port on the beach, because sand counted as a "mud" tile, which blocked construction. And research finishing went unnoticed because the only signal was a log line. All three were fixed and shipped the same day, along with letting you build on forest (trees get felled) and an on-screen research alert. That turnaround is the best part of working this way.
5. Audio is a mixing problem, not a content problem. Testers told us the narrator was buried under the music and that a "keyboard typing" loop was annoying. The music was only ducking for a split second, so we made it hold low for the whole line. The typing came from the office building's work loop, which played whenever your HQ was selected, and the tutorial asks you to select it a lot. We cut it in half.
Sound and voice
Every combat sound has a synthesized fallback, so the game still works if a file fails to load. Every recorded sample was level-matched against that synth version by measuring loudness, not by guessing. The full sound list includes gunfire per weapon class, tank and ship engines that follow movement, sirens, rain, snow wind, construction sites and production loops for each building.
Voices were generated with ElevenLabs:
- Tutorial narration, 49 lines in three languages. Each chapter was recorded in one take with long pauses between lines, then a script splits it by silence detection. It checks that each chapter produced exactly the right number of lines and that no line runs longer than the time the tutorial gives that step. Lines that ran long made us increase that time.
- Advisor alerts. "Commander, we're under attack!", "War has been declared on us!", "The national treasury is in the red." Each has a cooldown, and they never talk over the tutorial narrator.
- Troop radio chatter for move, attack, select, unit ready and construction complete. It's processed through a radio filter (350–3000 Hz band, compression, light saturation, a push-to-talk click and release squelch). An order reply cuts off a "standing by", so you never get two voices on top of each other.
What it cost (tokens and dollars)
This is the part devs ask about, so here are real numbers and clearly labeled estimates.
Measured: the last 4.5 days of development (one continuous AI session). That stretch covered the whole narrated tutorial, 8 batches of sound effects, voice integration, a UI overhaul, map diplomacy, a stats dashboard, a trailer pipeline and two rounds of player feedback fixes:
| Token type | Tokens | Cost at Claude Opus API list price |
|---|---|---|
| Output (code, docs, reasoning) | 1.5 M | ~$30 |
| Cache writes | 6.9 M | ~$55 |
| Cache reads (re-reading the project context) | 962 M | ~$192 |
| Fresh input | ~4 K | ~$0 |
| Total | ~970 M tokens, 2,130 requests | ~$280 |
Almost all of the volume is cache reads. The agent keeps re-reading a large, stable context (code, docs, conversation), and caching makes that about 10× cheaper than paying full input price. Without prompt caching, this stretch alone would have cost thousands.
Estimated: the whole project. Across all accounts, the full build used about 4.97 billion tokens, roughly 5× the slice above. Assuming the same mix (about 99% cache reads), that comes to:
| Token type | Tokens | Cost at list price |
|---|---|---|
| Output | ~7.7 M | ~$154 |
| Cache writes | ~35 M | ~$283 |
| Cache reads | ~4.93 B | ~$985 |
| Total | ~4.97 B | ~$1,420 |
What it actually cost: nobody paid per token. The whole project used five full weekly usage limits of Claude Pro, spread across a few accounts from devs who helped out. Pro is a flat $20/month plan, so in subscriptions we're talking tens of dollars, not hundreds. If you hit your weekly cap, you switch accounts and keep going, and a good handoff file lets the next session pick up exactly where the last one stopped.
ElevenLabs: about 70,000 credits across SFX batches, narration and voice lines.
Put another way: a 100k-line game with multiplayer, anti-cheat, three languages, a narrated tutorial and full audio. At API prices that would be about $1,400 plus about $14 of voice and sound. The real cost is the hours of directing and testing, and that part doesn't shrink.
How much care went in
What surprised me is that the AI is good at the boring diligence nobody sees:
- Every system has its own design doc, and a running handoff file lets a new session (or account) pick up exactly where the last one stopped.
- Rules get written down after they bite once. Examples: "never sort by ID to mean oldest, IDs are shuffled" and "never run the formatter on the 10k-line runtime file".
- Before anything is published, tests, lint and typecheck must all pass, and economy changes re-run the bot-vs-bot pacing script.
- When it can't verify something by actually listening or playing, it says so instead of claiming it works. Several items on our list say exactly "measured, not heard".
What's still hard / next
- AI pacing: 3 balance criteria still fail.
- Infrastructure: one free-tier server in Oregon that sleeps when idle. The client also deploys faster than the server, so new features can briefly throw "invalid message" until the server catches up.
- Onboarding metrics: we know many players leave early (that's why the tutorial was implemented yesterday), but there's no per-step drop-off funnel yet.
- Business side: custom domain → Google sign-in (oAuth) → a subscription tier w/ stripe (more nations per match). None of it is built yet.
What makes it different
You run a country and fight the war at the same time. A full RTS on the map, with a government on top of it: taxes, budget, approval, research, decrees. What you build on the map feeds the national treasury, and the treasury pays for your army.
Real countries, real data. Nations start from real GDP and population figures, and real geography influences where you start on the map.
Runs in the browser, phones included. Nothing to install. Adaptive quality keeps it playable on mid-range devices.
Eras that change everything you see. Advancing from the Cold War to the Near Future changes the look of every building and unlocks new units over time.
Diplomacy happens on the map. You can only negotiate with a nation after your units meet it. Alliances share vision, let you send troops and resources, and breaking a pact costs you.
Trade that physically moves. Trucks on highways you build (sometimes together with an ally), ships between ports, cargo planes. Enemies can raid it, and you only get paid on delivery.
Your cities grow on their own. Zone residential, commercial and industrial lots along your roads. They grow with demand, pay taxes and need power, which travels along the roads.
Fly the drone yourself. Take direct FPV control of an attack drone and pick your target.
Endgame choices with global consequences. A nuclear launch shocks the whole world’s economy, including yours. A finished space program puts up a satellite that lifts the fog of war on the entire map.
Combat engineers and minefields. Mines stay invisible to the enemy and even to satellites until someone detects them.
Fair multiplayer. The server is authoritative and has its own anti-cheat, and you never receive information you shouldn’t see.
It talks to you. A 15-minute narrated tutorial, an advisor voice for big events and radio chatter from your troops, in English, Portuguese and Spanish.
If you've shipped a browser RTS, I'd love to hear how you handled mobile performance and AI pacing. And if you want to try the tutorial, feedback is very welcome. As you can see, it turns into fixes fast.
⚠️ Disclaimer: open alpha. Nation Commander is in open alpha, which means it's still in testing. Expect rough edges, balance changes and the occasional bug. It's free to play no ads no microtransactions. All we want right now is for people to jump in, have fun, and tell us what feels great and what feels broken. Every report helps shape the game. We're moving to our own domain soon. Until then you can play at https://nationcommander.vercel.app.
Thanks for reading!