Make a Tower Defense Game With AI: Paths and Balance
Make a Tower Defense Game With AI: Paths and Balance
Tower defense is buildable from a description, but it is the most demanding arcade genre to get right. Name the path, the towers, the enemy waves and the money rules, and Zugo returns a playable 2D browser game in about a minute. The build costs 6 credits, and balancing it takes several edits at 3 each.
The reason is interaction. In a shooter, one number affects one thing. Here, tower cost affects how many towers you own, which affects how far enemies get, which affects how much money you earn, which affects tower count again. One prompt compresses that loop badly, so plan on tuning.
Why is this genre harder to generate than an arcade game?
Because everything is a system rather than a value. A game where the player's income comes from killing the enemies that their income is supposed to stop is a feedback loop, and feedback loops break in both directions.
Too strong and the player never loses, money piles up and the game ends by boredom. Too weak and the first leak becomes a collapse, since a leak means less money, which means fewer towers, which means more leaks. Both failures appear in first builds, and both are fixable by asking for different numbers.
The build itself arrives complete: a path, placeable towers, enemies that walk it, a health pool that drains, and a wave counter. It is booted in a sandbox before it reaches you, so a broken build is reported rather than delivered. The sandbox will not tell you the game is unbalanced, because an unbalanced game runs perfectly.
What does the prompt need to define?
Six things, and skipping any one of them leaves the generator guessing at the part that determines whether the game is fair.
| Element | Weak wording | Wording that works |
|---|---|---|
| Path | "enemies walk to the base" | "one fixed path from the left edge to the base, drawn on a grid" |
| Build spots | "you place towers" | "towers go on any grid tile that is not on the path" |
| Towers | "different towers" | "two types at first: fast and short range, slow and long range" |
| Money | left unsaid | "start with enough for three towers, earn a small amount per kill" |
| Waves | left unsaid | "a wave every twenty seconds, each with more and tougher enemies" |
| Losing | left unsaid | "twenty lives, each escaped enemy costs one, zero ends the game" |
The path is the single most important line. A generated maze with branching routes turns into a game nobody can read, while one clear route makes every placement decision visible. Start with one path and add complexity later if the game needs it.
Say what to leave out too. "No tower upgrades yet, no boss waves, no menu" gets you a version simple enough to judge. General prompt advice is in how to write a good prompt.
How do you describe the map so it plays well?
In terms of a grid, always. Free placement anywhere on the screen sounds more flexible and plays worse, because towers overlap, coverage becomes impossible to judge and the player cannot tell why a spot did not work.
Ask for a visible grid, a path that runs through it, and placement restricted to tiles that are not on the path. Then ask for the tower's range to be shown as a circle while placing. Those two details do more for playability than any amount of art direction.
Length matters as well. A path that crosses the whole screen with two or three turns gives towers a reason to sit at corners, where enemies stay in range longer. A short straight line makes every position equivalent, and equivalent positions mean no decisions.
If you want difficulty from geography rather than numbers, ask for one section of the path with no buildable tiles beside it. Players will notice the gap and plan around it.
How do you get the economy to balance?
By fixing the ratio between what a tower costs and what a wave pays. That ratio is the game, and it is easier to state as a goal than as numbers.
Tell the builder what you want to be true: "clearing a wave without leaks should pay for roughly one new basic tower". That sentence gives a target the generated numbers can be checked against, and it is far more useful than asking for a tower to cost some specific amount.
Then play three waves and adjust one side only. If money is tight, raise the reward. If money piles up, raise tower cost. Changing both at once leaves you unable to tell which change did the work, and this genre punishes that more than most.
Watch the late game too. A schedule that stays flat after wave ten means the player has already won and is waiting for the game to notice. Ask for enemy health to keep climbing so runs end in a real defeat.
What usually breaks in the first build?
Four things, in a fairly reliable order.
Range is invisible. Players place towers blind and blame the towers. Ask for a range circle on hover and on placement.
Enemies leak silently. If an escaped enemy just disappears, the player never learns what went wrong. Ask for a clear signal and a visible life counter.
Selling and moving are missing. Without them, one bad early placement ruins a whole run. A sell button that refunds part of the cost is a single edit and saves the game.
The wave gap is wrong. No gap between waves and there is no time to build, which is where the fun of the genre actually lives. Ask for a short pause and an optional button to call the next wave early.
Each of those is one edit at 3 credits. Phrasing for that kind of change is covered in how to edit after generation.
What does the whole thing cost?
More edits than a simple arcade game, and the credits reflect that.
| Action | Credits |
|---|---|
| Build the game | 6 |
| One edit | 3 |
| Hi-Fi build | 12 |
| Hi-Fi edit | 6 |
Expect a build plus eight to ten edits before it feels balanced, because balance is discovered by playing rather than specified in advance. Pro is $25 a month for 200 credits, roughly 33 builds or 66 edits, and Business is $99 a month for 800 credits.
Free grants 5 credits, less than one build, so this is not a genre you can complete on the free tier. Cloning a game template from the gallery costs no credits and is a reasonable way to see how a finished arcade build is put together first.
How many tower types should the first version have?
Two. It is tempting to ask for six, and six is exactly how you end up with a game where four of them are never used.
Two types with clearly opposed strengths, one fast and short ranged, one slow and long ranged, already create a placement puzzle. Add a third only when you can say what problem it solves that the first two cannot, such as slowing a group or hitting several enemies at once.
Upgrades are better than new types for a while. Letting a tower be upgraded twice adds depth without adding anything new to learn, and it gives the player something to spend late-game money on.
The same restraint applies to enemies. One normal, one fast and weak, one slow and armoured is a complete cast for a first version.
Where are the limits worth knowing?
Games here are 2D and browser based, which suits tower defense well, though a 3D presentation is not available at any prompt length.
Saved progress, unlocked maps and a shared leaderboard all need a database, meaning a Supabase connection and work layered on top of the game rather than a chat message. It is worth deciding early whether the game needs any of that, since a local best score covers most cases.
The deeper limit is honest and specific to this genre: intricate balance is not something a single description can deliver, because balance is a property of play. Very specific logic gets built through a series of edits, which is the intended workflow rather than a workaround. Your code exports to GitHub, and on a large commercial title Zugo does not replace a development team. A genre with far fewer moving parts, if you want a gentler start, is a snake game.
What is a sensible build order?
One path, one tower type, one enemy type, twenty lives. Play it. That version is boring on purpose, and it tells you whether the placement and range feel right, which nothing else will.
Then add the second tower type, then the money tuning, then the wave schedule, then quality of life: range circles, selling, an early call button. Content last, systems first, because content built on a broken system has to be redone.
Publish to an address like your-defense.zugo.run and give it to someone who plays this genre, since they will find the exploit in two minutes. Start at zugo.dev.