Spielerando

Lesson 3 of 14A story the game can check9 minFree

Map Your Dialogue Tree: Dead Ends, Lost Lines and Loops

A pixel art beekeeper talks to a gatekeeper in grey before a shut wooden gate. The gatekeeper's bubble shows a lock; answer bubbles over the beekeeper show a question mark and an arrow that walks away. After asking, wasps appear in her bubble and the question mark is gone. While the beekeeper fetches a key from under a bush, three dots wait in her bubble. Back with her, a key answer appears and the gate opens.

The blueprint's own example conversation, line by line. Asking why is offered once, then it is gone. The key answer is hidden until the game remembers that you have the key. Leaving is always on offer, so this conversation can never leave you with nothing to pick.

Try it: Talk without the key: only the question mark and the arrow are there. Ask, and on the way back to the lock the question mark is gone. Fetch the key from the bush on the left, walk back to the gatekeeper until her bubble gets a blue frame, and talk again: now the key is one of the answers, and it opens the gate.

Keys: ←→ walk, choose Space talk, go on, answer

This little game runs this blueprint's tested code in your browser. Nothing you press is sent anywhere. Its code on GitHub.

The game above is the playable demo of our blueprint Dialogue System. It runs that blueprint's tested code in your browser.

The conversation in the game above has three lines and three answers, and it can never leave you standing with nothing to pick. You cannot see that by reading it from top to bottom. You see it when you draw it as a map, one box for every line and one arrow for every answer, and walk every way through it. This lesson has you draw that map from the game above and walk it by hand, then give the walk to your AI and a checker.

Also in this lesson 4 things to read up on 3 questions to check yourself

The idea

A conversation, or any branching story, is not a text. It is places and the ways between them: a line the gatekeeper says, and the answers that lead from it to other lines or to the end. Three things can only go wrong on such a map:

Reading finds none of them. A script is one path through the map, the one its writer had in mind, and every line on it reads fine. The trouble sits on the paths the writer did not walk: a player without the key, or one who asked first. You find them by walking every way through the map, with everything the game may remember.

How it works

Take a sheet of paper and play the game above. Draw as you go.

  1. Talk without the key. The gatekeeper's bubble shows a lock: the gate is shut. That is your first box. Over the beekeeper float two answers, a question mark and an arrow that walks away. Draw two arrows out of the lock box.
  2. Pick the question mark. Her bubble shows wasps: the reason. This line has no answers, only a small blinking mark to go on. Draw a box for it and an arrow from it back to the lock, then press on. Back at the lock, the question mark is gone: it is offered once in each conversation. Write "once" on its arrow.
  3. Pick the arrow that walks away. The conversation ends. Draw an arrow from the lock to a box called "end".
  4. Fetch the key from the bush on the left; the slot at the top right fills. Walk back and talk again. In a new conversation the question mark is back, and there is a third answer, the key. It leads to a third line, an arrow through the gate, and on to the end. Write "needs the key" on that arrow.

Your map has three boxes, the end, and five arrows. Now walk it, box by box, and ask three questions of each one:

The wasps box passes all three. So does the lock, and look at why. The question mark is used up after one pick. The key needs the key. Only the arrow that walks away has no condition and is never used up. That one arrow is the whole reason this conversation always ends.

By hand this works for three boxes. A conversation in your own game may have dozens, and every "once" and every fact an answer needs can double what there is to walk. That is a job for a checker: the checker on this site runs our dialogue check in your browser on a conversation your AI writes down as data.

What goes wrong

The shortcut is a script written from top to bottom, the way a scene in a film is written:

Gatekeeper: The gate is shut.
You: Why is it shut?
Gatekeeper: (wasps)
You: I have the key.
Gatekeeper: Then go through.

Every line of it is fine, and it is one path: the player who asks first and happens to have the key. The other paths are not wrong in it, they are missing. The AI builds what the script says, and the answer that walks away, the one with no condition, is the line nobody wrote.

We ran the dialogue check from this site on the conversation above with that answer taken out. It printed:

dead-end: Dead end at "greet": it does not end the conversation and no option can be picked. "Why is it shut?" was already used; "I have the key." is hidden by flags.
  Path: greet > [Why is it shut?] reason > greet

In the check's words, "greet" is the line with the lock and "reason" the one with the wasps. Read the path: ask why, hear the reason, and you are back at the lock with nothing to pick. A player who follows the script, minus the key, is stuck for good.

Then we let the question be asked again and again, with no "once". The dead end is gone, and the quieter failure takes its place: no-way-out: From "greet" the conversation can never end, although options remain. There is always something to pick, and for a player without the key it always leads back to the lock.

The guide to a language for interactive stories in the reading list warns about the same trap: a choice there can be picked once unless it is marked otherwise, so a loop runs out of choices. Its answer is a hidden choice the game takes by itself when no other is left. The game above keeps its way out in plain sight instead.

Tell your AI

Draw my conversation as a map and walk it with a checker before you change any line.

The conversation is [name it, or say which file it is in]. If you cannot see it, ask me to paste it.

1. Write it as data in the form of the dialogue-tree-check recipe from spielerando.com: one entry per line, with who says it, and for each answer the line it leads to or that it ends the conversation, what it needs, what it sets and whether it can be picked only once. A line without answers says which line comes next or that the conversation ends there. List the facts that come from outside the conversation, such as an item in the bag.
2. Draw that data as a Mermaid diagram: one box per line, one arrow per answer, with what it needs and "once" written on the arrow. Show me the diagram.
3. Walk every way through it with the recipe's code, or code of your own that does the same: from the start, once for every combination of the outside facts. A state is the line, what the game remembers and which answers are used up.
4. Show me what the checker printed, word for word: every line nobody can reach, every line where nothing can be picked and the conversation does not end, every loop that can never end, and every answer that leads to a line that does not exist, each with its path from the start.
5. For each problem, suggest one fix and wait for me to pick. After the fix, run the checker again and show me the new output.

Do not tell me the conversation works. Show me the checker's output.

Try it

Read up

Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.

Check yourself: three questions

Each answer is checked and explained at once. The questions are part of the quiz, so they count for your Game Coder IQ like any other.

Question 1 of 3Easy

In the game above, the gatekeeper's conversation always ends, whatever the player has done before. Which answer makes sure of that?

All questions of this course · The quiz and the Game Coder IQ

Next lesson Quest States in a Game: Not Taken, Active, Done or Failed

How useful was this page?

Nobody has rated this page yet.

One click, no account. It tells us which pages to make better next.

Last updated: 2026-11-27