Hybrid Encoding for Generating Large Scale Game Level Patterns With Local Variations

Jacob Schrum, Benjamin Capps, Kirby Steckel, Vanessa Volz, Sebastian Risi

TL;DR

This paper introduces CPPNThenDirect2GAN, a hybrid evolutionary approach for generating large-scale video game levels. By combining the global structural capabilities of Compositional Pattern Producing Networks (CPPNs) with the local refinement of direct latent vector evolution—all mediated through a pre-trained Generative Adversarial Network (GAN)—the authors demonstrate a superior way to create diverse, cohesive, and playable levels for games like Super Mario Bros. and The Legend of Zelda.

What Problem Does This Paper Address?

Generative Adversarial Networks (GANs) have become a staple in Procedural Content Generation (PCG), but they suffer from a "tunnel vision" problem: they are typically trained on small, fixed-size segments. When these segments are stitched together to form a full level, the result often looks like a disjointed patchwork quilt rather than a cohesive game world. Human-designed levels rely on global patterns—like symmetry in a Zelda dungeon or repeating motifs in Mario—which standard GANs struggle to replicate across large scales.

Previous attempts to fix this used CPPNs to coordinate GAN inputs, which produced great global structure but lacked the "messy" local variety that makes levels feel organic. Conversely, directly evolving GAN inputs (Direct2GAN) creates plenty of variety but often results in structural chaos. This paper proposes a hybrid method to capture the "best of both worlds."

Methods

The researchers propose a three-stage pipeline:

  1. Pre-trained GANs: First, they train a GAN on existing level data to learn the "language" of individual level segments (e.g., what makes a valid Mario pipe or a Zelda room).
  2. CPPN2GAN (Indirect Encoding): They use a CPPN—a network that generates patterns based on spatial coordinates—to produce the latent vectors that feed into the GAN. This ensures that segments at different locations are functionally related, creating global patterns like symmetry.
  3. CPPNThenDirect2GAN (The Hybrid): Evolution starts with CPPNs to find a solid global layout. Then, a mutation can trigger a transition where the CPPN's output is "baked" into a direct vector representation. From that point on, evolution can tweak individual segments independently, allowing for fine-tuned local variations that a rigid CPPN couldn't produce.
Fig. 1: Three Genotype Encodings Applied to Zelda. (a) CPPN2GAN uses spatial coordinates to generate GAN inputs, capturing global structure. (b) Direct2GAN evolves a raw vector of inputs, allowing for local variety but lacking global cohesion. (c) CPPNThenDirect2GAN starts with (a) and transitions to (b) to combine their strengths.

To evaluate these methods, the authors used MAP-Elites, a Quality-Diversity (QD) algorithm. Instead of just finding one "best" level, MAP-Elites tries to fill a multi-dimensional archive of levels that are both high-quality (playable) and diverse (varying in decoration, space coverage, or backtracking).

Datasets

The study utilized the Video Game Level Corpus (VGLC):

  • Super Mario Bros. (1985): 12 overworld levels used to train a GAN to generate 28x14 tile segments.
  • The Legend of Zelda (1986): 18 dungeons (38 unique rooms) used to train a GAN to generate 16x11 tile rooms.

Key Insights and Ideas

  • The "Scaffolding" Effect: Starting with CPPNs acts as a structural scaffold. Once a good global "skeleton" is found, switching to direct encoding allows evolution to "flesh out" the details without being constrained by the mathematical regularities of the CPPN.
  • Symmetry vs. Playability: While CPPNs are great at making things look "designed" through symmetry, those symmetries can sometimes make a level unplayable or repetitive. The hybrid approach allows evolution to break symmetry just enough to improve gameplay flow.
  • Domain Sensitivity: The paper shows that the "best" encoding depends on the game and the desired diversity metrics. In Zelda, when diversity was defined by complex pathing (backtracking), the hybrid approach was a clear winner.

Key Results

The hybrid CPPNThenDirect2GAN approach consistently outperformed or matched the state-of-the-art across both games.

  • Quality-Diversity (QD) Scores: The hybrid method consistently reached higher QD scores—a measure of both the number of unique levels found and their quality—compared to direct evolution.
  • Zelda Breakthrough: In the "Distinct BTR" (Back-Tracking and Reachable rooms) scheme for Zelda, the hybrid approach was the undisputed champion, filling significantly more bins in the archive than either parent method.
  • Playability: Levels generated by the CPPN-based methods (pure and hybrid) were significantly more likely to be beatable by an A agent. In Zelda, the hybrid achieved 94% beatability*, compared to only 85% for the direct evolution method.
Fig. 2: Average QD Score Across 30 Runs. CPPNThenDirect2GAN (blue) is consistently the best or tied for best, showing its ability to generate high-quality, diverse content across different games and metrics.

Limitations and Future Work

  • One-Way Street: Currently, the transition from CPPN to direct encoding is permanent. Genomes cannot switch back, which might limit long-term evolutionary flexibility.
  • Fixed Scale: Unlike pure CPPNs, which can generate levels of any size by querying more coordinates, the hybrid and direct methods are tied to a fixed genome length once the transition occurs.
  • Future Directions: The authors suggest exploring Offset-HybrID, where evolution adds local "offsets" to a global CPPN pattern rather than replacing it entirely. They also propose end-to-end training where a discriminator evaluates the global structure of the entire level, not just individual segments.

Summary updated

BibTeX
@article{schrum2023hybrid,
  author = {Jacob Schrum and Benjamin Capps and Kirby Steckel and Vanessa Volz and Sebastian Risi},
  title = {{Hybrid Encoding for Generating Large Scale Game Level Patterns With Local Variations}},
  journal = {IEEE Transactions on Games},
  year = {2023},
  url = {https://openreview.net/forum?id=n2LuAVEjA0},
}
Figure