STORY2GAME: Generating (Almost) Everything in an Interactive Fiction Game

Eric Zhou, Shreyas Basavatia, Moontashir Siam, Zexin Chen, Mark O. RiedlarXiv 2025 · DOI

Introduction

Interactive fiction (IF) has long struggled with a "Goldilocks" problem: traditional games like Zork are logically sound but restricted to hard-coded actions, while modern AI-driven experiences like AI Dungeon offer infinite freedom but often lack logical grounding. STORY2GAME is a novel framework that bridges this gap by using Large Language Models (LLMs) to generate entire interactive fiction games from scratch—including the underlying world state and executable Python code.

The STORY2GAME Pipeline

The researchers developed a multi-stage pipeline, powered by GPT-4o-mini, to translate narrative concepts into functional game engines. The process begins with story generation, where the LLM identifies a sequence of events, preconditions, and effects. This is followed by world generation, where rooms are placed on a grid and populated with items and NPCs. Finally, the system translates these elements into executable code, creating data structures for inventory and custom attributes.

Overview of the STORY2GAME multi-stage pipeline for generating executable game code from narrative prompts.

Dynamic Action Generation

The system's most significant innovation is its ability to handle "off-script" player actions. If a player attempts an action not in the original story (e.g., "distract the guard"), the engine calls the LLM to determine if new objects or attributes are needed and generates the necessary code on the fly. This includes recursively creating "preceding events" to ensure logical consistency, such as requiring a player to find a specific item before performing a complex task.

Flowchart of the dynamic action generation system, which handles off-script player actions by recursively generating preconditions and effects.

Key Results and Insights

  • High Compilation Success: The system achieved a compilation success rate of 93% to 97% for story-based actions, demonstrating the LLM's ability to generate functional game logic.
  • Semantic Challenges: While code compilation for novel actions was high (~80%), the "semantic success rate"—how well the action matched human common sense—was lower at ~60%. For example, the engine might fail to realize that lighting a fire should affect the visibility of all items in a room.
  • The Naming Ambiguity Problem: A primary failure point was found to be entity resolution. If the LLM referred to a "Key" in one instance and a "Metallic Key" in another, the generated code often treated them as two distinct objects, breaking the game logic.

Limitations and Future Work

Current limitations include the engine's struggle with environmental effects (e.g., fire destroying items) and potential narrative interference, where a dynamic action might accidentally make the main plot impossible to finish. Future work will focus on better entity resolution and ensuring dynamic actions remain aware of the overarching narrative goals. STORY2GAME represents a major step toward creating infinite, logically consistent game worlds generated in real-time.

Summary updated

BibTeX
@misc{zhou2025story,
  author = {Eric Zhou and Shreyas Basavatia and Moontashir Siam and Zexin Chen and Mark O. Riedl},
  title = {{STORY2GAME: Generating (Almost) Everything in an Interactive Fiction Game}},
  year = {2025},
  eprint = {2505.03547},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.03547},
}
Figure