Make a City Builder With AI: Keep the Town Explainable
A city builder lets you place buildings and watch a town grow, so start with a small grid, three buildings and one number that matters. Count people as totals, not as individuals, and make sure the game can explain why every number moved.
What is the hardest part of a city builder?
Answering the question "why?". Systems in this genre feed each other with a delay. People leave, income drops, repairs stop, more people leave. By the time a player notices, the cause lies a long way back, and a town that shrinks for no visible reason feels random.
Imagine a floating market town built on barges roped together. Houseboats fill up when fresh water is close by and work is nearby. A rain barrel reaches three squares. A bakery needs customers and flour. If half the houseboats stand empty, is that the water, the work or the rent?
The most valuable feature you can build is small and very unglamorous. Click on any building and read one sentence: "Empty, because no rain barrel is within three squares." Your AI can write that in minutes, and it turns a confusing game into a clear one. A second helper, a view that colours every square by water reach, shows the same answer at a glance.
How little can you start with?
A ten-by-ten grid, three buildings and a town that either grows or does not:
| Building | Needs | Gives |
|---|---|---|
| Houseboat | Water within three squares | Up to 4 residents |
| Rain barrel | Upkeep money | Water nearby |
| Bakery | At least 4 residents | Income |
That is a whole game. A barrel costs money, so you want few. Houseboats need to be near one. The bakery needs enough of them. Placing the next piece is already a small decision.
How does the town grow from there?
First comes the grid, placing buildings, and money. Then residents who arrive when needs are met. Add the why-sentence right after that, while there is still little to explain. Next, income and upkeep, so that a careless town slowly bleeds. Only then add a second need, like flour, then one event, like a storm that snaps a rope. Add speed controls before you think you need them.
Each new system should show up in the why-sentence on the day you add it. If it cannot be explained in one line, players will not understand it either.
What makes a town grind to a halt?
Simulating every citizen. It sounds wonderful: each person has a home, a job and a walk to work. It is also why such games crawl once the town gets big, and why bugs become impossible to follow. Your AI will build it if you ask, and it will look great for the first hundred people.
Count totals for each building instead. If you want a lively town, add a few little walkers as pure decoration. They need not be going anywhere. Nobody will ever know.
Paste this to your AI
Build a small city builder: a 10 by 10 grid, three building types, money and a population number. Seen from above, and plain squares are fine.
Start with a state machine in a Mermaid diagram of the town's loop: place, pay, needs met or not, people arrive or leave, income, upkeep, new demand. Show which number feeds which, and flag any spiral with no way back, such as having no money to repair what earns the money. Build from that.
Count people as totals per building, never one by one.
Every building gets a panel that says in one plain sentence why it is doing what it does, with the numbers. When the town grows or shrinks, trace it to the buildings and rules behind it. If you cannot trace a change, say you do not know why it happened. Then simulate 50 days with a sensible plan and show me the numbers.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Ask why. Click any empty building. The sentence should tell you what to do next.
- Go broke on purpose. Can you climb out, or is the town doomed with no warning?
- Build only houses. You should see clearly what goes wrong, and why.
- Fill the grid. The game should stay smooth with every square in use.
- Remove one barrel. Watch what changes, then ask your AI to explain each step of it.