Symmetry-Aware LLM-Driven Generation and Repair of Interactive Fiction Graphs in Twine/Twee
Marcin Puchalski, Bożena Woźna-Szcześniak · Symmetry · 2026
We present a hybrid system that combines large language models (LLMs) with formal graph-analytic methods to generate and automatically repair interactive fiction (IF) stories written in the Twine/Twee format. We chronologically describe the practical challenges encountered when attempting to produce fully playable branching narratives using contemporary state-of-the-art LLMs, including missing passages, trap-like cycles without exits, dead-end passages, narrative discontinuities, incorrect use of Twine macro commands, and inconsistent handling of story variables. To address these limitations, we deliberately abandon all macro- and variable-based logic and instead encode story state directly within passage names through structured, token-based naming. We formalize symmetry and asymmetry in the resulting narrative graphs: symmetrical convergence occurs when multiple branches with compatible states merge into a common passage, whereas asymmetry reveals incorrect or logically inconsistent merging of divergent states (for example, entering a scene in which an item or companion is present via paths where they were never acquired or met). We propose algorithms to detect naming-based asymmetries, cycles, unreachable endings, and structurally defective branches, and we integrate these diagnostics into a repair loop that prompts the LLM to rewrite missing or inconsistent parts of the story. Experiments with several LLM backends indicate that this approach can yield structurally robust and locally coherent interactive stories by reducing state inconsistencies and structural defects. Beyond the specific case of Twine, we argue that symmetry/asymmetry analysis offers a powerful lens for evaluating and correcting AI-generated narrative graphs in general.