Xanadu Brancheschoice-based stories, gamebooks, Twine and ink projects, and text adventures

Continuity and State Tracking

State Tracking for a Forty-Passage Story Without Spreadsheets

By the Xanadu Branches editors / / 5 min read

Short answer. A branching story can manage persistent choices without a complicated spreadsheet if its author defines a small set of variables, documents their permitted values and records where each variable changes. For a forty-passage story, a compact state reference and an AI-assisted consistency review can expose contradictory conditions, forgotten updates and choices that have no meaningful consequences.

Key points

  • Every persistent variable needs a defined purpose, starting value and permitted range.
  • Record where variables change and where their values affect available choices.
  • Use AI to compare conditions and identify inconsistencies, not to invent game logic.
  • A forty-passage story benefits from a compact state reference organized by variable.

Design the State Before Writing Every Passage

Choice based game writing becomes difficult when every decision creates another piece of information that the story must remember. A player might promise a companion something, collect a key, expose a secret or gain the trust of a faction. If these facts are scattered across forty passages, the author can lose track of which later scenes should acknowledge them. State tracking provides a consistent way to preserve decisions across branches.

Start by listing facts that can affect future passages. Separate persistent facts from temporary narrative details. A key that remains in the player's inventory needs a variable. A character briefly noticing the rain probably does not. Every variable should have a reason to exist, ideally because it changes a later choice, dialogue option, outcome or description.

  • Inventory: does the player possess a required object?
  • Relationship: has trust with a character increased or decreased?
  • Knowledge: has the player discovered a particular fact?
  • Progress: has a major objective been completed?

Choose a Small and Predictable Variable System

A forty-passage story rarely needs a variable for every individual choice. Use Boolean variables for facts with two states, such as whether the player has found a letter. Use numeric variables for quantities that can change across several passages, such as trust or suspicion. Use a small set of clearly named values when a character or faction can occupy several distinct states.

For example, a mystery might use has_letter, trust_mara and knows_identity. The first and third variables are Boolean. The second might range from zero to three. Its starting value is one, and relevant interactions can increase or decrease it. A documented range prevents an accidental value of seven from appearing because two passages apply the same increase.

  • Boolean: true or false.
  • Numeric: a defined minimum, maximum and starting value.
  • Enumerated: one value from a documented list of states.
  • Avoid duplicate variables that represent the same underlying fact.

Map Changes and Consequences Across the Story

The important part of state tracking is the relationship between a variable change and its later consequence. A player finding a letter might set has_letter to true. A later conversation could reveal an additional dialogue choice when that value is true. A final passage might use the same information to determine whether the protagonist can prove an accusation.

For example, consider a four-passage sequence within the larger story. Passage 08 introduces a locked room. Passage 12 offers a key. Passage 19 checks has_key before displaying the entrance choice. Passage 34 uses the same variable to determine whether a final piece of evidence is available. This creates a traceable chain from acquisition to consequence.

  • Passage 08: introduces the locked room.
  • Passage 12: sets has_key to true.
  • Passage 19: checks has_key for access.
  • Passage 34: checks has_key for an ending-related consequence.

Maintain a Compact State Reference

A spreadsheet is useful for large projects, but it is not essential for a manageable story. A structured text document can serve as a state reference that sits beside the manuscript. Give every variable a name, type, starting value, permitted range, update locations and read locations. Include a short explanation of the narrative fact it represents. This makes the information understandable even when the writer returns to the project after several weeks.

A practical entry might read: trust_mara; numeric; starts at 1; range 0 to 3; updated in passages 06, 14 and 27; checked in passages 18 and 35; purpose: determines whether Mara shares information and provides assistance in the final sequence. This compact description is easier to maintain than repeatedly searching through the entire manuscript.

  • Variable name and type.
  • Starting value and permitted range.
  • Passages that modify the value.
  • Passages that read the value.
  • Narrative consequences and intended meaning.

Use AI for a Targeted State Consistency Review

A language model can help compare a variable reference with passage descriptions and conditional expressions. Give it the state definitions, the relevant passage excerpts and the rules for updating each value. Ask it to identify variables used without initialization, conditions that refer to undefined names, updates that exceed permitted ranges and decisions that never appear to affect subsequent content.

A useful prompt is: "Review this branching story state reference and the accompanying passages. Identify every variable that is read before initialization, every update that conflicts with its permitted type or range, and every condition that appears inconsistent with the documented variable meaning. Return the variable name, passage identifier, relevant expression and reason for concern. Do not propose new variables or rewrite the narrative." This keeps the task focused on consistency.

  • Ask for evidence tied to passage identifiers.
  • Provide the complete variable definitions.
  • Separate definite contradictions from possible design concerns.
  • Do not treat every unused variable as an error without considering planned future content.

A Branch Map Makes State Dependencies Visible

A state-aware Branch Map adds variable information to the ordinary passage graph. Nodes show where a fact is introduced, edges show the choices that carry the player forward, and annotations identify updates or conditions. This is particularly useful when several routes converge on one passage but arrive with different player histories.

For example, Passage 12 sets has_key to true. An AI prompt asking whether every route to Passage 19 handles the key condition can help expose an incomplete dependency. The suggestion to add a missing check can be kept if it matches the intended rules. A suggestion to give the key to a player who never acquired it should be discarded. The author decides what the game permits.

  • Passage 12: has_key becomes true; update documented.
  • Passage 19: checks has_key; conditional route retained.
  • Passage 23: alternate entrance; no key required.
  • Passage 34: uses has_key for final evidence; dependency retained.
  • Proposed automatic key acquisition: discarded because it bypasses the intended choice.

Keep the System Maintainable as Branches Grow

State systems become fragile when variables are renamed without updating their references or when several variables begin representing overlapping facts. Before adding a new variable, ask whether an existing one can express the same information. When a variable is retired, remove or revise its dependent conditions. Document changes as part of passage editing so the state reference does not become a second, outdated version of the story.

For gamebook writing tips that translate well to digital projects, think in terms of player-visible consequences. A variable should matter because it changes something the player can encounter, understand or influence. Before drafting the next ten passages, list the variables that the new scenes introduce, modify and depend on, then update the state reference alongside the manuscript.

Questions readers ask

How many variables should a forty-passage story have?

There is no fixed ideal number. Start with the smallest set needed to represent persistent player knowledge, inventory, relationships and progress. Add variables only when a distinct piece of information has a meaningful consequence.

When is a Boolean variable preferable to a numeric score?

Use a Boolean when a fact has only two meaningful states, such as whether a player found an object. Use a numeric score when several degrees of change influence later decisions or outcomes.

What happens when two branches merge?

The merged passage inherits the player's current state, so its conditions must accommodate every legitimate route into it. Document which variables can differ between incoming paths and what the merged scene should do with those differences.

Can state tracking work in a printed gamebook?

Yes. Inventory lists, numbered status values and written instructions can preserve persistent decisions. Keep the rules visible and make sure players can update their records without interpreting ambiguous instructions.

Related reading