Spielerando

Make a Tower Defense With AI: Real Choices, Not Just Stats

In a tower defense game, you stop waves of enemies from crossing the map by placing things that attack along their route. Build one path, two towers with different jobs and five waves, and keep every wave in a table you can edit.

What is really hard about this genre?

The towers are easy. The choices are hard.

Picture a fishing harbour where icebergs drift in on the tide. You place foghorns, which slow the ice, and heat lamps, which melt it. Each wave is a question, and each placement is your answer. If "build more heat lamps" answers every question, the game is a waiting room with a nice view.

So give towers different jobs. Do not make stronger and weaker copies of one idea. A slow tower and a hard-hitting tower need each other, and that need is where the thinking happens.

What should each wave teach?

Treat waves as lessons. For the harbour, five are enough:

Wave What comes What it teaches
1 Five slow floes Lamps melt ice
2 Eight faster floes One lamp is not enough
3 One huge berg Big ice needs time under heat
4 Twelve tiny, quick floes Foghorns earn their place
5 A mix of all three Now choose for yourself

If you cannot say what a wave teaches, cut it. Keeping this as a table also means you can rebalance the game by changing numbers, with no coding.

In which order do the pieces go in?

  1. A path, and one iceberg that follows it to the harbour.
  2. Harbour lives that go down when ice arrives.
  3. One tower with a plain targeting rule, such as "the ice closest to the harbour".
  4. Money for each melted floe, and a price for each tower.
  5. The wave table.
  6. The second tower.
  7. A speed-up button, because waiting is this genre's quiet enemy.
  8. Upgrades between levels, perhaps as a small skill tree, once one level is good.

Where do these projects go wrong?

In the habit of fixing balance by adding health. Wave 4 feels too easy, so the ice gets tougher. Wave 5 feels too easy, so it gets tougher again. Soon every enemy takes ages to melt, the choice of tower stops mattering, and the game turns into watching a number shrink. When a wave is too easy, change what it asks of the player.

The other trap is building anywhere. If towers can go on any square, players can wall off the path, and now the ice needs to think about what to do when no route exists. Fixed build spots remove that whole problem, so start with them.

Paste this to your AI

I want a small tower defense game: one path across the screen, a base at the end with 10 lives, two towers with different jobs (one slows, one hits hard) and five waves. Towers go on fixed spots only.

Do not write the game yet. Draw one wave as a state machine in a Mermaid diagram: build phase, wave starts, enemies walk, towers fire, enemy dies or reaches the base, wave ends, next wave, win or lose. Go through it and tell me what happens when the last enemy dies at the same moment the base falls.

Build from that diagram. Keep all waves in one table I can edit: how many, what kind, how fast, how far apart.

Then simulate. Play every wave with only the first tower, only the second, and a mix, and show me each result. If one tower wins alone, tell me. Without a run to show, say you do not know whether it is balanced.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

How to check it worked

  • Use one tower only. Try to win with a single type. If you can, the other tower is decoration.
  • Build nothing. Start a wave and sit back. You should lose, quickly and clearly.
  • Watch who gets shot. Place a tower and follow its target. You should be able to predict its next choice.
  • Spend it all early. You should still be able to recover in the next wave, or see why you cannot.
  • Fast-forward a wave. The result should match normal speed, with no ice slipping past a tower.
  • Edit wave 3. Change the table. The game should follow with no other edit.

Last updated: 2026-11-02