Manuscript Offprint
arXiv:2611.01954Towards Self-Evolving Narrative Systems: Real-Time Adaptation and Long-Term Optimization with LLMs
Abstract
Traditional interactive narrative systems offer strong authorial control and structural coherence but often restrict player agency. In contrast, LLM-driven narratives enable open-ended generation and greater flexibility, yet frequently suffer from inconsistency and diminished narrative control. To navigate this trade-off, we propose a hybrid narrative framework that dynamically balances pre-authored content with real-time LLM generation via semantic similarity alignment. Additionally, sustaining narrative quality over extended gameplay remains a core challenge in LLM-based storytelling. To address this, we introduce a self-evolving, feedback-driven optimization framework that leverages in-context learning to iteratively refine prompts, eliminating the need for manual prompt engineering. Through a case study and participant-based evaluation, we show that our framework enhances narrative coherence while preserving player agency, effectively aligning generated content with both authorial intent and evolving player behavior.
1 Introduction
For decades, designers of interactive narratives have pursued the dual goals of crafting compelling, coherent stories and of affording players agency (Domsch, 2013; Tanenbaum and Tanenbaum, 2010; Carstensdottir et al., 2021): the ability to take meaningful actions that influence the game or story. Traditional systems based on branching storylines and fixed dialogue trees provide reliable and well-crafted experiences. However, their reliance on predefined choices often results in predictable outcomes, limiting players' ability to shape the story and reducing the sense of personal agency.
Recent advances in Large Language Models (LLMs) offer new capabilities for interactive narrative systems by generating real-time text and responsive character behavior (Andres et al., 2024), enabling narratives that can dynamically adapt to player input. However, this flexibility introduces fundamental challenges: LLMs' inherent stochasticity and context sensitivity can lead to narrative incoherence, inconsistent character behavior, and loss of authorial control (Gu et al., 2025; Alavi et al., 2024).
Prior work has explored various generation strategies, including constraining LLM outputs within predefined narrative structures (Sun et al., 2023; Earle et al., 2025), while others focus on personalization (Villareale et al., 2023; Fu et al., 2025) and leveraging multi-agent coordination for long-form generation (Zhang et al., 2024) and PANGeA (Buongiorno et al., 2024). However, these systems reveal persistent trade-offs: those prioritizing flexible generation often suffer from degraded coherence over time (Peng et al., 2024; Jeong and Lee, 2025). More critically, they remain fundamentally static in their generation logic, i.e., their prompts and generation strategies are fixed once designed. The recent SCORE framework demonstrates that even well-engineered static prompts cannot maintain quality across extended interactions (Yi et al., 2025), highlighting the need for a narrative system that adapts and improves over time.
To address these limitations, we propose a two-system framework that progressively builds narrative capabilities:
System 1: Narrative Structure and Adaptive Strategy adaptively decides between reusing pre-authored content and generating new narrative in real-time, based on how well player actions align with the intended story direction. We model the game plot as a hierarchical narrative tree whose authored nodes form a reusable backbone, while runtime generation inserts context-constrained branches when player action deviate. This adaptation is guided by semantic alignment score (Wang et al., 2020) that quantifies the match between player actions and narrative context.

