Abstract
Recent advancements in Large Language Models (LLMs) have enabled automated code generation, yet applying these models to the complex, state-dependent logic of games remains a significant challenge. This paper introduces a comprehensive benchmark for "program search" across 29 distinct gaming tasks. By evaluating 11 LLMs using a hill-climbing optimization framework, we identify that reasoning-centric models and iterative search strategies with frequent restarts significantly outperform traditional long-run optimizations.
Introduction
Historically, program synthesis was confined to simple tasks or highly constrained Domain-Specific Languages (DSLs). While modern LLMs demonstrate proficiency in general-purpose coding, the "messy" reality of game development—incorporating physics, complex rule-based puzzles, and framework-specific libraries—presents a new frontier. This study addresses the lack of standardized measurement for LLM performance in searching for optimal programmatic solutions, such as agent policies or game heuristics, within dynamic environments.
Methodology: The Program Search Framework
The researchers propose a General Framework for Program Search based on a neurosymbolic hill-climbing algorithm. This approach combines the creative, probabilistic generation of LLMs with the rigid, symbolic verification of code interpreters.
The process follows five iterative steps:
- Prompting: The LLM receives a task description and initial state.
- Generation: The model generates a function in Python or Java.
- Execution & Repair: Code is executed in a safe subprocess. If a runtime or syntax error occurs, the error trace is returned to the LLM for up to three repair attempts.
- Evaluation: Executable code is scored against a fitness function (e.g., game score).
- Iteration: The best-performing code informs the next prompt, guiding the LLM toward further optimization.
Experimental Setup and Domains
The benchmark spans five major environments across Python and Java:
- Minatar: Miniature Atari environments for synthesizing agent policies.
- Baba is You: A logic puzzle game requiring rule manipulation.
- Vehicle Driving: A physics-based environment testing navigation and momentum control.
- Maze Generation: A task focused on Procedural Content Generation (PCG).
- Tabletop Games (TAG): A Java-based framework for 12 board and card games (e.g., Poker, Seven Wonders), where LLMs write state-evaluation heuristics.
Key Insights and Discussion
The evaluation revealed several critical trends in how LLMs handle programmatic search:
Reasoning vs. Scale
Performance was more closely tied to a model's "reasoning" capabilities than its raw parameter count. OpenAI’s o1-mini, a model specifically optimized for chain-of-thought reasoning, emerged as the top performer in Python domains. This suggests that the ability to logically decompose game rules is more valuable than broad linguistic knowledge.
The "Restart" Advantage
A practical finding of the study is that frequent "restarts" (running the search algorithm multiple times with fewer iterations) is more effective than a single, prolonged optimization run. LLMs often fall into "logic loops"; starting fresh allows the model to explore diverse areas of the solution space.
Domain-Specific Challenges
In the Java TAG experiments, models frequently suffered from "library hallucination," attempting to use standard API calls (e.g., .size()) instead of the framework’s specific methods (e.g., .getSize()). Furthermore, in physics-heavy tasks like Vehicle Driving, models struggled with "stopping" logic, failing to account for momentum and friction despite successful navigation.
Results
OpenAI’s o1-mini ranked first overall in Python tasks, followed by GPT-4o and Claude 3.5 Sonnet. In the Java domain, Google’s Gemini 2.0 Flash took the top spot, also proving to be the most cost-efficient high-performance model.
Claude 3.5 Sonnet was particularly notable in the Baba is You domain, solving 8 out of 10 levels. Most other models struggled with levels requiring the destruction of existing rules. Reliability also varied; while OpenAI and Gemini models consistently produced executable code, Mistral models had the highest failure rates.
Conclusion
While current LLMs show promise in program search, the reliance on "one-shot" function generation remains a bottleneck. Future work should explore "agentic" workflows, where a manager LLM coordinates specialized sub-modules. Additionally, moving beyond text-based state descriptions to multi-modal inputs could allow models to better understand the spatial and visual nuances of game environments.
Summary updated