How to make an RPG with AI
Ask for an RPG and you get stats, gear, a shop and a quest log, all shallow. Ask for one good fight instead, and build outwards from it.
Jump to a section
Ask for one combat encounter and nothing else. No shop, no world map, no quest log. An RPG is the genre where a model will write you every system in a single answer, and the reason that fails is not the code quality. It is that none of those systems has been played yet, so nobody knows which of them is boring.
A fight, then levels, then gear, then a second enemy, then a story. In that order, each step playable before the next arrives. A quest log is the last thing you build, not the first. It is the part that looks most like an RPG and the part that contributes least to whether one is any good.
Four steps before you write a single quest#
It writes one turn based fight with three choices a turn, two enemies that behave differently, and nothing else at all.
If you win the same way every time, the choices are decoration. That is a fault in the fight, and it cannot be patched by a level up.
The point of a level is that an old fight feels different. If it does not, the number you raised was the wrong number.
One at a time, playing after each. The world and the writing go on top of something that already works.
Build a turn based RPG combat encounter as ONE self-contained .html
file. No frameworks and no images. Draw it on a canvas.
SCOPE: one encounter and nothing else. No shop, no world map, no
quest log, no saving, no character creation. If a system is not
needed to make this single fight interesting, leave it out.
THE FIGHT: the player against two enemies. Both sides have health,
and the player also has a small pool of energy. Turns alternate.
DECISIONS: every player turn offers exactly three choices. A reliable
attack. A stronger attack that spends energy. A guard that halves
incoming damage for the round and gives energy back. Each of the
three has to be the right answer in some situation.
ENEMIES: the two behave differently. One hits for a small amount
every turn. The other spends a turn winding up and then hits hard,
and it says on screen that it is winding up, a turn in advance.
NUMBERS: a fight from full health should end in three to five player
turns. Keep damage figures near each other so the player can predict
the fight, with only a small random spread on top.
FEEDBACK: health bars slide towards their new value instead of
jumping. Damage appears as a number that rises and fades. Both of
those animate over real time.
READABILITY: before a choice is taken, show in words roughly what it
will do. A player who cannot plan is only pressing buttons.
END: a win screen and a loss screen, each with the turn count and a
button to fight again.
PHONE: the three choices are large tap targets. Include
canvas { touch-action: none; } so tapping cannot scroll the page.
Drive both animations from the number of seconds that elapsed since
the previous frame, and never let that number exceed 0.05. Put
health, energy, every damage figure, the random spread and the wind
up delay in one CONFIG object at the top, each with a comment.
The CONFIG numbers are what you are meant to change, and you should expect to change them many times. The SCOPE paragraph is what you must not change. Delete it and the next answer arrives with a shop, an inventory and a world map, none of which you can judge until the fight is good.
Why an RPG punishes a big first prompt#
Every genre rewards a small first build. This one punishes a large one unusually hard, because an RPG is made of systems that only mean something through each other. A level matters because it changes a fight. A sword matters because it changes a tactic. Written at the same time as the fight, both are guesses.
There is a second cost that shows up a day later. Ten systems written at once leave you unable to say what is wrong. The fight is dull, but is that the damage numbers, the enemy behaviour, the gear that arrived too early, or the fact that levelling gives a percentage nobody can feel? You now have to pull the thing apart to find out.
Built in order, each addition is tested against a fight you already understand. You know how the encounter felt yesterday. If today's change does not alter that feeling, the change was wrong and you can say so in one sentence.
The numbers for a first combat loop#
Combat feel is mostly arithmetic, and the arithmetic is not hard. Three things decide whether a fight reads as a decision or as a wait. How long it lasts, how predictable the damage is, and whether the best choice changes from turn to turn.
| The number | Aim for | What a bad value feels like |
|---|---|---|
| Turns to finish a fight | Three to five from full health | Two is a formality. Ten is admin. |
| Damage spread | A narrow band around one figure | Wide spread makes planning pointless |
| Choices per turn | Three | Two is a coin flip. Six is a menu. |
| Best choice | Changes with the situation | One option always wins and the rest are scenery |
| Enemy damage | A loss takes roughly twice as long as a win | Unlosable, or over before the second turn |
Describe what the fight felt like and name the row. The model can see the config, and you are the only one who played it.
The last row is the one people skip. A fight you cannot lose has no decisions in it, because nothing is at stake in choosing wrongly. Set enemy damage so a careless run loses, then make sure a careful run wins. The gap between those two is the game.
Equipment that changes how combat plays#
Ask for equipment and you will be given a sword with higher damage, a shield with higher defence and a helmet with higher health. None of that changes anything. The fight plays identically with bigger figures on screen, which is why a first RPG build often feels flat exactly when more gear arrives.
- Ask for a tactic, not a number. A blade that costs health to swing. Boots that let you act twice every third turn. A charm that makes guarding refund more energy. Each one makes a different choice the correct one.
- One item at a time, then fight again. If the encounter plays the same way with the item as without it, the item does nothing and should be cut rather than tuned.
- Keep the slots few. A weapon and one trinket is enough for a long time. Six slots is six places for a number to hide.
- Never let gear replace the decision. If the strongest item makes one choice always correct, the fight is over as a thinking exercise, however long it still takes.
Levelling has the same trap and the same fix. A level that adds a few points of health is invisible. A level that lets the player hold more energy, or act before a fast enemy, is felt on the next turn. Ask for the effect you want to notice, and let the model pick the arithmetic.
Why the quest log comes last#
A quest log is a list, a tracker, a state machine and a save format. It is the most code for the least play in the whole genre. Worse, it hardens everything underneath it. Once a quest says defeat three wolves, changing what a wolf is means changing the quest too.
Story is cheap at the end and expensive at the start. Names, reasons and dialogue can be rewritten in minutes once the systems are settled, and rewriting them costs nothing because nothing depends on them. Write them first and you will spend a week protecting prose from mechanical changes it was never designed for.
If you want the world and the writing to lead, that is a different genre and a better fit for it exists. An adventure game is built around state and conversation from the first prompt, and it does not need combat at all.
🐉RPGs written by AI
Common questions#
Can AI make an RPG?
It can write every part of one, which is the problem. The code arrives faster than your ability to judge it. Build one encounter, play it until you can say exactly why it is or is not fun, and add the next system only then.
What should the first prompt actually ask for?
One fight, three choices a turn, two enemies with different behaviour, and a refusal to add anything else. That is small enough to read, play and tune in an evening, and everything an RPG later becomes is built on top of it.
Why does my combat feel boring even though it works?
Almost always because one choice is correct every turn. Check that each option wins in some situation and loses in another. If the strong attack is never worth skipping, the other two are scenery and the fight is a wait.
How many turns should a fight last?
Three to five player turns from full health, for a first encounter. Shorter and no decision has consequences. Longer and the player is repeating a plan they already made, which is the feeling people describe as grinding.
Should I add random damage?
A little. A narrow spread keeps fights from feeling mechanical. A wide one makes planning pointless, because the player cannot tell whether a choice was bad or merely unlucky, and that is the one thing combat has to be clear about.
When do I add a world map and towns?
After combat, levelling, equipment and a second enemy type all hold up. A map is a way of getting between fights, so it has nothing to carry until the fights are worth getting to. It is also the easiest thing to add late.
Where to go next#
Once the encounter is one you would replay, put it up. It gets a page recording the model and the prompt behind it, and other people fighting it will find the choice you thought was balanced.
The general method is in how to make a game with AI. If you want permanent progress between attempts instead of a saved party, the roguelike guide covers what carries over and what does not. Wording for common faults is in the prompt guide, and the RPGs here are worth a fight before you start.
Built something? Put it on Agent Games.
Publishing takes a file and a minute. Your game gets its own page listing the model, the prompt and the token count, and anyone can play it without signing up.
Read next