Spielerando

Generate a dungeon where every key lies before its lock

Random dungeons sound great until the generator puts the blue key behind the blue door. Here is a way to build the rooms and hand out locks and keys in an order that always leaves a way through, no matter what the dice say, with a check you can run afterwards.

Why this works

Fixing a broken dungeon after the dice have fallen is guesswork. If you build it so a key can only land where the player can already stand when they need it, the dungeon cannot fail, and a separate walk-through confirms it.

When not to use it

Skip it for a hand-made dungeon where you want a deliberate loop, such as a key the player must come back for. Also skip it when the player may bring keys from earlier runs; then plain placement with a check afterwards is simpler.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • A diagram of every state
  • 51 lines of example code with 3 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Generate a dungeon where every key lies before its lock" (read_entry dungeon-keys-always-placed-before-locks) in my game. Build it step by step, and show me how you checked that it works.

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