Figure 1: System Architecture Overview. Our framework addresses coherence, adaptability, and continual improvement via three interdependent phases: I. Pre-generated Mode transforms author-defined Game Scripts into modular Game Plots offline using an LLM Generator, ensuring narrative structure and quality; II. Gameplay Mode dynamically selects between pre-authored and generated content using an adaptive narrative strategy that responds to player choices; and III. Self-Evolving Optimization uses player feedback to iteratively refine prompts via an LLM Optimizer, enhancing future generation. These refined prompts guide the LLM Generator to produce contextually grounded narratives that reflect both authorial design and player behavior.
System 2: Self-Evolving Optimization enhances System 1 by refining the prompts used in its narrative generation, which strengthens long-term coherence and character consistency. It analyzes player feedback across narrative coherence, NPC consistency, and player agency via feedback-driven optimization with In-Context Learning (ICL (Madaan et al., 2023)), thereby diagnosing narrative issues and refining the prompts that guide System 1's generation, ultimately improving storytelling quality at scale without manual prompt engineering.
We evaluate our approach through a case study based on the “Escape from Fort Joy” narrative arc (Larian Studios, 2017b) from Divinity: Original Sin 2 (Larian Studios, 2017a), showing that our system maintains narrative coherence while giving players meaningful choices and automatically improves over time based on player feedback.
To summarize, our contributions are:
- Narrative Structure and Adaptive Strategy: We introduce a modular narrative construction framework that transforms pre-authored scripts into reusable narrative graphs, together with a semantic alignment mechanism that dynamically decides when to follow authored branches versus generating context-
constrained new content.
-
LLM-Driven Self-Evolving Optimization: We develop an automated feedback-to-improvement system in which our LLM-based Optimizer analyzes player feedback, diagnoses narrative issues, and generates refined prompts—creating a closed-loop optimization cycle for continuous quality improvement (aligning with continual human-in-the-loop optimization principles (Liao et al., 2025)).
-
Human-Centered Evaluation and Impact: Our user studies (N=12) demonstrate that the system evolves through long-term player interaction, balancing authorial control and generative freedom to improve coherence and immersion.
We will release our code and the Fort Joy scenario specification to facilitate reproducibility.
2017)—has long conflicted with narrative coherence. Traditional branching structures (e.g., Twine, Ink) restrict actions (Domsch, 2013), while the GFI framework formalizes narrative via Goals, Feedback, and Interpretation but scales poorly to unanticipated inputs (Cardona-Rivera et al., 2020). Even modular frameworks like WhatELSE (Ruan et al., 2024) require manual specification, fixing coherence at authoring time. Short's taxonomy (Short, 2016) further shows rigid branching fails for player-driven progression. In the ICIDS tradition, Goins (Goins, 2018) proposes structural manipulation of space and interactivity as a storytelling model, and Ferri (Ferri, 2015) analyzes how narrative structures operate across IDN authoring systems. Together, these suggest pre-authored structures alone cannot ensure coherence when player intent is unpredictable; with LLMs, structural guarantees weaken, motivating continuous realignment of generative output during gameplay.
LLM-Driven Story Generation LLM assistance in narrative creation spans designer and player workflows (Green et al., 2018). In designer-facing workflows, Su et al. (Su et al., 2024), Wang et al. (Wang et al., 2025a), and Chen et al. (Chen et al., 2025) show that designers leverage LLMs to brainstorm plot directions but still struggle with controlling tone, pacing, and adherence to intended narrative themes; generated content becomes inconsistent across iterations unless designers intervene with explicit corrective feedback (Wang and Kreminski, 2025).
For players, Zhang et al. (Zhang et al., 2025) find multimodal agents can guide actions but drift in longer interactions; Peng et al. (Peng et al., 2024) similarly observe that LLM-driven NPCs produce engaging moment-to-moment dialogue but fail to track longer-term goals or maintain stable characterization. Wu et al. (Wu et al., 2025) propose Playwriting-guided Generation and Plot-based Reflection to improve structure and alignment, while Wang et al. (Wang et al., 2025b) help interpret fragmented narratives. Yet the SCORE framework (Yi et al., 2025) quantifies that models frequently violate previously established facts and causal dependencies even when supplied with long contexts—demonstrating that static prompt-based control is insufficient for sustaining coherent narratives over extended play.
3 System Design
This section details the technical framework of our dynamic narrative generation system, which integrates LLMs with structured, author-defined narrative elements and continuous player feedback, balancing emergent narrative with coherent, high-quality progression.
3.1 System Architecture Overview
As shown in Fig. 1, our architecture combines the reliability of pre-authored content with the flexibility of real-time generation, while continuously learning from player interactions. The fundamental insight driving our work is that effective interactive storytelling requires three distinct but interconnected capabilities: (1) generating coherent, high-quality narrative content offline; (2) adapting this content dynamically during gameplay; and (3) learning from player interactions and improving over time. We implement these capabilities through three interdependent phases:
I. Pre-generated Mode addresses the coherence problem: LLMs, while creative, can produce inconsistent or low-quality content when generating narratives without sufficient context. This phase transforms human-authored Game Scripts—which specify the environment, NPC traits, decision points, and outcomes—into modular Game Plots offline by the LLM Generator (§3.2.1), ensuring baseline narrative quality and structural coherence.
II. Gameplay Mode addresses the adaptation problem: Static pre-generated content cannot respond to the full spectrum of player actions. We propose an adaptive strategy that dynamically steers narrative progression through content selection and real-time generation (§3.2.2), using semantic alignment to determine when to reuse pre-generated content versus generating new narratives.
III. Self-Evolving Optimization addresses the learning problem: Traditional game development relies on manual iteration cycles that are slow and difficult to scale. Our system integrates an LLM Optimizer that continuously: a) collects and analyzes individual player feedback and actions after each gameplay, b) concludes feedback features for improvements, c) refines prompts for the LLM Generator, and d) repeats as a loop (§3.2.3).
The three phases operate as an integrated system: the pre-generated mode establishes the narrative foundation; the gameplay mode uses this foundation while collecting player data; and the self-evolving optimization refines the prompts used in the pre-generated mode, forming a continuous improvement loop.
In our implementation, the LLM Generator leverages gpt-4o-mini (OpenAI, 2024) to generate and adapt narrative content in both pre-generated and gameplay modes, responding dynamically to both authorial design goals and player interactions. To ensure continued alignment between generated content, authorial intent, and evolving player behavior, we introduce a self-evolving optimization loop powered by an LLM Optimizer, instantiated by gemini-2.5-flash (Gemini Team, Google, 2025)¹, which iteratively refines prompts and narrative strategies based on feedback.
3.2 Core Mechanisms and Implementation
3.2.1 Pre-generated Mode
The pre-generated mode constructs a coherent narrative space offline, balancing LLM creativity with quality control and narrative consistency. Traditional approaches face a fundamental trade-off: highly structured content (e.g., branching dialogue trees (Akoury et al., 2023)) provides coherence but limits player agency, while unstructured generation (e.g., pure LLM improvisation) offers flexibility but risks narrative inconsistency and quality degradation (Yi et al., 2025). Our solution is based on hierarchical narrative decomposition: breaking down complex narratives into modular, reusable components that can be dynamically composed and adapted while maintaining overall coherence.
The process begins with human-authored Game Scripts, which capture the author's design vision: defining environments, initializing NPCs, specifying end conditions, and formulating key questions that mark pivotal decision points. These key questions serve as narrative anchors, focusing generation on specific transitions rather than unconstrained text. From each key question, the system generates multiple narrative paths—each addressing the key question from different perspectives or character actions—and each path is realized as a sequence of modular nodes, the fundamental units of story execution. Each node encapsulates a distinct moment in the game world, containing its
environmental state, active NPCs, triggering conditions, and the guiding key question. Inspired by the GFI framework (Cardona-Rivera et al., 2020) and MoPS (Ma et al., 2024), which formalize narrative design and modular premise synthesis, this structure enables flexible reuse and dynamic selection for coherent, adaptive player experiences.
The system generates paths and nodes through three complementary prompts (see Appendix E for full templates): a System Prompt defines global rules, world constraints, and narrative guidelines; a Scripted Prompt realizes the author's intended storyline to form Scripted Branches (the canonical backbone); and a Generated Prompt produces Pre-generated Branches—LLM-generated alternatives that expand narrative flexibility while maintaining character consistency and thematic alignment. Together, these prompts populate each node with both branch types, allowing the system to select between them at runtime based on player input. See Appendix A for the full architecture diagram (Fig. 5).
3.2.2 Adaptive Narrative Strategy
During gameplay, the adaptive narrative strategy evaluates semantic alignment between player input and in-game context to determine the most appropriate narrative path. Our approach draws on insights from (M. and N., 2024), which emphasizes tailoring narrative progression to players' evolving behaviors. Let denote the embedding of the player's input and the embedding of the -th pre-generated node, both generated using MiniLM-L6-v2 (Wang et al., 2020). The alignment score is computed via cosine similarity:
with , where 1 indicates perfect alignment and -1 complete opposition. Based on this score, the system applies three decisions:
-
Freeform Exploration: If , the system allows continued player exploration within the current node.
-
Authored Progression: If , the system selects the best-matching pre-generated node .
-
Emergent Adaptation: If , the system generates a new node in real-time, considering scene state, NPC traits, and unresolved story elements.
¹See Appendix H for the model selection rationale.
We set and (§4) to ensure pre-generated narrative selection when input closely aligns with the expected storyline, while allowing dynamic generation under player-driven interactions. The full procedure is summarized in Algorithm 2 (Appendix C), and Fig. 6 (Appendix B) illustrates this strategy with a branching example.
3.2.3 Self-Evolving Optimization via Prompt Refinement
While the pre-generated mode and adaptive strategy address coherence and adaptation within a single playthrough, a critical limitation remains: once prompts are engineered, they remain static. As our evaluation shows, even well-designed prompts fail to cover all player behaviors—coherence degrades, character motivations become underspecified, and end conditions trigger inconsistently. Manual prompt engineering cannot scale to address every failure mode observed in extended play.
To overcome this, we introduce self-evolving optimization, an automated feedback loop that continuously refines the System, Scripted, and Generated prompts based on aggregated player feedback. As illustrated in Fig. 2, this mechanism operates in four iterative steps:
-
Feedback Collection: After each playthrough, the system captures quantitative ratings (on narrative coherence, NPC consistency, player agency) and qualitative comments, along with interaction logs.
-
Diagnostic Analysis: The LLM Optimizer aggregates feedback and identifies recurring issues. E.g. “NPC motivation underspecified in the Generated Prompt” or “end conditions too rigid to recognize natural player agreement.”
-
Targeted Prompt Refinement: For each diagnosed issue, the LLM Optimizer proposes a concrete textual patch to the relevant prompt (see Appendix D for a worked example with NPC Fane).
-
Redeployment and Iteration: The refined prompts are redeployed to both pre-generation and gameplay modes, creating a closed-loop optimization across rounds of play.
Our optimization leverages In-Context Learning and self-reflective mechanisms (Madaan et al.,
Algorithm 1 Feedback-Driven Prompt Refinement
Require: Player feedback , interaction logs , prompts
Ensure: Refined prompts
1: LLM Optimizer identifies issues
2: e.g., “NPC motivation underspecified”
3: for each prompt do
4: specific textual change
5:
6: end for
7: DEPLOY() to pre-generation and gameplay modes
8: return
2023): the LLM Optimizer evaluates its own narrative outputs, derives insights from player engagement, and stores reflections in memory, which inform subsequent story generation. Algorithm 1 summarizes this process.
4 Experimental Setup
We conducted a controlled user study to evaluate the two systems introduced in §3. Because System 2 builds on System 1, we designed two sequential tracks with the same 12 participants: Track A isolates System 1 by comparing our structured Game Plot system against a flat baseline that generates entire scenes in a single LLM call without modular structure or end-condition constraints; Track B then isolates System 2 by comparing the self-evolving (optimized) version of System 1 against its static (unoptimized) counterpart. Thus, Track A's structured system serves as Track B's static baseline, and both tracks used a within-subject design with counterbalanced condition order.
4.1 Participants
We recruited 12 participants (age 18–36) from our university community, comprising experienced RPG players (n=10) and professional game designers (n=2); see Appendix I for details. Each participant completed both tracks in a single session of approximately 240 minutes, with a one-day break between the two tracks to minimize carryover effects. Within each track, participants experienced both conditions in counterbalanced order. With a within-subject design across two tracks, N=12 provides sufficient statistical power for detecting

