Finding Game Levels with the Right Difficulty in a Few Trials through Intelligent Trial-and-Error

Miguel González Duque, Rasmus Berg Palm, David Ha, Sebastian Risi

Abstract

Achieving the "Goldilocks zone" of game difficulty—the flow state—is a persistent challenge in game design. This paper proposes a novel approach to Dynamic Difficulty Adjustment (DDA) by combining MAP-Elites for diverse level generation with Bayesian Optimization for rapid online adaptation. By treating level selection as an Intelligent Trial-and-Error (IT&E) problem, the system successfully identifies levels tailored to specific player skills in as few as one to three trials.

Introduction: The Challenge of Flow

In game design, the "Goldilocks zone"—where a game is neither frustratingly hard nor boringly easy—is known as the Flow State. Achieving this through Dynamic Difficulty Adjustment (DDA) is a long-standing challenge.

Most current DDA methods are limited: they either tweak a single variable (like enemy health) or require hundreds of iterations of Procedural Content Generation (PCG) to find a suitable level. This research addresses the efficiency gap: How can we find a complete, custom-tailored level for a specific player's skill level almost instantly?

Methodology: Intelligent Trial-and-Error

The authors adapt the Intelligent Trial-and-Error (IT&E) algorithm, originally designed to help robots recover from physical damage in seconds, and apply it to game levels. The process happens in two main stages:

1. Offline Map Creation (MAP-Elites)

Before a player ever starts, the system uses the MAP-Elites algorithm to evolve a "behavioral map" of levels. These levels vary across three dimensions:

  • Leniency: The number of enemies.
  • Reachability: The distance between the player, the key, and the goal.
  • Space Coverage: How crowded or open the level layout is.

Instead of just making "easy" levels, they use a custom fitness function that rewards levels where an AI agent achieves a 60% win rate—the theoretical sweet spot for engagement.

2. Online Adaptation (Bayesian Optimization)

When a new "player" (represented by a different AI agent) enters, the system uses the existing maps as a prior. It uses Gaussian Process Regression to predict how the new player will perform across the entire map. After the player tries one level, the system updates its statistical model and picks the next level most likely to hit the target difficulty, balancing exploration (trying unknown areas) and exploitation (picking likely winners).

The IT&E framework: (a) Offline generation of behavioral maps for various agents; (b) Online adaptation using Bayesian Optimization to select levels; (c) The resulting tailored game level.

Experimental Setup

The study utilizes the General Video Game AI (GVGAI) framework, specifically a Zelda-like dungeon crawler.

  • Agents: The system was tested using eight different AI planning agents (ranging from "DoNothing" and "Random" to sophisticated algorithms like Monte Carlo Tree Search (MCTS) and Open Loop Expectimax Tree Search (OLETS)). These agents act as proxies for human players with varying skill levels.
  • Levels: The levels are generated using the Video Game Description Language (VGDL).

Key Insights: Visualizing Skill Blind Spots

The core "aha moment" is that the difficulty landscape for one type of AI agent is a remarkably good predictor for another. Even if Agent A is much smarter than Agent B, the relative difficulty of levels (e.g., "levels with more enemies are harder") remains consistent enough to jump-start the search.

The MAP-Elites archives act as a "fingerprint" for an AI's intelligence. For example, the One Step Look-ahead (OSLA) agent struggles immensely with "Reachability" because it can't plan for long-distance goals, whereas MCTS handles distance easily but is more sensitive to enemy density.

Behavioral maps for different AI agents showing win rates across various level dimensions. These 'fingerprints' highlight how different algorithms struggle or excel with specific level features.

Key Results

  • Rapid Convergence: In most cases, the algorithm found a level with the ideal difficulty (50%–70% win rate) in fewer than 10 trials.
  • High Success Rates: When moving between similar high-performing agents (like OLETS to MCTS), the system often found the perfect level in just 1.2 to 1.3 iterations.
  • Robustness: Even when using a "Random" agent's map as a starting point for a more complex agent, the system was able to find a compensatory level in about 3.5 trials.
  • Asymmetric Transfer: The authors noted it is easier to find a level for a "basic" agent using a "skilled" agent's map than vice-versa. Skilled agents find almost everything easy, making their maps less descriptive for lower-skill players.

Limitations and Future Work

While AI agents are great proxies, they are more predictable than humans. The authors acknowledge that testing with actual human players is the necessary next step. Additionally, the dimensions of the map (leniency, reachability) were hand-crafted; future work could use Variational Autoencoders (VAEs) to learn these behavioral dimensions automatically. Finally, while the current system picks from a static archive, a more advanced version could potentially generate entirely new levels on-the-fly based on the Gaussian Process's predictions.

Summary updated

Abstract

Methods for dynamic difficulty adjustment allow games to be tailored to particular players to maximize their engagement. However, current methods often only modify a limited set of game features such as the difficulty of the opponents, or the availability of resources. Other approaches, such as experience-driven Procedural Content Generation (PCG), can generate complete levels with desired properties such as levels that are neither too hard nor too easy, but require many iterations. This paper presents a method that can generate and search for complete levels with a specific target difficulty in only a few trials. This advance is enabled by through an Intelligent Trial-and-Error algorithm, originally developed to allow robots to adapt quickly. Our algorithm first creates a large variety of different levels that vary across predefined dimensions such as leniency or map coverage. The performance of an AI playing agent on these maps gives a proxy for how difficult the level would be for another AI agent (e.g. one that employs Monte Carlo Tree Search instead of Greedy Tree Search); using this information, a Bayesian Optimization procedure is deployed, updating the difficulty of the prior map to reflect the ability of the agent. The approach can reliably find levels with a specific target difficulty for a variety of planning agents in only a few trials, while maintaining an understanding of their skill landscape.
BibTeX
@inproceedings{duque2020finding,
  author = {Miguel González Duque and Rasmus Berg Palm and David Ha and Sebastian Risi},
  title = {{Finding Game Levels with the Right Difficulty in a Few Trials through Intelligent Trial-and-Error}},
  booktitle = {CoG},
  year = {2020},
  url = {https://openreview.net/forum?id=pa1cYOL4dVQ},
}
Figure