TL;DR
This paper introduces ScriptDoctor, a system that uses Large Language Models (LLMs) and tree search to automatically generate complete, playable games in the PuzzleScript domain. By integrating LLM code generation with automated compilation, playtesting, and feedback loops, ScriptDoctor demonstrates a promising step towards open-ended, automated game design.
What Problem Does This Paper Address?
The field of Automatic Game Design (AGD) has seen growing interest in using LLMs for tasks like generating game code or assets. However, much of this work relies heavily on human supervision and lacks robust automated evaluation. This leaves open questions about the quality of LLM-generated games and how to effectively integrate these models into longer, automated design pipelines. The authors aim to address this by creating a system that can autonomously generate and test entire games, using a constrained domain (PuzzleScript) to make the problem tractable.
Methods
ScriptDoctor employs an iterative pipeline:
- LLM Code Generation: A Large Language Model (LLM) generates PuzzleScript code.
- Compilation & Parsing: The generated code is compiled by the PuzzleScript engine. Compilation errors or warnings are captured. A Context-Free Grammar (CFG) is used to identify syntax errors.
- Automated Playtesting: If the code compiles, a Breadth-First Search (BFS) solver acts as a player agent to test each level for solvability. The solver explores up to 1 million nodes.
- Feedback Loop: The LLM receives feedback including compilation errors, warnings, and playtesting results (solvability, number of nodes explored, solution length).
- Prompt Augmentation: The LLM's prompt is augmented with human-authored examples, documentation, and design ideas generated by a separate "brainstorming" agent.
This process repeats until a functional game (compiles and has solvable levels with solutions longer than 10 moves) is generated, or a maximum of 10 attempts is reached.
Datasets
- Human-authored PuzzleScript Games: A dataset of 610 human-made PuzzleScript games was scraped from a public archive ([19]) and used for few-shot prompting. This dataset is crucial for grounding the LLM's output.
Key Insights and Ideas
- The Power of Few-Shot Prompting: Including human-authored examples in the LLM's prompt significantly improves the quality of generated games, leading to higher compilation rates and more solvable levels.
- Reasoning Models Outperform: LLMs with stronger reasoning capabilities (like o1 and o3-mini) demonstrate better performance in generating functional and complex PuzzleScript games compared to general-purpose models like GPT-4o.
- Diminishing Returns on Context Length: While increasing the LLM's context window (by adding more few-shot examples) initially improves game generation, the benefits plateau after around 30,000 tokens. This suggests that simply adding more examples might not be the most effective way to improve complex reasoning.
- Automated Metrics are Key: The integration of automated compilation and playtesting provides crucial feedback for the LLM, enabling an iterative generation process without constant human intervention.
Key Results
- Improved Functionality: Few-shot prompting with human games increased the proportion of games that successfully compile and are solvable.
- Increased Complexity: Generated games also showed increased solution complexity, as measured by the number of nodes explored by the BFS solver.
- Model Performance: Reasoning models (o1, o3-mini) outperformed GPT-4o in generating compilable and playable games.
- Context Length Impact: Increasing context length up to 30,000 tokens improved compilability, but further increases showed diminishing returns.
Limitations and Future Work
- Solution Length vs. Quality: The paper notes that while they aim for solutions longer than 10 moves, many human games with shorter solutions can still be interesting. The current metrics might not fully capture "game quality" beyond basic solvability and complexity.
- "Broken" Mechanics: The system sometimes generates complex games that are solvable "in spite of" or "as a result of" their mechanics being broken. More targeted feedback mechanisms are needed to diagnose and fix such issues.
- Future Directions:
- Leveraging ScriptDoctor's metrics to guide a novelty-seeking evolutionary loop.
- Using the generated games as a dataset for fine-tuning smaller LLMs.
- Developing more sophisticated feedback mechanisms, potentially involving vision-language models to analyze gameplay frames.
- Investigating fine-tuning LLMs specifically for game generation.
Summary updated