ChatPCG: Large Language Model-Driven Reward Design for Procedural Content Generation

In-Chang Baek, TaeHwa Park, Jinha Noh, Cheong-mok Bae, Kyung-Joong Kim

Abstract

Reward function design is a critical yet labor-intensive aspect of Reinforcement Learning (RL), particularly in Procedural Content Generation (PCG) where abstract design goals like "balance" and "diversity" must be mathematically formalized. We present ChatPCG, a framework that leverages Large Language Models (LLMs) to automate this process. ChatPCG translates high-level textual descriptions into executable Python reward functions and iteratively aligns them using real-world game logs. Our results in a multiplayer boss raid environment demonstrate that ChatPCG-generated rewards can surpass human-engineered baselines in creating specialized and diverse game content.

Introduction: The Reward Design Bottleneck

In Reinforcement Learning, the reward function serves as the primary signal for agent behavior. However, designing these functions is often considered a "black art," requiring human experts to engage in tedious trial-and-error to translate qualitative concepts like "fun" or "role differentiation" into rigid mathematical formulas. In PCG, this bottleneck is particularly acute; simple rewards often lead to homogenous, uninteresting content. ChatPCG addresses this by using LLMs to bridge the gap between high-level design intent and low-level executable code.

The ChatPCG Framework: From Insights to Code

ChatPCG utilizes a two-stage pipeline, primarily powered by GPT-4-turbo, to generate and refine reward functions:

  1. Insight to Reward Generation: The LLM receives a textual description of the game environment and design constraints. It generates "design insights" and translates them into modular Python code. This modularity ensures the reward design is transparent and maintainable.
  2. Iterative Self-Alignment: To ground the LLM's abstract logic in game reality, the framework runs the generated code against real game logs. The LLM then reviews the resulting reward values and receives feedback (e.g., "the diversity score is too low"). It uses this feedback to refine the code over multiple iterations ($N_{align} = 5$).
The ChatPCG pipeline: from game log collection and insight generation to iterative self-alignment and agent training.

The framework employs Chain-of-Thought (CoT) prompting, which encourages the model to explain its reasoning step-by-step before writing code, significantly reducing hallucinations in complex coding tasks.

Experimental Evaluation: RaidEnv II

The researchers evaluated ChatPCG using RaidEnv II, a multiplayer boss raid environment where four players must collaborate to defeat a boss. The system was tasked with generating character configurations (health, speed, damage) that met specific win-rate targets while maintaining high diversity and role differentiation. Ground truth for the self-alignment phase was provided by 1,500 rows of gameplay data collected from heuristic agents.

Results and Key Findings

ChatPCG was compared against human-designed rewards ($R_{WR}$) and standard LLM prompting (IO). The results highlight the framework's ability to capture complex design principles:

  • Role Differentiation: Using the CoT-based LLM reward, the Team Build Score (Tbs)—measuring character variance within a team—reached 0.404, significantly outperforming the human-designed baseline of 0.288.
  • Controllability: A "Hybrid" approach ($R_{HYB}$), which combines LLM-generated insights with standard win-rate rewards, achieved the best Controllability (0.19), accurately hitting the designer's target win-rate.
  • Diversity: LLM-driven rewards consistently produced a wider variety of valid game content compared to traditional methods, which often converge on a single optimal but repetitive solution.
Performance comparison of ChatPCG against human-designed (R_WR) and simple LLM (IO) baselines across Controllability (Ctr), Diversity (Div), and Team Build Score (Tbs).

Conclusion

ChatPCG demonstrates that LLMs can serve as effective design partners, capable of translating complex game design principles into functional mathematical rewards. The study underscores that iterative feedback is mandatory for grounding LLM logic. While human intervention is still required for final weight tuning, ChatPCG marks a significant step toward automating the creative and technical complexities of procedural content generation.

Summary updated

BibTeX
@inproceedings{baek2024chatpcg,
  author = {In-Chang Baek and TaeHwa Park and Jinha Noh and Cheong-mok Bae and Kyung-Joong Kim},
  title = {{ChatPCG: Large Language Model-Driven Reward Design for Procedural Content Generation}},
  booktitle = {CoG},
  year = {2024},
  url = {https://openreview.net/forum?id=LO2oHh1pQw},
}
Figure