Spielerando

Dialogue System

A dialogue system is a web of lines. Each line moves on to the next or offers the player answers, and an answer can depend on what the game remembers, change it, or appear only once. The big risk is a soft lock, a dead end where every answer is hidden, so check for one before release.

Also called: Dialogue tree, Branching dialogue, Conversation system, Dialogue graph.

At a lantern-lit night market a child in a green coat talks to a fluffy moth shopkeeper, with speech bubbles showing the choices as pictures: a heart, a coin and a knife, and a key in the shopkeeper's reply.
Mothlamp Market, an invented night-market adventure. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Dialogue System" to my game.

What it should do: Dialogue lets the player talk to the world, and what they say and do changes what comes next.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> line
  line: Says a line
  ended: Ended
  stuck: Stuck
  choices: Waits for answer
  line --> line: next line
  line --> choices: answers on offer
  line --> ended: nothing follows
  line --> stuck: every answer hidden
  choices --> line: answer leads to a line
  choices --> choices: answer, more answers
  choices --> ended: answer ends the talk
  choices --> stuck: every answer hidden
  ended --> [*]
  stuck --> [*]
```

Use these starting values:
- historyLimit: 50

Watch out for these common mistakes:
- Every answer is hidden: Tell your AI to give every point with answers one that has no conditions, and to check that when the conversation loads.
- An answer offered once is the only way out: Tell your AI that an answer offered once does not count as the way out, and to check for that when the conversation loads.
- A line nobody can reach: Tell your AI to walk the conversation from the start when it loads and report what it did not reach.
- A link to a line that is gone: Tell your AI to check every link when the conversation loads. If a broken link is ever followed, the game should stop with one clear message that names the missing line, whether the player picked an answer or just moved on.
- A conversation that never ends: Tell your AI to check when the conversation loads that, from every line, links and answers with no conditions lead to an end.

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

Dialogue lets the player talk to the world, and what they say and do changes what comes next.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

next lineanswers on offernothing followsevery answer hiddenanswer leads to a lineanswer, more answersanswer ends the talkevery answer hiddenSays a lineEndedStuckWaits for answer
How it runs, as a diagram
  • Says a line → Says a line: next line
  • Says a line → Waits for answer: answers on offer
  • Says a line → Ended: nothing follows
  • Says a line → Stuck: every answer hidden
  • Waits for answer → Says a line: answer leads to a line
  • Waits for answer → Waits for answer: answer, more answers
  • Waits for answer → Ended: answer ends the talk
  • Waits for answer → Stuck: every answer hidden

Good starting values

ValueStart withWhat it changes
historyLimit50How many past lines the game keeps. More lets players look further back.

What usually goes wrong

Every answer is hidden

If all the answers at a point have conditions, the player can be left with nothing to pick and no way out. This is a soft lock. It depends on what the game remembers, so it is easy to miss when you test.

Fix: Tell your AI to give every point with answers one that has no conditions, and to check that when the conversation loads.

An answer offered once is the only way out

An answer offered once that loops back leaves the point empty on the second visit.

Fix: Tell your AI that an answer offered once does not count as the way out, and to check for that when the conversation loads.

A line nobody can reach

Writers add a line and forget to link it, and it never appears.

Fix: Tell your AI to walk the conversation from the start when it loads and report what it did not reach.

A link to a line that is gone

After an edit, an answer leads to a line that no longer exists, and the game fails at the moment the player picks it.

Fix: Tell your AI to check every link when the conversation loads. If a broken link is ever followed, the game should stop with one clear message that names the missing line, whether the player picked an answer or just moved on.

A conversation that never ends

Every answer leads on, but they all lead back, so the player always has something to pick and can never leave. Nothing looks broken, which makes this easy to miss.

Fix: Tell your AI to check when the conversation loads that, from every line, links and answers with no conditions lead to an end.

How to check it works

Common questions

how do you make a dialogue system

Store dialogue as data: each line has its text and either the next line or a list of answers. A small part of the game keeps track of where the conversation is and what it remembers, and offers only the answers whose conditions are met.

what do i tell my ai to add a dialogue system

Paste this: Add a dialogue system stored as data, where answers can depend on what the game remembers, and check when it loads that every link exists, every line can be reached, every set of answers has one with no conditions, and every line has a way to the end.

what is a soft lock in dialogue

A point where every answer is hidden, so the player can neither go on nor leave. Give every point with answers one without conditions, and check that when the conversation loads.

how do i remember what the player said

Save a short named note when an answer is picked, and let later answers need it or rule it out. Keep the names plain, so writers can read them.

Where it comes from

Earliest example we could find: Deadline (Marc Blank, Infocom) (1982). A text mystery in which the player has to question suspects. The player types a character's name followed by a question or demand, or uses ASK and TELL about a topic. Jimmy Maher describes earlier games' conversation as passwords or a plain TALK TO command. This is the oldest game located here with a described conversation model; ELIZA (1966) is older but is not a game.

  1. 1966 ELIZA (Joseph Weizenbaum), paper in Communications of the ACM 9(1): Precursor, not a game. A program that spots key words in typed input and builds a reply from rules attached to them. It is included as a precursor because game-writing histories, including Brent Ellison's, start with it. [ELIZA: A Computer Program For the Study of Natural Language Communication Between Man And Machine (Joseph Weizenbaum, CACM, January 1966)][Defining Dialogue Systems (Brent Ellison, Gamasutra/Game Developer, 2008)]
  2. 1982 Deadline (Marc Blank, Infocom): A text mystery in which the player has to question suspects. The player types a character's name followed by a question or demand, or uses ASK and TELL about a topic. Jimmy Maher describes earlier games' conversation as passwords or a plain TALK TO command. This is the oldest game located here with a described conversation model; ELIZA (1966) is older but is not a game. [Playing Deadline, Part 1 (Jimmy Maher, The Digital Antiquarian, 2012)][Playing Deadline, Part 4 (Jimmy Maher, The Digital Antiquarian, 2012)][Deadline (Jimmy Maher, The Digital Antiquarian, 2012)]
  3. 1983 Murder on the Zinderneuf (Jon Freeman and Paul Reiche III, Free Fall Associates; published by Electronic Arts): The manual has the player choose an approach to a suspect from a list that differs by detective, then choose whom to ask about. Suspects react differently to the role and approach. The player picks a manner and a topic, not lines of text. This is the oldest menu-based conversation located here. Reiche later reused the idea for Starflight. [Atari Game Manual: Murder On The Zinderneuf, full text (Internet Archive)][Free Fall, Part 2: Murder on the Zinderneuf (Jimmy Maher, The Digital Antiquarian, 2013)][Starflight (Jimmy Maher, The Digital Antiquarian, 2014)]
  4. 1989 Indiana Jones and the Last Crusade: The Graphic Adventure (Noah Falstein, Ron Gilbert, David Fox; Lucasfilm Games): The manual tells the player to choose what Indy says from phrases listed at the bottom of the screen, and warns that a poor choice can cause trouble. This is the earliest game located here where a primary source documents picking literal lines. Alexander Freed also lists Space Rogue (1989) as an example of a conversation tree, without describing it. [Indiana Jones and the Last Crusade: The Graphic Adventure, manual (Lucasfilm Games, 1989; scan at mocagh.org)][Branching Conversation Systems and the Working Writer, Part 1: Introduction (Alexander Freed, Game Developer, 2014)]
  5. 2005 Facade (Michael Mateas and Andrew Stern): A research work and interactive drama in which the player types free dialogue at any time. Its authors state the aim of moving past branching narrative. It marks a line of work that treats conversation as an AI problem instead of an authored tree. [Facade, authors' submission statement (Electronic Literature Collection, volume 2)][Defining Dialogue Systems (Brent Ellison, Gamasutra/Game Developer, 2008)]
  6. 2012 AI-driven Dynamic Dialog through Fuzzy Pattern Matching (Elan Ruskin, Valve, GDC 2012): A developer talk on matching facts about the world against a database of lines, so characters choose what to say without a hand-written script for each case. Used in Left 4 Dead and other Valve games. Here the player does not pick lines at all, so it shows dialogue selection as a rules system. [AI-driven Dynamic Dialog through Fuzzy Pattern Matching. Empower Your Writers! (GDC Vault)][GDC 2012 Talk on Dynamic Dialogue (Emily Short, 2012)]

CHOICE OF EARLIEST POINT: The answer depends on the definition. Conversation program of any kind: ELIZA, 1966, not a game. Conversation model in a game: Deadline, 1982. Menu choice of how to talk: Murder on the Zinderneuf, 1983. Picking literal lines: Indiana Jones and the Last Crusade, 1989, on primary evidence. Deadline was chosen as the earliest documented point because this is a library of game mechanics. A true dialogue tree, with branching structure documented, is not shown by any primary source read here: the Indy manual documents choosing lines, not the structure behind them. SOURCE STRENGTH: Primary texts were read for ELIZA, the Zinderneuf manual, the Indy manual, the Facade statement and the GDC session page. The ELIZA and Indy quotes were read from page images of the PDFs. Deadline rests on Jimmy Maher, a strong secondary source. Maher's Deadline posts date development to late 1981 and early 1982 and discuss its reception in 1982, but no exact release date was opened. The Zinderneuf manual copy has no copyright year, so 1983 comes from Maher. CLAIMS OF 'FIRST', RECORDED AS THE SOURCES' OWN: Maher says Deadline is 'the first adventure game in which conversation plays a prominent role'. Wikipedia says the first computer dialogue system was in ELIZA, and that the earliest known dialogue tree is described in Borges's 1941 story 'The Garden of Forking Paths'. Both statements are uncited there, and a story is not a game, so the Borges claim is not used. Ellison starts his history with ELIZA. DISPUTE, PORTOPIA: Wikipedia says The Portopia Serial Murder Case (1983) has a conversation system with branching dialogue choices, citing Retro Gamer (2011), Beep (1987) and Official Xbox Magazine (2015), none of which could be read. Hardcore Gaming 101 says the microcomputer versions used a text parser, that the Famicom port used a verb menu, and does not describe branching dialogue. So the Wikipedia claim is not confirmed for 1983, and Portopia is left out of the timeline. If confirmed, it would matter for the same period as Zinderneuf. GAPS: (1) Alexander Freed writes that such systems were pioneered in the 1980s and asks readers for more pre-1990 examples; his earliest listed game is Space Rogue (1989). The pre-1989 record of line-picking dialogue remains thin, and earlier cases may exist. (2) Zork II had conversational constructions before Deadline, which Maher calls awkward; these were not examined. (3) The origin of the term 'dialogue tree' was not found. (4) Later branching games (Fallout, Planescape: Torment and others) are named by Freed and Ellison, but no developer source on their systems was opened. (5) The origin of Mass Effect's dialogue wheel could not be documented. Ellison classifies its conversations as hub-and-spokes, and the BioWare interview found could not be opened. (6) The academic paper from FDG 2009 found by search could not be opened, so the academic side rests on the Facade authors' statement. RELATED POINTS NOT IN THE TIMELINE: Ultima IV (1985, per Maher) used a keyword-based pseudo-parser. Starflight (1986, per Maher) used conversation postures taken from Zinderneuf. Ellison (2008) is a useful trade-press taxonomy of non-branching, branching, hub-and-spokes, parser-driven and systemic dialogue. Emily Short (2016) argues that naive branching handles order-free information badly.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

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