Ability Gates
An ability gate is a door, wall or gap that opens only for a player who owns the right ability. A failed try bumps a counter, and after a few bumps the gate says what is missing. A good try starts the opening, and an open gate stays open. A world check finds gates that can never open.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Ability Gates" to my game.
What it should do: Gates turn what the player can do into a map of where they can go. A place seen early becomes a reason to come back later, and every new ability opens up something that was always there.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> locked
locked: Locked
ready: Ready to open
opening: Opening
open: Open
locked --> ready: ability gained
ready --> locked: ability lost
ready --> opening: player tries
ready --> open: tries, opens at once
opening --> open: opening is done
open --> [*]
```
Use these starting values:
- openTime: 0.6 s
- hintAfter: 2 tries
Watch out for these common mistakes:
- The ability sits behind its own gate: Tell your AI: play the world forward from the start, opening every gate you can and collecting every ability you can reach. List whatever is left over, and fix it before the game ships.
- A misspelled ability can never be owned: Tell your AI: when you check the world, treat a gate that asks for an unknown ability as a problem and report it by name.
- Walking through a half-open gate: Tell your AI: the player may pass only once the gate is fully open, and not while it is still opening.
- Losing the ability closes an open gate: Tell your AI: an open gate stays open for good. The ability is checked once, at the moment of the try.
- A second try restarts the opening: Tell your AI: ignore every try while the gate is opening or open.
- The hint asks for what the player already has: Tell your AI: recompute the hint whenever the player gains or loses an ability, and list only what is still missing.
- A broken clock skips or freezes the opening: Tell your AI: count only time that is a real number and not below zero, and treat anything else as no time at all.
- A gate that asks for nothing: Tell your AI: a gate that asks for nothing opens for everyone.
Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
What it does
Gates turn what the player can do into a map of where they can go. A place seen early becomes a reason to come back later, and every new ability opens up something that was always there.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- Locked → Ready to open: ability gained
- Ready to open → Locked: ability lost
- Ready to open → Opening: player tries
- Ready to open → Open: tries, opens at once
- Opening → Open: opening is done
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| openTime | 0.6 s | How long the gate takes to open after a good try. Under half a second feels like a switch, and over two seconds the player starts to wonder if anything happened. Zero opens it at once. |
| hintAfter | 2 tries | How many failed tries it takes before the gate shows what is missing. At 1 the gate gives everything away at once, and at 10 a stuck player gets frustrated before any help comes. |
What usually goes wrong
The ability sits behind its own gate
The wall needs the smash ability, and the smash ability is hidden behind that wall. The game can never be finished, and nobody notices until a player is stuck for good.
Fix: Tell your AI: play the world forward from the start, opening every gate you can and collecting every ability you can reach. List whatever is left over, and fix it before the game ships.
A misspelled ability can never be owned
A gate asks for 'smahs' instead of 'smash'. No ability has that name, so the gate never opens, and nothing says why.
Fix: Tell your AI: when you check the world, treat a gate that asks for an unknown ability as a problem and report it by name.
Walking through a half-open gate
The gate is sliding open, and the player slips through the gap, or is already counted as through, before it is really open.
Fix: Tell your AI: the player may pass only once the gate is fully open, and not while it is still opening.
Losing the ability closes an open gate
The player opens a gate with a temporary power, the power runs out, and the gate slams shut. Anything the player carried through is now cut off from the way back.
Fix: Tell your AI: an open gate stays open for good. The ability is checked once, at the moment of the try.
A second try restarts the opening
The player presses the button again while the gate is opening, and the timer starts over. A player who mashes the button keeps the gate shut.
Fix: Tell your AI: ignore every try while the gate is opening or open.
The hint asks for what the player already has
The gate shows a hint, the player finds the missing ability, and the hint still lists it. The player thinks the pickup did not count.
Fix: Tell your AI: recompute the hint whenever the player gains or loses an ability, and list only what is still missing.
A broken clock skips or freezes the opening
A pause, a hiccup or a bad time value makes a gate open in one jump, or run backwards and never finish.
Fix: Tell your AI: count only time that is a real number and not below zero, and treat anything else as no time at all.
A gate that asks for nothing
A gate with an empty list of abilities is treated as impossible, because nobody owns 'nothing'. It never opens.
Fix: Tell your AI: a gate that asks for nothing opens for everyone.
How to check it works
- The player owns nothing and the gate asks for smash. the player tries the gate: the try is refused, the gate stays shut, one bump is counted and no hint is shown yet.
- The player owns smash and the opening takes 0.6 seconds. the player tries the gate: the gate starts opening with 0.6 seconds left.
- A gate has started opening. 0.5 seconds pass, and then 0.1 more: the player cannot pass after 0.5 seconds and can pass after 0.6.
- A gate asks for smash and swim, the player owns smash, and the hint comes after 2 tries. the player tries twice: the first try shows no hint, and the second shows only swim.
- A gate asks for smash and swim, and needs both. the player owns only smash and tries, then gets swim and tries again: the first try is refused and the second opens the gate.
- A gate that wants smash or swim, and either will do. the player owns only swim and tries: the gate opens.
- A gate is open. the player loses the ability that opened it: the gate is still open and the player can still pass.
- A gate that asks for no ability at all. a player with nothing tries it: the gate opens.
- A gate is opening. the player loses the ability and 0.7 seconds pass: the gate still finishes and is open.
- The opening time is set to zero. the player tries with the right ability: the gate is open right away.
- A world where the smash ability lies behind a wall that needs smash. you run the world check: it reports that smash and the wall can never be reached.
- A world where one ability lies in the open and the others lie behind gates that build on it. you run the world check: it reports nothing.
Works well with
- Double Jump: A jump that reaches a high ledge is the classic gate key. Check the heights with your numbers, so the gate is really out of reach without the ability and really within reach with it. Give the player the ability first, then place the gate that needs it somewhere they have already been.
- Skill Tree: If a tree can refund a rank, a gate may need an ability the player no longer has. An open gate stays open, but a closed one can become a dead end. Decide whether abilities come from the tree or from the world, and check the world only against abilities the player can really get.
Common questions
how do i make a door that opens with an ability
Give the door a list of the abilities it asks for and check the player's list when they try it. If the player has them, open the door and keep it open for good. Tell your AI to open it only on a try, never on every frame.
how do i avoid getting the player stuck behind a locked gate
Play the world forward from the start: open every gate you can, take every ability you can reach, and repeat. Whatever is left over is a dead end. Ask your AI to run this check whenever you change the map.
should a locked door tell the player what it needs
Not at the first bump, because discovering it is part of the fun. After two failed tries show what is missing, so a stuck player gets help without having to guess.
what do i tell my ai to add gates that need abilities
Paste this: Add gates that open only when the player owns the needed abilities. A gate may need all of its abilities or just one. After a good try it opens in about 0.6 seconds, stays open for good, and counts as passable only when fully open. After two failed tries it names what is missing. Then check the whole map for gates that can never be opened.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 25 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
Your AI gets the code
Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it