Spielerando

Make a Text Adventure With AI That Understands Players

A text adventure is a game you play by reading and typing, so have your AI keep the whole world in a plain list of rooms, objects and facts. Build three rooms with one locked door, then teach the game the many ways people will say the same thing.

What makes typing so hard to get right?

A player can type anything at all. Say you are writing about a night porter in a sleeping hotel who has until dawn to find a missing guest. You put a brass key on the front desk and expect "take key". Players type "grab the key", "pick up brass key", "pocket it", "look under desk" and "ask the cat". Every "I don't understand" pulls them out of the story.

So the game has two jobs. It has to understand what was typed, and it has to remember the world: is the lift door open, is the key in the porter's pocket, has the boiler been lit?

Keep those facts apart from the writing. If "a brass key lies on the desk" is part of the room's description, the room will keep saying so after the key is gone.

Should players type, or click?

Typing gives surprise and the joy of trying something odd, and it takes far more work. Clicking is simpler and works well on phones. If you prefer clicks, Twine is an open-source tool for interactive stories that produces web pages, and the dialogue system blueprint covers much of the same ground.

Be careful with a live AI inside the game. It may invent a fifth floor or spoil your ending.

What should you build, and in what order?

Start with a lobby, a lift and a boiler room. One key, one locked door, one clue in the guest book, one ending.

  1. The list: rooms, exits, objects, and where each object starts.
  2. Moving, looking, taking and using.
  3. Three ways of saying each action.
  4. Failure messages that help. "The lift needs a key" beats "You can't do that".
  5. A hint command that nudges without solving.
  6. The ending, and only then more story.

What kills a text adventure?

A dead end the player cannot see. The porter drops the only key down the lift shaft in minute three, and the game politely carries on for an hour with no way to win. Quests that do not get stuck goes deeper.

The close second is a puzzle that only makes sense to its author. For every puzzle, the game's own text must point to the answer somewhere.

Paste this to your AI

Build a text adventure where I type commands, running in a browser: three rooms, one locked door, one key, one clue, one ending.

First draw the play loop as a state machine in a Mermaid diagram: show text, wait for a command, understood or not, change the world, show the result, ending. Check that every state leads on, and only then build from it.

Keep all facts in one file: rooms, exits, objects, where each object is now, what has happened. Build room text from those facts, so it never mentions a thing I have taken. Understand three ways of saying each action.

Model the game as those facts, each command as a step with what it needs and changes, and rules such as "the ending can always still be reached". Go through every path with TLA+ and the TLC model checker, or with get_recipe story-model-check if Spielerando is connected. If a rule breaks, list the exact commands in order. I do not need to see the model.

For every puzzle, quote the line in the game that points to the answer. If there is none, or my story has not settled something, say you do not know and ask me.

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

Your AI treats every command as one step, and a program tries all the orders no player would think of. You only see the failing list: take key, go to lift, drop key, and the ending is gone. That recipe arrives over an MCP connection, set up with a free Google or e-mail sign-in, and nothing of yours gets read. The story pages help with the writing.

How to check it worked

  • Say it wrong on purpose. Try "grab", "get", "pick up" and "pocket", then pure nonsense. You should always get a useful reply.
  • Take it and look. Take the key and look around. The room must stop mentioning it.
  • Throw away what you need. Try to lose the key somewhere awful. You should still be able to win.
  • Watch someone type. Write down everything that fails, and say nothing. That list is your next job.

Sources

Last updated: 2026-11-02