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

The demo is playing itself. Press a key or a button to take over.
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.
←→ walk, choose Space talk, go on, answer
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:
- A dead end: a line where there is nothing to pick and the conversation does not end.
- A lost line: a line no way leads to, so no player ever hears it.
- A loop with no way out: there is always something to pick, and every answer leads back, so it never ends.
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.
- 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.
- 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.
- Pick the arrow that walks away. The conversation ends. Draw an arrow from the lock to a box called "end".
- 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:
- Can a player get here from the start?
- Is there always something to pick here, or a way on, whatever the game remembers?
- From here, can a player always reach the end, whatever the game remembers?
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
- In the game above, draw the map, then cross out the arrow that walks away and walk it as a player without the key who asks first. You end up at the lock with nothing to pick: the same path the checker printed, found with a pencil.
- Take one conversation from your own game, have your AI write it as data with the text above, and paste that into the checker on this site. Every path it prints is a way a real player can go.
Read up
Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.
The check this lesson runs: its own example of a talk in which the questions run out, every kind of problem it reports, and the code and tests your AI can use.
Check Your Twine Story for Dead Ends and Broken Links
The same map for a story written in Twine: four mistakes planted in a small story, and the report the check on this site writes for them, finding by finding.
The walk for a whole story rather than one conversation: scenes, choices and flags, with endings nobody can reach and scenes that need a flag nothing sets.
The guide to a language for branching stories: choices that get used up inside loops, the fallback choice that saves a talk which runs out of options, and its warning about loose ends.
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.
In the game above, the gatekeeper's conversation always ends, whatever the player has done before. Which answer makes sure of that?
Next lesson Quest States in a Game: Not Taken, Active, Done or Failed
How useful was this page?
Nobody has rated this page yet.