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 (PCG) has been significantly advanced by machine learning, particularly Generative Adversarial Networks (GANs). While GANs are adept at capturing the aesthetic "vibe" and spatial relationships of human-authored levels, they often fail to respect functional logic. For instance, a GAN-generated Zelda dungeon might be visually appealing but unplayable because a key is inaccessible or an exit is missing.

To address this, researchers have developed a "generate-then-repair" framework. This system combines the creative flair of GANs with the rigorous logical guarantees of Mixed Integer Linear Programming (MIP), ensuring that every generated level is 100% playable while maintaining its stylistic integrity.

Methodology: The Generate-then-Repair Pipeline

The framework operates in two distinct stages: generation and repair.

The generate-then-repair pipeline: Random noise is fed into a GAN to create an initial level, which is then refined by a Mixed-Integer Linear Program to meet playability criteria.
  1. Generation: A Deep Convolutional GAN (DCGAN) is trained on a small set of human-authored levels (e.g., 50 levels from The Legend of Zelda). It produces an initial grid of tiles that mimics the training data's style but may contain playability errors.
  2. Repair: The "broken" grid is passed to a MIP solver. The goal of the MIP is to find a valid, playable version of the level that minimizes the Edit Distance from the GAN's original output.

Reachability as Network Flow

The technical core of the repair step involves modeling playability as a network flow problem. To ensure a player can reach a key and then the door, the system treats the path as a "flow" that must move from the start position to objectives without crossing impassable tiles like walls. By using a flow-based edit distance rather than a simple Hamming distance, the solver can "nudge" objects to nearby tiles at a low cost, preserving the GAN’s structural intent rather than simply deleting and recreating items.

Evaluation and Results

The framework was tested on The Legend of Zelda and Pac-Man domains within the General Video Game AI (GVGAI) framework.

An example of a Zelda-like level generated and repaired by the framework, featuring a player, key, door, and enemies within a structured environment.

The results demonstrate significant improvements over standalone generative models:

  • Guaranteed Playability: While raw GAN outputs were playable only 24.3% of the time, the GAN+MIP framework achieved 100% playability.
  • Diversity and Fidelity: The approach produced a higher percentage of unique, playable levels (85.1%) compared to state-of-the-art self-attention GANs. Furthermore, KL divergence measures showed that the repaired levels remained closer to human-authored distributions (0.108) than raw GAN outputs (0.272).
  • Efficiency: Repairs are computationally inexpensive, averaging just 0.13 seconds per level, making the system suitable for real-time generation.

Discussion and Future Work

A key insight from this research is that style and logic are not mutually exclusive. Human designers often place keys far from doors to encourage exploration; the GAN+MIP approach preserves this learned spatial "tension," resulting in more engaging paths than random constraint solvers.

However, challenges remain. Defining MIP constraints for complex games requires significant domain expertise. Additionally, while the model excels at grid-based movement, extending it to games with complex physics (like platformers) or subjective aesthetic preferences will require further investigation and human user studies.

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