Spielerando

Make a Roguelike With AI That Stays Fair Every Run

A roguelike is a game where you push through randomly built floors, lose your run when you die, and start again. To make one with AI, build a three-floor run you can finish in five minutes, and give every run a number so the same run can be played twice.

Where is the real difficulty?

Random is the easy word. Fair is the hard one. Players forgive dying to their own greed. They do not forgive a floor with no way down, or a run that ends before they have touched a key.

Imagine a salvage diver sinking through a flooded clock tower, with each floor put together at random from a set of rooms. Over thousands of runs, nobody can look at every floor by hand. So the game has to keep two promises by itself: the stairs down can always be reached, and no eel starts right next to you.

The second difficulty is the bug that only happens once. "On one run the door was missing" is useless to your AI if nobody can get that run back. The fix is a run number. The game uses one number to make all its random choices, so the same number always builds the same tower. Programmers call this a seed. Show it on the death screen, and a vague complaint turns into "run 48213, floor 2".

What is the smallest run worth playing?

Three floors, one enemy and three finds.

The finds matter more than anything else here. For the diver they could be:

  • a harpoon that goes through two eels in a line
  • a lamp that shows what waits in the next room
  • a bellows that buys one extra breath when you run out

Each of these changes what you do next. "Plus one damage" would not. Use a loot table to decide how often each turns up, and turn-based combat if you want time to think, which also makes the whole thing far easier to build.

How does the run grow from there?

  1. One room made by hand, with moving and one eel. Learn what a good room feels like.
  2. Eight more rooms by hand. The game picks from these and does not invent rooms from nothing.
  3. Stairs, three floors, and an end to the run.
  4. Death, a short summary, and an instant restart.
  5. The run number, shown on screen and typed in to replay.
  6. The three finds, then a small inventory if you need one.

Not sure which kind of game you want? A dungeon crawler has a fixed, mapped place and you keep your progress.

What is the mistake that ends these projects?

Mistaking more for different. Your AI can write two hundred items in a minute. If nearly all of them mean "a bit more damage", every run plays the same, and you now own two hundred things to balance.

Ten finds that change each other beat that easily. Ask what happens when the lamp meets the harpoon. Pairs like that are what make someone start another run.

Paste this to your AI

Build a small roguelike I can finish in five minutes: three floors, one enemy type, three items. Turn-based on a grid, plain shapes only.

Start with a diagram, not code: draw the run as a state machine in a Mermaid diagram (new floor, player move, enemy move, find, stairs, death, summary, new run). Walk through it and show me that every state has a way out. Then build from it.

Make floors by joining rooms from a small hand-made set. One run number decides everything random, shown on screen, and I can type it in to replay that run.

Two rules for every floor: the stairs down can be reached from the start, and no enemy begins next to the player.

Do not just tell me these rules hold. Give me the run numbers you looked at and what you found on each floor. If you only looked at a few, say how many. If you cannot tell, say you do not know.

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

How to check it worked

  • Replay your last death. Type in the run number. You should get the same rooms, with the same enemies in the same places.
  • Play ten quick runs. Note any floor with no way down, and any hit you took before you could move.
  • Ignore a find. If you would make the same moves with or without it, it is a number and not an idea.
  • Time the restart. Die on floor 1 and count the seconds until you are moving again. It should feel instant.

Last updated: 2026-11-02