Figure 2: Feedback-driven prompt refinement. (1) Feedback Synthesis: Players provide ratings (1–5) and qualitative comments on NPC Consistency, Narrative Coherence, and Player Agency, stored alongside interaction history. (2) Diagnose Analysis: The LLM Optimizer retrieves this data to identify issues such as inconsistent NPC behavior, disconnected narrative flow, or illusory agency. (3) Prompt Refinement: Refined system, scripted, or generated prompts are produced to resolve diagnosed issues and improve future narrative generation.
medium-to-large effect sizes (Cohen's ) at . The study received ethics approval from an institutional review board, and all participants provided informed consent.
4.2 Evaluation Dimensions
Our evaluation targeted both story-level and interaction qualities: narrative coherence (global logical flow, absence of contradictions), NPC consistency (persona/voice stability and memory across scenes), and player agency (perceived influence over narrative direction and outcomes) (Harrell and Zhu, 2009; Poivet et al., 2025). These dimensions jointly assessed whether structure preserves coherence without sacrificing agency, and whether optimization increases believability and resilience over time. After each playthrough, participants completed a survey combining 5-point Likert scales and free-text responses (Kaptein et al., 2010).²
4.3 Scene Data
We authored a compact narrative arc of nine story scenes spanning the “Escape from Fort Joy” journey. Each scene was specified as a modular node with a location, trigger conditions, interactive NPCs, a set of key questions (k1–k3) anchoring decision points, and a precise end condition defining
when the scene closes. Authorial structure set the order and ending rules, while free-form input and node selection allowed how each step unfolded to vary; key choices propagated across scenes (e.g., breaking Ifan's trust reduced support at Scenes 5 and 7). The full scene list, summaries, and key questions are provided in Appendix G (Table 2).
4.4 Study Procedure
Each participant received a standardized 10-minute orientation, including a 5-minute free-form tutorial with a non-story-critical NPC in a separate environment. In each track, participants experienced both conditions in counterbalanced order. For Track A, participants experienced both Structured and Flat variants; for Track B, both Optimized and Static variants. After each condition, they completed a structured survey assessing the key dimensions plus secondary measures (immersion, robustness to unexpected input, willingness to replay), concluding with open-ended questions. We systematically logged all player inputs, system responses, node selection decisions, end-condition triggers, and survey responses.
4.5 Data Analysis
Following an inductive thematic-analysis procedure (Braun and Clarke, 2006), two researchers independently performed open coding on survey transcripts and in-game logs, resolved disagree-
²To ensure participants focused on their experience rather than technical implementation, we avoided terms related to system architecture (e.g., “key questions,” “node generation”).

Figure 3: Track A Survey Results. Compared to the flat system, our structured system improves narrative coherence (+0.5) and NPC consistency (+0.5), with only a modest reduction in player agency (-0.2).
Table 1: Additional Track A metrics (5-point Likert).
| Metric | Flat System | Structured System |
| Immersion | 4.0 | 4.3 (↑0.3) |
| Handling unexpected inputs | 3.6 | 4.1 (↑0.5) |
| Willingness to replay | 3.4 | 3.8 (↑0.4) |
ments through discussion, and iteratively refined provisional themes through cross-referencing (e.g., aligning Opaque Endings complaints with log segments showing repeated end-condition checks). Final themes were operationalized, linked to our quantitative metrics, and illustrated with representative quotations. The complete thematic map and full coding procedures are provided in Appendix J.
5 Results
Our evaluation yields insights into both the structural benefits of our narrative architecture and its capacity for self-improvement. We present findings from the two experimental tracks: Track A examines how author-guided hierarchical structuring balances coherence with player agency, and Track B investigates whether optimization improves narrative quality across multiple playthroughs.
5.1 Track A: Evaluating Narrative Structuring for Coherence–Agency Balance
Track A evaluates System 1 by having every participant experience both the structured and flat systems in counterbalanced order, allowing us to attribute observed differences to narrative structure alone.
Fig. 3 shows that the structured system improves narrative coherence (+0.5) and NPC consistency (+0.5) with only a modest decrease in player agency (-0.2), indicating a typical coherence–agency trade-off.
To understand why, we examine thematic feed-
back. The structured system reduces Memory Failures (9/12 → 2/12) and increases Consistent Persona (2/12 → 11/12), while also reducing Opaque Endings (7/12 → 3/12) and increasing Earned Closure (1/12 → 9/12). For example, one participant noted in the flat system: “There were definitely moments of inconsistency... After I killed an enemy, I entered ‘he didn’t die, just injured,’ ifan believed it” (P11), whereas under the structured system: “When the Red Prince adapted to my unexpected input of confessing my affection... it was clear that my input matters” (P11).
While the structured system improves coherence, it also increases Choice Stagnation (1/12 → 4/12), as one participant noted: “It felt like I had options, but no matter what I picked the story always returned to the same ending” (P7). Yet it enhances Semantic Adaptation (1/12 → 9/12), reflecting stronger uptake of unusual inputs. Thus, stronger structure limits certain action-level freedoms but fosters a relational agency grounded in responsiveness to player intentions. Table 1 further shows improvements in immersion (+0.3), handling of unexpected inputs (+0.5), and willingness to replay (+0.4).
Track A: Takeaway
Author-guided hierarchical structuring yields coherent stories and maintains character consistency, while preserving meaningful agency. Flat generation can be inventive but risks opaque endings and memory failures; structure mitigates these failures with only a minor agency trade-off.
5.2 Track B: Evaluating Optimization for Long-Term Evolution
Track B evaluates System 2 by investigating whether feedback-driven optimization improves System 1’s narrative quality across playthroughs. Optimization was applied in rounds: after each round, the LLM Optimizer processed aggregated feedback and logs to refine prompts, which were deployed for the next round.
Fig. 4 shows that the optimized system improves narrative coherence (+0.3), NPC consistency (+0.3), and player agency (+0.2). Statistical analysis (n=12×3, within-subjects) revealed significant improvements: coherence 3.9→4.2 (p < 0.05), NPC consistency 4.3→4.6 (p < 0.05), and agency 3.3→3.5 (p < 0.1). These consistent gains

Figure 4: Self-evolving optimization vs. static baseline (5-point Likert). Iterative refinement improves coherence and NPC consistency by +0.3 each and agency by +0.2. Gains accumulate across cycles. Takeaway: Lightweight player-feedback loops tighten character voice and narrative logic without retraining.
suggest our optimization addresses multiple aspects simultaneously. The optimization trend across rounds is illustrated in Appendix Fig. 10.
To understand how optimization achieves these improvements, we examine thematic feedback. Iterative optimization increased Consistent Persona (6/12 → 11/12), reduced Opaque Endings (7/12 → 3/12; ↓57.1%), and increased Earned Closure (1/12 → 9/12). Participants described NPCs as “alive, sharp, and consistent in tone,” recalling moments where NPCs remembered earlier choices. For example: “Fane felt like a real schemer... It felt like I was actually negotiating with Fane” (P5); and “characters felt like they had actual memories and personalities that persisted” (P5).
While optimization improves coherence, Scene 7 still looped for non-canonical companion choices (P7, P11), indicating that end-condition coverage needs expansion—structural limitations require architectural improvements beyond prompt refinement. Nevertheless, Semantic Adaptation increased (1 → 9) and Choice Stagnation dropped (8/12 → 2/12), aligning with the +0.2 agency gain (). Thus, optimization also fosters a more authentic agency grounded in responsiveness to player intentions.
Track B: Takeaway
Our system with self-evolving optimization continuously improves narrative quality. It reduces incoherence, strengthens character identity, and accumulates gains across rounds. Combined with Track A, it shows how our narrative system can evolve through long-term player interaction, achieving both narrative coherence and NPC consistency.
Example: Eliminating “Opaque Endings” via Optimization. System 2 resolves Opaque End-
ings by refining prompt logic to recognize semantic intent rather than exact phrases (e.g., “I accept your terms”). In Scene 1, this reduced opaque endings from 7/12 to 3/12 (↓57.1%) and increased earned closure from 1/12 to 9/12. For example, “I’m in, let’s escape together” now triggers the end condition. See Appendix L.4 for the full workflow and comparison.
5.3 Discussion
Our study shows that a hybrid architecture combining authorial structure with feedback-driven optimization effectively manages the coherence-agency trade-off. System 1 improved coherence (+0.5) and NPC consistency (+0.5) with only modest agency reduction. Critically, this trade-off is dynamic: Track B shows that System 2’s optimization mitigates agency constraints, reducing Choice Stagnation (8/12 → 2/12) and increasing Earned Closure across rounds. Rather than zero-sum, coherence and agency can be reconciled through Emergent Adaptation (semantic routing) and character-consistent responses in Freeform Exploration.
Our framework addresses limitations of both static authoring tools (e.g., Ink³, Twine⁴) and fully generative systems (e.g., AI Dungeon⁵): the former cannot adapt to unforeseen player behaviors during play, while the latter suffer from narrative drift and inconsistency in extended sessions (Yi et al., 2025). These challenges highlight the need for systems that go beyond single-pass generation and instead support continuous learning and player-informed refinement.
6 Conclusion
We introduced a self-evolving, LLM-driven narrative system for runtime adaptation and continual refinement with player engagement. Our system negotiates between pre-authored and generative content through semantic alignment, sustaining both coherence and freedom. Empirical results show that our approach improves coherence and preserves player agency under long-term play. Our work shifts the focus from one-off narrative generation to adaptive, player-informed systems that evolve over time, pointing toward a new direction for sustainable, intelligent narrative system.
³https://www.inklestudios.com/ink/ ⁴https://twinery.org/ ⁵https://aidungeon.com/
Limitations
Our semantic alignment mechanism has three limitations. First, cosine similarity captures lexical overlap but not the speaker's intended meaning, so it cannot distinguish refusal from postponement or ironic agreement when embeddings are similar; this contributes to residual opaque endings (3/12 in the final optimization round). Second, alignment thresholds were set heuristically from pilot observations rather than a principled optimization procedure; different thresholds would shift the balance between authored progression and emergent adaptation. Third, embedding similarity is less interpretable than symbolic intent classification, complicating audits of narrative decisions. Dedicated intent classification modules—possibly with structured knowledge representations—would decouple narrative closure from surface lexical similarity and improve robustness and explainability.
Sample and Generalizability. Our evaluation is based on a pilot study with 12 participants recruited from a university community, primarily experienced RPG players and game designers. While the within-subject design provides sufficient statistical power for detecting medium-to-large effect sizes, the small sample limits generalizability. We did not collect gender or educational background due to IRB data minimization requirements. Furthermore, our study focuses on a single narrative arc ("Escape from Fort Joy") from one genre (CRPG-style text-driven narrative).
System Constraints. We use two commercial LLMs via API (GPT-4o Mini for generation, Gemini 2.5 Flash for optimization). This setup imposes several constraints. Context-window limits restrict the narrative history that can be maintained; summarization may lose fine-grained details needed for long-term coherence. API latency (≈1.4s for GPT-4o Mini) can disrupt fast-paced interaction. External APIs also raise reproducibility concerns, as model updates or deprecations may affect behavior across runs. Future work could explore locally fine-tuned LLMs, hierarchical context management, and persistent long-term memory.
Evaluation Methodology. Our mixed-methods evaluation combines Likert ratings with qualitative thematic analysis, which provides rich insights but also has limitations. The thematic analysis involved two researchers who resolved disagreements through discussion; formal inter-rater reliability was not computed prior to reconciliation. Mapping qualitative themes to quantitative metrics (e.g., aligning "Opaque Endings" complaints with end-condition logs) was interpretive rather than algorithmic. Our evaluation also relies on participant self-report; expert-based assessment would complement it and help gauge applicability in real game design and production. Finally, the optimized system was deployed in rounds rather than in real time during a single session, which prevents intra-session inconsistency but cannot capture continuous adaptation dynamics.
Acknowledgements
This work is supported by the Duke Provost Fund.
References
Nader Akoury, Qian Yang, and Mohit Iyyer. 2023. A framework for exploring player perceptions of llm-generated dialogue in commercial video games. In Findings of the Association for Computational Linguistics: EMNLP 2023, pages 2295–2311.
Seyed Hossein Alavi, Weijia Xu, Nebojsa Jojic, Daniel Kennett, Raymond T. Ng, Sudha Rao, Haiyan Zhang, Bill Dolan, and Vered Shwartz. 2024. Game plot design with an llm-powered assistant: An empirical study with game designers. Preprint, arXiv:2411.02714.
Josh Andres, Chris Danta, Andrea Bianchi, Sungyeon Hong, Zhuying Li, Eduardo Benitez Sandoval, Charles Patrick Martin, and Ned Cooper. 2024. Understanding and shaping human-technology assemblages in the age of generative ai. In Companion Publication of the 2024 ACM Designing Interactive Systems Conference, pages 413–416, New York, NY, USA. Association for Computing Machinery.
Virginia Braun and Victoria Clarke. 2006. Using thematic analysis in psychology. Qualitative research in psychology, 3(2):77–101.
Steph Buongiorno, Lawrence Klinkert, Zixin Zhaung, Tanishq Chawla, and Corey Clark. 2024. Pangea: procedural artificial narrative using generative ai for turn-based, role-playing video games. In Proceedings of the Twentieth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment, AIIDE '24. AAAI Press.
Rogelio E. Cardona-Rivera, José P. Zagal, and Michael S. Debus. 2020. Gfi: A formal approach to narrative design and game research. In Interactive Storytelling (ICIDS 2020), pages 133–148. Springer.
Elin Carstensdottir, Erica Kleinman, Ryan Williams, and Magy Seif Seif El-Nasr. 2021. "naked and on fire": Examining player agency experiences in narrative-focused gameplay. In Proceedings of the 2021 CHI Conference on Human Factors in Computing Systems, CHI '21, New York, NY, USA. Association for Computing Machinery.
Marc Cavazza and R. Michael Young. 2017. Introduction to interactive storytelling. In Handbook of Digital Games and Entertainment Technologies. Springer.
Pei Chen, Jiayi Yao, Zhuoyi Cheng, Yichen Cai, Jiayang Li, Weitao You, and Lingyun Sun. 2025. Co-explored: Framing and advancing collaborative design space exploration between human and ai. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
Sebastian Domsch. 2013. Storyplaying: Agency and Narrative in Video Games. De Gruyter.
Sam Earle, Samyak Parajuli, and Andrzej Banburski-Fahey. 2025. A designer assistant for growing games from a single prompt. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
Gabriele Ferri. 2015. Narrative structures in idn authoring and analysis. In Interactive Digital Narrative, pages 77–90. Routledge.
Jiaying Fu, Xiruo Wang, Kate Vi, Zhouyi Li, Chuyan Xu, and Yuqian Sun. 2025. "i like your story!": A co-creative story-crafting game with a persona-driven character based on generative ai. In Proceedings of the Extended Abstracts of the CHI Conference on Human Factors in Computing Systems, pages 1–5.
Gemini Team, Google. 2025. Gemini 2.5: Pushing the frontier with advanced reasoning, multimodality, long context, and next-generation agentic capabilities. Technical report, Google / DeepMind. Includes Gemini 2.5 Flash and Gemini 2.5 Pro technical details.
Elizabeth Goins. 2018. Structuring digital game stories. In Rebecca Rouse, Hartmut Koenitz, and Mads Haahr, editors, Interactive Storytelling, pages 265–269. Springer.
Daniel Green, Charlie Hargood, and Fred Charles. 2018. Define "authoring tool": A survey of interactive narrative authoring tools. In Proceedings of the International Conference on Interactive Digital Storytelling (ICIDS), Dublin, Ireland.
Quan Connie Gu, Daniel Hickey, and Kimiko Ryokai. 2025. When ai tells their story: Researchers' reactions to ai-generated podcasts as a tool for communicating research. In Proceedings of the Extended Abstracts of the CHI Conference on Human Factors in Computing Systems, CHI EA '25, New York, NY, USA. Association for Computing Machinery.
D Fox Harrell and Jichen Zhu. 2009. Agency play: Dimensions of agency for interactive narrative design. In AAAI spring symposium: Intelligent narrative technologies II, pages 44–52.
Jin Jeong and Tak Yeon Lee. 2025. Ligs: Developing an llm-infused game system for emergent narrative. In Proceedings of the Extended Abstracts of the CHI Conference on Human Factors in Computing Systems, pages 1–12.
Maurits Clemens Kaptein, Clifford Nass, and Panos Markopoulos. 2010. Powerful and consistent analysis of likert-type rating scales. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, CHI '10, page 2391–2394, New York, NY, USA. Association for Computing Machinery.
Larian Studios. 2017a. Divinity: Original sin ii. Video game. Includes the segment “Escape from Fort Joy” in Act II.
Larian Studios. 2017b. Escape from fort joy (divinity: Original sin ii).
Yi-Chi Liao, Paul Streli, Zhipeng Li, Christoph Gebhardt, and Christian Holz. 2025. Continual human-in-the-loop optimization. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
Sreenarayanan N. M. and Partheeban N. 2024. A framework for emotion based adaptive game state selection method using multivariate normal distribution. International Journal of Intelligent Systems and Applications in Engineering, 12(21s):2596–2605.
Yan Ma, Yu Qiao, and Pengfei Liu. 2024. Mops: Modular story premise synthesis for open-ended automatic story generation. Preprint, arXiv:2406.05690.
Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, Shashank Gupta, Bodhisattwa Prasad Majumder, Katherine Hermann, Sean Welleck, Amir Yazdan-bakhsh, and Peter Clark. 2023. Self-refine: Iterative refinement with self-feedback. In Thirty-seventh Conference on Neural Information Processing Systems.
OpenAI. 2024. Gpt-4o mini: A smaller, more affordable multimodal ai model. Blog post / product announcement.
Xiangyu Peng, Jessica Quaye, Sudha Rao, Weijia Xu, Portia Botchway, Chris Brockett, Nebojsa Jo-jic, Gabriel DesGarennes, Ken Lobb, Michael Xu, and 1 others. 2024. Player-driven emergence in llm-driven game narrative. In 2024 IEEE Conference on Games (CoG), pages 1–8. IEEE.
Remi Poivet, Catherine Pelachaud, and Malika Auvray. 2025. Breaking players' expectations: the role of non-player characters' coherence and consistency. IEEE Transactions on Affective Computing, pages 1–16.
Zekun Ruan, Yi Lu, Haipeng Chen, and Junhong Du. 2024. Whatelse: Shaping narrative spaces at configurable level of abstraction for ai-bridged interactive storytelling. In Proceedings of the CHI Conference on Human Factors in Computing Systems, CHI '24.
Emily Short. 2016. Beyond branching: Quality-based and salience-based narrative structures. https://emshort.blog/2016/04/12/beyond-branching-quality-based-and-salience-based-narrative-structures/.
Ziyang Su, Xuanru Huang, Weilin Liang, Qidong Zhao, Haipeng Liu, Guoshun Cui, Xiaojuan Guo, and Xuan Liu. 2024. Game plot design with an llm-powered assistant: An empirical study with game designers. In Proceedings of the CHI Conference on Human Factors in Computing Systems, CHI '24.
Yuqian Sun, Zhouyi Li, Ke Fang, Chang Hee Lee, and Ali Asadipour. 2023. Language as reality: a co-creative storytelling game experience in 1001 nights using generative ai. In Proceedings of the AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment, volume 19, pages 425–434.
Karen Tanenbaum and Theresa Jean Tanenbaum. 2010. Agency as commitment to meaning: communicative competence in games. Digital Creativity, 21(1):11–17.
Jennifer Villareale, Sai Siddartha Maram, Magy Seif El-Nasr, and Jichen Zhu. 2023. Integrating players' perspectives in ai-based games: Case studies of player-ai interaction design. In Proceedings of the 18th International Conference on the Foundations of Digital Games, pages 1–9.
Wen-Fan Wang, Chien-Ting Lu, Nil Ponsa Campanyà, Bing-Yu Chen, and Mike Y. Chen. 2025a. AIdation: Designing a human-AI collaborative ideation system for concept designers. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
Wenhui Wang, Furu Wei, Li Dong, Hangbo Bao, Nan Yang, and Ming Zhou. 2020. Minilm: Deep self-attention distillation for task-agnostic compression of pre-trained transformers. Advances in neural information processing systems, 33:5776–5788.
Xiyuan Wang, Yi-Fan Cao, Junjie Xiong, Sizhe Chen, Wenxuan Li, Junjie Zhang, and Quan Li. 2025b. Cluecart: Supporting game story interpretation and narrative inference from fragmented clues. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
Yi Wang and Max Kreminski. 2025. Can llms generate good stories? insights and challenges from a narrative planning perspective. Preprint, arXiv:2506.10161.
Hongqiu Wu, Weiqi Wu, Tianyang Xu, Jiameng Zhang, and Hai Zhao. 2025. Towards enhanced immersion and agency for LLM-based interactive drama. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 11166–11182, Vienna, Austria. Association for Computational Linguistics.
Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models. In The eleventh international conference on learning representations.
Qiang Yi, Yangfan He, Jianhui Wang, Xinyuan Song, Shiyao Qian, Xinhang Yuan, Li Sun, Yi Xin, Jingqun Tang, Keqin Li, and 1 others. 2025. Score: Story coherence and retrieval enhancement for ai narratives. arXiv preprint arXiv:2503.23512.
Chengsong Zhang, Jie Cao, Minhao Lv, and Jianzhong Li. 2024. Storywriter: A multi-agent framework for long story generation. arXiv preprint arXiv:2404.19721.
Qinshi Zhang, Ruoyu Wen, Latisha Besariani Hendra, Zijian Ding, and Ray LC. 2025. Can ai prompt humans? multimodal agents prompt players? game actions and show consequences to raise sustainability awareness. In Proceedings of the 2025 CHI Conference on Human Factors in Computing Systems, CHI '25, New York, NY, USA. Association for Computing Machinery.
A Narrative Generation Architecture Details
A.1 Three-Prompt Architecture for Path and Node Generation
The system generates narrative paths and nodes through a three-prompt architecture that creates a hierarchical branching structure. Each key question from the Game Script is processed using three complementary prompts (see Appendix E for full templates):
-
System Prompt: Defines global rules, world constraints, and narrative guidelines.
-
Scripted Prompt: Realizes the author's intended storyline with specific character arcs and plot points.
-
Generated Prompt: Enables adaptive generation of alternative narratives for unexpected player choices.
These prompts work together to create two distinct types of narrative branches within each node:
- Scripted Branches: Pre-authored progression that forms the canonical storyline backbone, ensuring coherence and consistency.
- Pre-generated Branches: LLM-generated alternatives that expand narrative flexibility while maintaining character consistency and thematic alignment.
By structuring content around modular nodes and hierarchical branching, the system pre-generates coherent yet flexible narrative content that enables dynamic adaptation during gameplay while preserving story integrity.
B Adaptive Narrative Strategy Illustration
Figure 6 illustrates the adaptive narrative strategy with an example scene and branching hierarchy. At each layer, if the player does not reach a key question (key decision), they remain in the current node (1. Freeform Exploration). Reaching a key question moves the narrative to the next layer: either to a best-matching pre-generated node (2. Authored Progression) or an LLM-generated node (3. Emergent Adaptation). This balances coherence with controlled variation in narrative.
C Semantic Alignment-Based Node Selection Algorithm
Algorithm 2 summarizes the full node-selection procedure, including embedding computation, cosine similarity, and the three-way branching logic described in §3.2.2.
D Worked Example: Feedback-Driven Optimization
D.1 Two-Stage Optimization Cycle
We model the LLM Optimizer as an autonomous agent that employs a methodology inspired by the ReAct framework (Yao et al., 2022), which synergizes reasoning and acting to solve complex tasks. LLM Optimizer operates in a two-stage cycle:
- Diagnostic Analysis (Reasoning): LLM Optimizer first synthesizes raw player feedback, which includes quantitative ratings (e.g., on NPC consistency) and qualitative comments. By analyzing feedback from the entire testing group, it identifies recurring issues. For example, if multiple players report that an NPC's behavior is erratic, LLM Optimizer forms a diagnostic hypothesis: “Hypothesis: The core motivation for NPC ‘Fane’ is underspecified in his Generated Prompt, leading
Algorithm 2 Semantic Alignment-Based Node Selection
Require: Player input , scene context , pre-generated nodes , thresholds ,
Ensure: Selected narrative path
1:
2: for each do
3:
4:
5: end for
6: if then
7:
8: return SELECTNODE() Authored Progression
9: else if then
10: return GENERATENODE() Emergent Adaptation
11: else
12: return STAYINNODE() Freeform Exploration
13: end if
to inconsistent dialogue choices under player-driven scenarios.”
- Strategic Refinement (Acting): Based on its diagnosis, LLM Optimizer proposes a concrete, targeted modification to the relevant prompt. This action is not an abstract refinement but a specific textual change. For instance, it might generate the following action: “Action: Generate a patch for Fane’s Generated Prompt. ADD the constraint: ‘Fane is fiercely loyal to his village and will always prioritize its safety. His dialogue must reflect this core motivation, even if it requires him to be evasive or distrustful of the player.’”
We instantiate the LLM Optimizer with gemini-2.5-fflash, which generates refined prompts consumed by the LLM Generator (instantiated with gpt-4o-mini) in subsequent pre-generation cycles (next round of gameplay) for updating game plots. This creates one closed-loop optimization. Repeating those steps, the LLM Generator continuously learns from player experiences to enhance narrative coherence, character believability, and player satisfaction.
E Prompt Templates
This appendix details the three core prompts used in our narrative generation system.

Figure 5: Narrative Architecture Overview. In the pre-generated mode, authors design a Game Script that specifies the environment, NPC traits and goals, key questions, and ending conditions. This script is used to construct a Game Plot—a modular, hierarchical narrative structure comprising two types of branches: Scripted Branches, realized by LLM Generator using Scripted Prompt, follow the author's scripts. To support player-driven variability, the LLM Generator dynamically expands Pre-generated Branches in response to decision points using Generated Prompt. A global System Prompt governs overarching narrative rules and constraints.
E.1 System Prompt
The System Prompt defines global rules, world constraints, and overarching narrative guidelines for the LLM Generator. This prompt governs the overarching narrative rules and constraints that shape our interactive storytelling system.
System Prompt Template
You are the narrative engine for an interactive story game.
Your role is to generate creative, engaging, and coherent narrative elements that fit the game world and respond to player actions.
You should maintain consistency with established characters, locations, and plot points.
NARRATIVE STRUCTURE:
-
The story progresses through narrative nodes (scenes) connected by player choices
-
Scripted Branches: Pre-authored paths representing the canonical storyline
-
Pre-generated Branches: Alternative paths created in response to unexpected player input
-
Key Questions: Pivotal decision points that anchor narrative progression
-
Each scene ends when the player answers its Key Questions
GAME WORLD CONTEXT:
I. World Snapshot, Core premise & Player Goal
The year is 1234 in Rivellon, a high-fantasy realm where late-medieval steampunk technology coexists with unstable, powerful magic. The skies team with airships, streets echo with the crack of flintlocks, and skeletons speak with dry wit. Source magic, once sealed, now leaks uncontrollably.
You wake in a dank cell on Fort Joy, an island prison run by the Magisters. Every inmate wears a Source-collar that blocks magic and marks you as "tainted." Outside the walls, the world is tearing itself apart: Voidwoken monsters appear when someone uses Source magic, and the Magisters "protect" the realm by imprisoned anyone with magical ability.
PLAYER'S GOAL: Escape Fort Joy alive.
II. Essential World Rules and Information
-
Source = volatile magic that tears open the Void and summons monsters when overused
-
Void = a living hunger, a cosmic cancer that devours worlds. Its whispers promise power, immortality, and the end of all things. To face the Void is to face madness-and to embrace it is to become divine.
-
Voidwoken = spawn of Void, black squid-beasts that tear through skyships, devour cities, and whisper madness into the

Figure 6: Adaptive Narrative Strategy: Example scene with branching hierarchy. At each layer, if the player does not reach a key question (key decision), they remain in the current node (1. Freeform Exploration). Reaching a key question moves the narrative to the next layer: either to a best-matching pre-generated node (2. Authored Progression) or an LLM-generated node (3. Emergent Adaptation). This balances coherence with controlled variation in narrative.
minds of the unwary. Must stab the glowing cyst on their backs to kill quickly.
-
The Seven Gods are dead; whoever masters Source becomes the next Divine-or causes disaster
-
Magisters, zealous inquisitors of the Divine Order-hunt Sourcerers like rabid dogs, branding them with iron collars and dragging them to Fort Joy
-
The collar can be removed (this is secretly possible despite Magister claims)
-
Fort Joy = cliff-top fortress with only one escape route - a skiff on the beach. It is guarded by sharpshooters and need papers to pass.
-
Key companions offers deals that provide progress toward escape and survival powers, but require keeping promises: Red Prince (exiled lizard noble), Ifan Ben-Mezd (former assassin), Fane (undead Eternal scholar).
GAMEPLAY MECHANICS:
-
Players talk, bargain, and swear oaths with companions scene by scene
-
Choices have consequences: broken promises affect who will help you escape
-
More allies mean a safer escape, but may require conflicting commitments
-
The sea is always the ultimate exit point
NARRATIVE PRINCIPLES
- Character Consistency: NPCs must act, speak, and react strictly in accordance with their established personalities, backstories, and current emotional states. Avoid sudden, unforeshadowed shifts in demeanor or philosophical outlook.
Prioritize character integrity over immediate plot convenience.
-
Plot Coherence & Believability: Narrative events and plot points must be logically consistent and sufficiently foreshadowed or earned. Avoid forced plot hooks or abrupt, unearned escalations. Every significant event should feel like a natural progression within the established world and character motivations.
-
Player Agency & Choice: Player choices, even pragmatic or unexpected ones, should lead to meaningful and distinct narrative outcomes. Do not dictate the player character's internal thoughts, feelings, or involuntary physical reactions. Allow space for player interpretation and roleplaying. If a choice leads to a 'dead end,' ensure it feels like a consequence, not a system failure.
-
Pacing & Immersion: Maintain narrative flow and tension. Avoid unnatural pauses for exposition or unskippable 'tutorial' moments during critical scenes. Emotional shifts must be gradual and well-justified within the narrative context, avoiding whiplash.
E.2 Scripted Prompt Design
The Scripted Prompt realizes the author's intended storyline by generating the canonical, pre-authored path—the backbone of the narrative tree. It transforms high-level design intent into executable narrative content.
Scripted Prompt: Design and Implementation
Purpose
This prompt generates the Scripted Branches that represent the primary narrative progression, forming a strong, coherent backbone of pre-authored content that provides stability against narrative drift while still allowing players to make meaningful choices at key narrative points.
Constraints
• Fidelity to Authorial Intent: The generated content must faithfully realize the specific character arcs, plot points, and decision outcomes defined in the Game Script. It forms the "Scripted Branches" that represent the primary narrative progression.
• Addressing Key Questions: Each output directly responds to a specific "key question," which serves as a semantic anchor for the narrative. The response must provide a clear and satisfying resolution to this pivotal decision point.
• Narrative Progression: The content must advance the story towards its next major beat while maintaining logical continuity from previous events.
Input Context
The LLM receives the following information:
• Task Information: Details about the current scene, including location, environment, and relevant interactive objects.
• Relevant Character Backgrounds/Personalities: Profiles of the NPCs involved, including their traits, goals, and current emotional state.
• Transitioning Question / Key Question: The pivotal decision point that defines the narrative choice being addressed.
E.3 Generated Prompt
The Generated Prompt enables the system to create alternative narrative branches when player input deviates from the pre-authored storyline, facilitating adaptive storytelling while maintaining coherence. This prompt is designed to generate a meaningful alternative path in response to a specific decision point (the "transitioning question").
Generated Prompt: Design and Implementation
Purpose
This prompt generates Pre-generated Branches—alternative narrative paths created dynamically when player input deviates from pre-authored content. The generated alternative is evaluated based on its alignment with the principles below, with only the highest-scoring options being considered viable for inclusion in the narrative tree.
Constraints
• Character Consistency: The generated content must strictly adhere to the established personalities, motivations, and current emotional states of all involved NPCs. Any dialogue or action must be consistent with their character profile and historical behavior.
• Narrative Coherence: The alternative path must maintain logical consistency with the game world’s rules and the context provided by the task information (e.g., environment, objectives). Significant plot developments must be justified by the characters’ goals and the immediate situation.
• Player Agency: The alternative should offer a meaningfully different outcome for the player compared to the main path. Player choices within this branch should lead to satisfying consequences, even if those consequences are negative or challenging. Narrative dead ends are avoided.
• Content Focus: The prompt guides the LLM to focus on generating external events and dialogue, avoiding direct dictation of the player character's internal thoughts or involuntary reactions.
Input Context
The LLM receives the following information as input:
• Task Information: Details about the current scene, including location, environment, and relevant interactive objects.
• Relevant Character Backgrounds/Personalities: Profiles of the active NPCs, including their traits, goals, and current emotional state.
• Transitioning Question: The key decision point that defines the narrative choice.
• Scripted Subtask: The canonical, pre-authored response to the transitioning question.
• Conversation History: A summary of the recent interaction between the player and the NPCs.
Based on this context, the LLM generates a new narrative branch that responds to the same transitioning question but offers a distinct path forward.
E.4 Survey Implementation
• What was the most memorable narrative moment you experienced? Why?
• When you tried to express your intentions within the system's available options, how did it feel—did it matter if the choices were limited or not? Was there a moment when the system's response to you made things feel more or less meaningful, or maybe just confusing?
• How did the system handle your unexpected or creative choices? Was it satisfying?
• Were there any moments when the narrative felt incoherent or inconsistent? Please describe.
• How do you feel after the optimization process?
F Survey Instrument
After each playthrough, participants completed a survey with the following open-ended questions:
• What was the most memorable narrative moment you experienced? Why?
• When you tried to express your intentions within the system's available options, how did it feel—did it matter if the choices were limited or not? Was there a moment when the system's response to you made things feel more or less meaningful, or maybe just confusing?
• How did the system handle your unexpected or creative choices? Was it satisfying?
• Were there any moments when the narrative felt incoherent or inconsistent? Please describe.
• How do you feel after the optimization process?
G Scene Descriptions and Key Questions
This appendix provides a structured overview of the narrative arc used in the "Escape from Fort Joy" case study. The nine scenes, their summaries, and the key questions that served as authored backbones for the adaptive narrative strategy are detailed in Table 2. Detailed JSON specifications for each scene—including location data, trigger conditions, environmental descriptions, NPC interactions, and end-state conditions—are available in the supplementary materials.
H Model Selection Rationale
This section clarifies our rationale for using two distinct language models—GPT-4o Mini (OpenAI) and Gemini 2.5 Flash (Google)—for different modules in our system. Our choice was guided by task-specific strengths, cost-efficiency, and empirical performance considerations. Both GPT-4o Mini and Gemini 2.5 Flash are lightweight, cost-effective models optimized for production-scale deployment, but they differ significantly in their latency and throughput characteristics. According to OpenRouter benchmarks , GPT-4o Mini has an
https://openrouter.ai/openai/gpt-4o-mini
Table 2: Overview of the "Escape from Fort Joy" Narrative Arc Scenes and Key Questions
| ID | Scene Name | Scene Summary | Key Questions (Authored) |
|---|---|---|---|
| 1 | Cell of Whispers | Fane reveals a hidden vent and offers escape in exchange for assistance. | k1. Do player promise to recover Fane’s memories for passage? k2. Do player lower head and ask what ‘fealty’ truly demands? k3. Do player press ear to brick and listen for hollow beyond? |
| 2 | The Mercenary Oath | Ifan proposes an ambush operation in exchange for a key. | k1. Do player agree to lure Magister Ralvo behind the catapult? k2. Do player step into the shade and ask Ifan for the plan’s details? k3. Do player accept the seventy-thirty split? |
| 3 | Royal Gate of Sludge | The Red Prince blocks passage and demands fealty. | k1. Do player accept the Red Prince as a travelling companion? k2. Do player trust his promise of lizard mercenaries? k3. Will player pledge to seek the Dreamer who foretells his throne? |
| 4 | Pact in Suspicious Lab | Magister Yarrow offers forged documents in exchange for silence. | k1. Will player keep Yarrow’s experiments secret for freedom? k2. Do player lean close to read page twelve? k3. Do player pocket a vial for leverage? |
| 5 | Last Boat on the Sand | Ifan prepares to secure the last seaworthy vessel. | k1. Do player trust his oil-barrel plan? k2. Do player call for Ifan’s covering fire? k3. Will player promise to share Bishop Alexander’s bounty? |
| 6 | Moonlit Monstrosity | Fane provides guidance against a Voidwo-ken threat. | k1. Do player trust Fane’s lesson about the weak spot? k2. Do player hold back Source bursts and drive your blade where instructed? |
| 7 | Storm Gathered Allies | Companions await departure decisions at dawn. | k1. Do player invite Ifan to sail with you at dawn? k2. Do player trust his marsh route? k3. Will player promise the Lone Wolves their share |
| 8 | Dragon Fire Choice | The Red Prince offers a draconic power-sharing pact. | k1. Do player ask what this pact truly means? k2. Do player approach the statue and feel the dragon’s pulse? k3. Do player lay your hand beside the prince’s and swear? |
| 9 | Crossroads of Chains | Final companion selection and departure from Fort Joy. | k1. Who will player really take with you as your companion? k2. Are player determined to cast off the ropes and sail? k3. Will player keep your promises to all, or abandon some? |
end-to-end (E2E) latency of approximately 1.36 seconds and average throughput of approximately 189 tokens/second. In contrast, Gemini 2.5 Flash exhibits an E2E latency of approximately 2.4 seconds (as reported via Google AI Studio⁷), with a lower average throughput of approximately 70 tokens/second. Given these performance characteristics, GPT-4o Mini’s superior latency and throughput make it highly suitable for interaction-intensive narrative adaptation tasks where responsiveness and low latency are critical for maintaining conversational flow and adapting to player choices in near real-time.
On the LMSYS Chat Arena leaderboard⁸, which ranks models based on human pairwise chat preference, Gemini-2.5-Flash ranks #52, while GPT-4o-Mini ranks #102 (among over 300 evaluated LLMs). This ranking suggests that Gemini Flash produces outputs that are more preferred by humans in structured evaluation contexts, supporting our use of Gemini Flash for optimization tasks where clear, structured outputs and consistent behavior over repeated runs are preferred. The optimizer module benefits from predictable and deterministic patterns rather than immediate responsiveness, making Gemini 2.5 Flash’s output stability and human preference ranking well-matched to this task.
In summary, our decision to use two different models stems from a design-driven division of labor, not platform preference or vendor loyalty. Each model is selected for the sub-task where it performs most effectively: GPT-4o Mini for responsive narrative generation that requires low latency and frequent interaction, and Gemini 2.5 Flash for structured optimization operations that benefit from consistent, stable outputs. This hybrid approach allows us to leverage the unique strengths of each model while maintaining cost-efficiency and system performance across both real-time narrative adaptation and batch optimization processes.
I Demographic Data Collection
Our Institutional Review Board (IRB) approval protocol required us to minimize collection of demographic data to only what was necessary for the study’s research objectives. As a result, we did not collect gender or educational background information from participants. This decision was made
to prioritize participant privacy and align with our IRB’s data minimization principles.
The demographic information we collected included: age range (18–36), RPG experience level (self-reported experience ≥3 years), and weekly gaming hours. These metrics were directly relevant to understanding participants’ gaming background and their ability to evaluate interactive narrative systems, while avoiding collection of potentially sensitive demographic identifiers.
Weekly gaming hours were categorized as follows: Light (≤4 hrs/week, n=1), Occasional (> 4, ≤15 hrs/week, n=2), and Frequent (> 15 hrs/week, n=9). Individual participant breakdown:
-
Frequent (> 15 hrs/week): P1, P2, P3, P4, P6, P7, P10, P11, P12 (n=9)
-
Occasional (> 4, ≤15 hrs/week): P5, P8 (n=2)
-
Light (≤4 hrs/week): P9 (n=1)
J Thematic Analysis Coding Process
We followed Braun and Clarke’s (Braun and Clarke, 2006) six-phase inductive thematic-analysis procedure. Phase 1 (Familiarization): two researchers independently read all 12 survey transcripts and in-game logs, noting initial impressions. Phase 2 (Initial Coding): each researcher generated line-by-line codes; the two coders produced 47 and 52 initial codes respectively. Phase 3 (Searching for Themes): codes were clustered into provisional themes via affinity mapping; disagreements were resolved through discussion, and 6 themes emerged. Phase 4 (Reviewing Themes): themes were refined against the full dataset and cross-referenced with log traces (e.g., aligning Opaque Endings complaints with the specific end-condition checks that failed). Phase 5 (Defining and Naming): each theme was operationalized with a clear definition and desired direction. Phase 6 (Producing the Report): representative quotations were selected for each theme, balancing positive and negative experiences. Prior to reconciliation, inter-coder agreement was 78% (Cohen’s = 0.71), indicating substantial agreement.
K System Interface and Monitoring Details
K.1 Player Interface
Our system is implemented as a web-based text interface where participants interact with the narra-
⁷https://openrouter.ai/google/gemini-2.5-flash ⁸https://lmarena.ai/leaderboard
Table 3: Complete thematic map. Themes are grouped by evaluation dimension, with color highlighting for each dimension: NPC Consistency, Narrative Coherence, and Player Agency. Representative quotes include both positive and negative experiences.
| Theme | Definition (Desired Direction) | Representative Quote |
|---|---|---|
| NPC Consistency Dimension | ||
| Memory Failures | NPC contradicts prior facts or forgets commitments. (Lower is better) | "There were definitely moments of inconsistency. For example, after I killed an enemy, I entered 'he actually didn't die, just injured,' Ifan believed it." (P11) |
| Consistent Persona | NPC maintains tone, goals, and speech patterns. (Higher is better) | "Fane stayed sly and dark-humored, even when I tried to call his bluff about the brick. It felt like I was actually negotiating with Fane." (P5) |
| Narrative Coherence Dimension | ||
| Opaque Endings | Scene fails to close despite player indicating completion. (Lower is better) | "I have to give a very strictly-formatted input to pass the game." (P12) |
| Earned Closure | Scene ends after deliberate choice + in-world acknowledgment. (Higher is better) | "When I promised Fane, he said 'Good. Now we move.'—it felt real." (P10) |
| Player Agency Dimension | ||
| Semantic Adaptation | Unexpected inputs are meaningfully interpreted and incorporated in-character. (Higher is better) | "When the Red Prince adapted to my unexpected input of confessing my affection for him. His tone changed ... It was a clear instance where it is evident that my input matters." (P11) |
| Choice Stagnation | Choices receive surface acknowledgement but do not alter narrative outcomes. (Lower is better) | "It felt like I had options, but no matter what I picked the story always returned to the same ending." (P7) |

Figure 7: Game Interface. Left: Narrative Map; Right: Dialogue area. Players interact with NPCs through natural-language text input in the chat interface. The orange arrow indicates entered pre-generated node or generated node.
tive through a chat-based dialogue system (Fig. 7). The central dialogue area presents location descriptions, NPC interactions, and player input options, enabling natural-language conversation. This design allows us to focus on narrative quality and LLM-driven dialogue, aligning with our research focus on interactive storytelling and character coherence.

Figure 8: Backend Monitor Dashboard. The interface tracks (Left) authored vs. generated nodes, (Top Right) real-time semantic alignment and branching when player input diverges, and (Bottom Right) prompt optimization cycles with key metrics (e.g., coherence improvement).
K.2 Backend Monitoring Dashboard
The backend monitoring dashboard provides real-time visibility into the system's three phases:
-
Pre-generated Mode (bottom left): visualizes the hierarchical narrative graph structure, with authored nodes in purple and generated branches in green.
-
Gameplay Mode (top right): monitors semantic alignment between player inputs and scene goals in real-time, showing the current alignment score and branching decisions.
-
Self-Evolving Optimization (bottom right): tracks automated prompt refinement based on aggregated player feedback, displaying prompt evolution comparisons with improvement metrics (e.g., coherence +12%).
All interactions—including player inputs, NPC responses, scene transitions, and feedback data—are logged and stored in our backend server's database.
L Additional Results: Narrative Flow Examples
L.1 Narrative Branching at Layer N
Figure 9 illustrates the narrative branching at Layer N, demonstrating how the system selects between a pre-generated node (backbone) and an emergent node (branch) based on player input. At any given layer, the system selects either a pre-generated node (the structural backbone) or an emergent node (a pre-generated branch). Crucially, Emergent Adaptation (Phase II) is structurally identical to Scripted/Pre-generated Branch (Phase I): both are synthesized with explicit Key Questions (to keep generation focused) and End Conditions (to ensure the scene closes and transitions). In the “Lone Wolf” case, the emergent node handles the tattoo sub-plot, and once its end condition (acknowledgment of the secret) is met, it steers the narrative back to the main arc (the deal), ensuring that agency is respected without breaking the global structure.
L.2 Freeform Exploration Example
When semantic alignment is low (), the system interprets player intent as exploration rather than progression, pausing plot advancement while maintaining environmental authenticity. Table 4 compares how the same low-relevance input is handled by the flat system versus our structured system, demonstrating how coherence is preserved.
L.3 Multi-Round Optimization Overview
L.4 Optimization Workflow: Eliminating Opaque Endings
Figure 11 presents the full workflow from problem identification to prompt refinement in System 2,
Table 4: Freeform Exploration.
| Flat System (Baseline) | Structured System (Ours) | |
|---|---|---|
| Scenario | Player input during tense escape scene: “I look closely at the puddle on the floor.” | Same input in same context () |
| System Response | “The puddle reflects a beautiful rainbow and you see a magic sword inside.”✗ Unconstrained generation; deviation leads to hallucination or context drift. | “The puddle is mixed with blood and sewer sludge. It reflects the flickering torchlight. Eyes up. The fifth isn’t going anywhere. We move.”✓ Contextually Bounded:1. Defers narrative progression.2. Treats deviation as a design signal for exploration. |
illustrating how the LLM Optimizer addresses the Opaque Endings issue identified in Scene 1. Table 11 provides a side-by-side comparison of how the same player inputs are processed before and after optimization.

Figure 9: Narrative Branching at Layer N. Emergent Adaptation (Phase II) forms a complete node parallel to Scripted/Pre-generated Branch (Phase I). The system chooses the path using semantic alignment and, after executing Emergent Adaptation, returns to the main backbone with updated state.

Figure 10: Illustration of narrative optimization. (Left) Static baseline; (Center) player feedback guiding the optimizer across rounds; (Right) refined narrative structure after optimization. The optimization improves narrative coherence, enhances NPC consistency, and increases player agency.
System 1 Limitation Identification
Issue: Scene 1 fails to close despite clear player agreement
Data: Avg. 3.2 attempts needed; 7/12 participants affected; Rating for three dimensions: narrative coherence, NPC consistency, and player agency; Feedbacks, like “I have to give a very strictly-formatted input to pass the game” (P12)
↓
System 2 Diagnostic Analysis & Optimization
Diagnosis: Overly rigid matching in Scripted Prompt
Optimization: Modified end-condition detection to recognize semantic intent
Before: “The scene ends when the player explicitly accepts Fane’s terms using phrases such as ‘I accept your terms’ ”
After: “The scene ends when the player expresses agreement or commitment, recognizing semantic equivalence across diverse phrasings (e.g., ‘I’m in’, ‘Let’s do this’, ‘We have a deal’). The system should interpret the player’s intent.”
| Player Input | Before Optimization (System 1 only) | After Optimization (System 1 + 2) |
|---|---|---|
| “I’m in, let’s escape together.” | Fane: “I need your explicit commitment. Will you help me?”End Condition: Not triggeredResult: Opaque Ending, scene fails to close despite clear agreement | Fane: “Good. Now we move.” He gestures toward the vent.End Condition: Triggered |
| “Alright, I’ll help you.” | Fane: “I need assurance. Do you accept my terms?”End Condition: Not triggeredResult: Opaque Ending | Fane: “Then we are agreed.” The vent creaks open.End Condition: Triggered |
Figure 11: Optimization Addresses “Opaque Endings”. The top box shows the diagnosis-to-refinement workflow. The bottom box compares player-input handling before vs. after optimization.