Abstract
This paper introduces LLM-PSRO, a novel framework that integrates code-generating Large Language Models (LLMs) with game-theoretic self-play to iteratively develop high-performance game-playing agents. Unlike traditional Deep Reinforcement Learning (RL) which produces uninterpretable "black box" policies, LLM-PSRO prompts an LLM to write Python code for bots designed to defeat the current Nash equilibrium of a population. This approach results in strategies that are not only highly effective but also fully interpretable and human-editable. Experimental results in the game of Checkers demonstrate that LLM-PSRO facilitates rapid strategy evolution, with newly generated bots quickly marginalizing the initial population.
Introduction
Historically, achieving superhuman performance in games has required computationally intensive search algorithms or Deep RL. While successful, these methods often result in policies that are opaque to human understanding. Recent attempts to use LLMs as direct game players via move-by-move prompting have frequently suffered from inconsistency and suboptimal reasoning.
LLM-PSRO addresses this gap by shifting the role of the LLM from a "player" to a "software engineer." By leveraging the reasoning and coding capabilities of LLMs, the framework generates explicit algorithmic strategies that can be audited and refined by humans, bridging the gap between high-level strategic performance and interpretability.
Methods: The LLM-PSRO Framework
LLM-PSRO adapts the Policy Space Response Oracle (PSRO) framework—a cornerstone of multi-agent RL—into the domain of software engineering agents. In this framework, the "policy" is represented as raw Python code rather than neural network weights.
The iterative process follows these steps:
- Initialization: A starting population of basic, LLM-generated Python bots is established for a target game (e.g., Checkers).
- Payoff Matrix Construction: All bots in the population play against each other to estimate win rates and build a payoff matrix.
- Nash Equilibrium Computation: Fictitious Play is used to find the Nash equilibrium of the current matrix, resulting in a "Mixture Bot"—a meta-strategy that selects bots based on the equilibrium distribution.
- LLM Best Response: A code-generating LLM (such as
CodeLlama-7b-Instruct-hf) is prompted with the source code of the Mixture Bot and tasked with writing a new Python bot to defeat it. - Selection and Expansion: Multiple candidate bots are generated and tested; the most successful candidate is added to the population, and the cycle repeats.
Experimental Setup
The authors evaluated LLM-PSRO using a custom Python-based Checkers engine. The system utilized CodeLlama-7b-Instruct-hf for zero-shot code generation. The primary goal was to observe if the LLM could consistently generate "best response" code that exploits the current population's weaknesses.
Key Results and Insights
The evaluation spanned 5 rounds of generation across 20 independent trials. The results indicated a rapid and consistent improvement in strategy quality.
As shown in the figure above, the Nash equilibrium placed significantly less probability mass on the initial generation of bots as the experiment progressed. After just five rounds, the original three starting bots retained only approximately 25% of the total probability mass. This decline is faster than their proportional share of the growing population (which would be 37.5% in round 5), proving that the LLM-generated counter-strategies were objectively stronger and successfully exploited the heuristics of earlier generations.
Code as Policy
By forcing the agent's strategy to be expressed as code, the resulting AI is inherently interpretable. Humans can read the generated heuristics, understand the logic behind specific moves, and manually adjust the code if necessary. This "Code as Policy" paradigm ensures that the evolutionary pressure of PSRO leads to robust, generalized strategies rather than overfitting to a single opponent.
Limitations and Future Work
While the current study focuses on Checkers—a deterministic, fully observable game—the authors identify several avenues for expansion. Future work will explore adapting LLM-PSRO to cooperative games, environments with partial observability (like card games), and stochastic settings. Additionally, the high-quality synthetic data generated during these tournaments (code and win/loss records) could be used to fine-tune the underlying LLMs, potentially creating a self-improving cycle of strategic reasoning and coding proficiency.
Summary updated