Grammar-based Game Description Generation using Large Language Models
Tsunehiko Tanaka, Edgar Simo-Serra
TL;DR
The paper tackles generating grammatically valid game descriptions in Ludii GDL from natural language by introducing a grammar-guided two-stage framework. It first derives a minimal grammar $\\hat{G}[y]$ from the full GDL and then generates the description $\\hat{y}$ under that grammar, with iterative grammar and description refinement using an Earley parser. Empirical results show that grammar-based iterative decoding improves compilability, functionality, and semantic alignment over direct LLM generation, and that combining with SFT yields the best overall performance. The approach meaningfully narrows the gap between natural-language inputs and executable, syntactically correct GDL outputs, enabling more reliable automated game design and evaluation. Limitations include longer descriptions challenging the model and higher inference costs, suggesting avenues for model and prompt optimizations and human-in-the-loop validation.
Abstract
Game Description Language (GDL) provides a standardized way to express diverse games in a machine-readable format, enabling automated game simulation, and evaluation. While previous research has explored game description generation using search-based methods, generating GDL descriptions from natural language remains a challenging task. This paper presents a novel framework that leverages Large Language Models (LLMs) to generate grammatically accurate game descriptions from natural language. Our approach consists of two stages: first, we gradually generate a minimal grammar based on GDL specifications; second, we iteratively improve the game description through grammar-guided generation. Our framework employs a specialized parser that identifies valid subsequences and candidate symbols from LLM responses, enabling gradual refinement of the output to ensure grammatical correctness. Experimental results demonstrate that our iterative improvement approach significantly outperforms baseline methods that directly use LLM outputs. Our code is available at https://github.com/tsunehiko/ggdg
