Distilling Game Code World Model Generation into Lightweight Large Language Models

Tyrone Serapio, Arjun Prakash, Haoyang Xu, Kevin Wang, Amy GreenwaldarXiv 2026

TL;DR

This paper demonstrates how to distill the ability to generate executable game environments (Game Code World Models) from natural language into a lightweight, 3B-parameter model. By combining Supervised Fine-Tuning (SFT) with Reinforcement Learning with Verifiable Rewards (RLVR), the authors successfully shift the heavy computational burden away from expensive inference-time debugging loops directly into the model's weights.

What Problem Does This Paper Address?

AI agents often rely on "world models"—internal simulations of their environment—to plan actions using algorithms like Monte Carlo Tree Search (MCTS). Traditionally, writing the code for these simulations is a painstaking manual task. While frontier Large Language Models (LLMs) can automatically translate natural language game rules into executable Python code (Game Code World Models, or GameCWMs), they currently require massive model sizes and expensive, slow "self-debugging" loops at inference time to get the code right.

This paper tackles these accessibility and scalability barriers. The authors investigate whether the complex reasoning required to generate syntactically and semantically correct game engines can be internalized by a lightweight, open-weight model (Qwen2.5-3B-Instruct) via post-training.

Methods

The authors propose a two-stage post-training pipeline paired with a novel hierarchical verification framework:

  1. Supervised Fine-Tuning (SFT): Aligns the base model to the target API structure, type signatures, and coding conventions.
  2. Reinforcement Learning with Verifiable Rewards (RLVR): Uses Group Relative Policy Optimization (GRPO) to optimize the model based on direct execution feedback, bypassing the need for a separate critic model.
Figure 1: Our Distillation Pipeline. Unlike prior approaches that rely extensively on test-time compute, we aim to dis- till game-theoretic logic into the model weights through post-training. Like many LLM pipelines, ours involves two stages: Supervised Fine-Tuning (SFT) followed by RLVR us- ing GRPO. To enable our approach, we define a dataset of prompt-code pairs for use during SFT, and a hierarchical verification framework for automatically evaluating gen- erated code, which provides reward signals that reinforce the syntactic correctness and semantic validity of generated GameCWMs during RLVR.

To provide a fast, sparse reward signal during RL, they developed a Hierarchical Verification Framework consisting of four gated tiers:

  • Tier 1: Static Analysis: Checks if the code compiles cleanly and implements all required API methods.
  • Tier 2: Dynamics (Fuzzing): Runs 100 random rollouts to ensure core engine invariants hold (e.g., determinism, state immutability, and proper terminal state handling).
  • Tier 3: Semantic Rule Adherence: Validates the engine against a sparse set of representative gameplay trajectories ("scenarios") generated a priori by a frontier model.
  • Tier 4: Information Consistency: For imperfect-information games, verifies that hidden state boundaries are maintained via a history-resampling method.

Datasets

The authors curated a dataset of 30 extensive-form games implemented via an OpenSpiel-like API. The games span perfect and imperfect information settings, as well as standard and completely novel/out-of-distribution (OOD) games designed to prevent data contamination.

  • Training Set: 23 games (e.g., Tic-Tac-Toe, Chess, Blackjack, Kuhn Poker).
  • Evaluation Set (Held-Out): 7 games used to test generalization capabilities.
Table 1: Categorization of held-out games based on informa- tion type and distribution.

Key Insights and Ideas

  • SFT can cause overfitting on complex logic: While SFT aligns the model to the correct API format, it can actually degrade performance on complex, unseen games. For example, on Gin Rummy, the SFT-only model blindly forced learned code templates onto the environment, introducing syntax errors and tanking its score compared to the base model.
  • RLVR provides the necessary semantic course-correction: The best results came from applying RLVR after SFT. SFT teaches the model the structural format, while RLVR refines the underlying game logic through execution-based rewards.
  • Internalizing test-time compute is viable: The post-trained 3B model showed significant, statistically isolated improvements, proving that lightweight models can internalize environment-tracking capabilities previously reserved for frontier models.
  • Imperfect information remains an open challenge: Tracking hidden variables and epistemic boundaries (e.g., what a player knows versus what is hidden in the deck) is incredibly difficult. Small models often default to writing code stubs or returning constant placeholders when tasked with complex resampling logic.

Key Results

  • Overall Performance: The full SFT+GRPO pipeline achieved a mean verification score of 53.2%, outperforming the Base model (47.3%) and SFT-only model (49.0%) with statistical significance. However, a gap still remains to GPT-4o at 66.7%.
Table 2: Overall mean verification score with 90% and 95% confidence intervals across held-out games. Intervals are computed over 25 generations per game. SFT+GRPO yields the strongest Qwen-based model. Note the statistically sig- nificant separation between it and the base model.
  • Semantic Improvements: SFT+GRPO nearly doubled the model's semantic rule adherence, climbing to 14.4% from the Base model's 8.5%.
Table 3: Per-tier average verification scores across all held- out games. Values are averaged across 25 sample genera- tions per game. Information is averaged only over imperfect- information games. SFT+GRPO yields the strongest perfor- mance in all categories among the post-trained models.

Limitations and Future Work

  • Imperfect Information Failure: The distilled 3B model still struggles heavily with complex hidden-information mechanics, scoring 0% on semantic tests for games like Gin Rummy.
  • Proxy Evaluation Metrics: The verification framework evaluates code correctness but does not measure downstream gameplay quality when paired with actual MCTS solvers. Subtle bugs could still impact planning.
  • Future Directions: The authors propose scaling up the base model size (e.g., to 14B parameters), expanding the dataset with more diverse imperfect-information games, and exploring hybrid approaches that combine post-training with lightweight, iterative test-time refinement loops.

Summary updated

BibTeX
@misc{serapio2026distilling,
  author = {Tyrone Serapio and Arjun Prakash and Haoyang Xu and Kevin Wang and Amy Greenwald},
  title = {{Distilling Game Code World Model Generation into Lightweight Large Language Models}},
  year = {2026},
  eprint = {2605.24375},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.24375},
}
Figure