TL;DR
The authors introduce ByteSized32Refactored, a highly modular and compressed version of the ByteSized32 text game corpus designed to evaluate how well Large Language Models (LLMs) build internal world models. By abstracting common game mechanics into a foundational library (GameBasic.py), they cut the codebase in half and significantly reduced token counts. Interestingly, while this clean, hierarchical structure makes the environment highly extensible for humans, it exposes a new reasoning bottleneck for state-of-the-art LLMs like GPT-4o.
What Problem Does This Paper Address?
While LLMs excel at text generation, evaluating whether they possess a true, structured understanding of the physical world—a "world model"—remains difficult. Playing text-based games often only tests surface-level linguistic reasoning. A more rigorous test is asking an LLM to generate an interactive world simulator (a text game) based on a natural language specification (e.g., "model how to heat milk for a baby using a stove").
The existing benchmark for this task, ByteSized32, suffered from a major software engineering flaw: each of its 32 games was implemented as a massive, monolithic file. This copy-pasted, redundant design resulted in over 20,000 lines of Python code. For LLMs, this meant individual games were too token-heavy to fit effectively into prompt context windows for in-context learning, and the lack of shared structure made the corpus nearly impossible to scale or extend with new features.
Methods
The researchers refactored the entire ByteSized32 corpus by introducing a centralized foundation library called GameBasic.py.
As shown in the architecture diagram above, they decoupled the core simulation mechanics into a four-layer hierarchy:
- Core Abstraction Layer: Defines
GameObject, unifying properties and core operations. - Extension Layer: Implements specific physical behaviors like
Device(turn on/off),Container(open/close), andSubstance(temperature-based phase changes). - Derived Layer: Manages the environment (
World) and player state (Agent). - Control Layer: Orchestrates game execution via
TextGame.
Additionally, they optimized code modularity by replacing verbose if/elif control chains with dictionary-based action mapping (action_map) and streamlining string construction.
To evaluate LLMs on this new setup, they designed an iterative generation pipeline. The model receives a one-shot example and a new task specification, generates the game, and then undergoes up to three rounds of self-reflection based on error feedback from a Python interpreter.
Datasets
The primary dataset introduced is ByteSized32Refactored, a direct, structurally optimized evolution of the original ByteSized32 corpus. It contains 32 common-sense, task-specific text games focusing on everyday household chores (e.g., washing dishes, boiling water, feeding a cat).
Key Insights and Ideas
- The Abstraction Paradox: Clean, object-oriented code is easier for humans, but harder for LLMs. The refactored corpus actually caused a drop in initial code validity. Monolithic code contains explicit, repetitive action cues that allow LLMs to pass shallow syntax checks without deep reasoning. Hierarchical code requires the model to reason across abstract classes, exposing limitations in LLM class-based code generation.
- Drastic Token Efficiency: By eliminating redundant class definitions across files, the average token count per game dropped from 6,792 to 2,896 (a ~57% reduction). This allows researchers to pack substantially more examples into an LLM's context window for multi-shot prompting.
- Reflection Bridges the Gap: While the abstract structure initially trips up LLMs, providing the model with Python interpreter error messages during a reflection phase allows it to rapidly correct its structural mistakes.
Key Results
The refactoring successfully shrank the total corpus size from 20k to 10k lines of Python code, reducing the average lines of code per game by 50.9%.
When evaluating GPT-4o on the refactored corpus versus the original, the authors observed a mix of performance shifts:
- Winnability & Compliance: Games generated using the refactored structure were significantly more functional. GPT-4o's winnability score (whether the game can actually be completed successfully) jumped from 34% on the original corpus to 54% on the refactored corpus after reflection.
- Technical Validity: Conversely, the percentage of fully runnable games dropped from 82.29% (original) to 61.46% (refactored), confirming that tracking dependencies across a hierarchical library remains a difficult challenge for current models.
Limitations and Future Work
The authors note several limitations in their current framework:
- Structural Bias: Altering the token distribution and code structure might introduce unforeseen biases rather than purely measuring world-modeling capabilities.
- Inefficient Reflection: The current self-reflection loop requires the LLM to regenerate the entire program from scratch for a single error, which is computationally expensive. Future iterations should focus on generating code diffs.
- Evaluation Approximations: The metrics used (validity, compliance, alignment, winnability) are proxies for world modeling. The authors suggest that future work should incorporate invariant testing, fuzzing techniques, and multi-judge LLM evaluations to improve verification.
Summary updated