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.
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.
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