Video Game Level Repair via Mixed Integer Linear Programming

Hejia Zhang, Matthew C. Fontaine, Amy K. Hoover, Julian Togelius, Bistra Dilkina, Stefanos Nikolaidis

Introduction

Procedural Content Generation via Machine Learning (PCGML) has revolutionized how game environments are created, allowing for the rapid generation of diverse content. However, deep learning models like Generative Adversarial Networks (GANs) often lack an understanding of functional logic. While they excel at mimicking the visual style and local spatial patterns of human-authored levels, they frequently produce "unplayable" outputs—levels where essential items like keys are inaccessible or exit doors are missing entirely. This paper introduces a framework that combines the aesthetic strengths of GANs with the formal rigor of Mixed Integer Linear Programming (MIP) to ensure 100% playability without sacrificing design quality.

The GAN+MIP Framework

The authors propose a "generate-then-repair" pipeline designed to bridge the gap between visual mimicry and functional requirements.

The GAN+MIP 'generate-then-repair' pipeline.

1. Generation Phase

A Deep Convolutional GAN (DCGAN) is trained on a small dataset of human-designed levels (e.g., 50 levels for The Legend of Zelda). The generator learns to map random noise to level layouts that resemble the training data. While visually consistent, these raw outputs often fail basic playability tests.

2. Repair Phase via MIP

The GAN's output serves as a "proposal" for the MIP solver. The objective is to find the playable level that has the minimum "edit distance" from the GAN's original layout. This is formulated as a minimum-cost network flow problem, where "flow" represents the movement, addition, or deletion of tiles (walls, enemies, items).

The MIP enforces several critical constraints:

  • Uniqueness: Each grid cell contains exactly one object.
  • Domain Rules: Specific requirements for the game genre (e.g., exactly one player, one key, and one door).
  • Reachability: Flow equations ensure a valid path exists from the player's start position to the key, and subsequently to the exit door.

Experimental Results

The framework was evaluated on The Legend of Zelda and Pac-Man environments. The results demonstrate a significant improvement over baseline methods.

Visual comparison of level generation methods against human-authored baselines.

Playability and Uniqueness

The raw GAN only produced playable levels 24.3% of the time. In contrast, the GAN+MIP framework achieved 100% playability. Furthermore, 85.1% of the generated levels were both playable and unique, indicating that the repair process does not lead to repetitive or "collapsed" outputs.

Aesthetic Fidelity

To measure how well the system preserved the "soul" of human design, the researchers used KL-divergence to compare tile distributions and analyzed average path lengths. Human levels typically feature longer, more complex paths (avg. 12.5 tiles). GAN+MIP levels maintained a respectable average path length of 8.6 tiles, significantly outperforming a "random MIP" baseline (7.8 tiles), which tended to create shorter, more sterile paths.

Discussion and Future Work

The GAN+MIP approach proves that optimization techniques can effectively "rescue" the unplayable majority of a GAN's output distribution, thereby increasing the overall diversity of usable content. The MIP solver is highly efficient, taking an average of only 0.13 seconds to repair a level, making it suitable for real-time design tools.

Future research directions include:

  • Physics-Based Games: Adapting the framework for non-grid games (like Super Mario Bros.) where playability depends on jump physics.
  • Automated Constraint Learning: Reducing the need for manual MIP engineering by learning game rules directly from data.
  • Differentiable Repair: Integrating the MIP layer into the GAN's training loop to allow the generator to learn playability constraints end-to-end.

In conclusion, by treating level repair as a constrained optimization problem, this work provides a robust path forward for creating PCGML systems that are both creative and functionally reliable.

Summary updated

BibTeX
@inproceedings{zhang2020video,
  author = {Hejia Zhang and Matthew C. Fontaine and Amy K. Hoover and Julian Togelius and Bistra Dilkina and Stefanos Nikolaidis},
  title = {{Video Game Level Repair via Mixed Integer Linear Programming}},
  booktitle = {AIIDE},
  year = {2020},
}
Figure