Mario Level Generation From Mechanics Using Scene Stitching

Michael Cerny Green, Luvneesh Mugrai, Ahmed Khalifa, Julian Togelius · DOI

Abstract

This paper presents a novel approach to procedural level generation for Super Mario Bros. that prioritizes mechanical experience over structural layout. By utilizing a "scene stitching" method powered by a dual-population genetic algorithm (FI-2Pop), the system assembles pre-evolved mini-scenes to replicate specific gameplay sequences from target playtraces. Results demonstrate that the system produces highly playable levels that accurately mirror the rhythm and mechanics of original game levels, significantly outperforming greedy and random baselines. This method shifts the focus of procedural content generation (PCG) from tile-based structural design to experience-driven design.

Introduction

Procedural Content Generation (PCG) has traditionally focused on creating visually diverse or structurally sound environments. However, these methods frequently overlook the "mechanical experience"—the specific sequence of actions a player performs, such as a short jump followed immediately by a shell kill. If a player enjoys a particular challenge or needs to practice a specific set of moves, current generators struggle to provide new levels that capture that exact "feel."

This research aims to bridge the gap between structural generation and experience-driven design. The authors propose a system that creates levels that are structurally distinct from the original but "mechanically analogous." By treating gameplay actions as the primary building blocks, the generator ensures that the content is not just a random assortment of tiles, but a curated sequence of challenges that forces a specific playstyle.

Methodology

Level Stitching and the Scene Library

The core of the approach is level stitching, which moves away from tile-by-tile generation. Instead, the system assembles larger, pre-authored "scenes." The researchers utilized a corpus of 1,691 mini-levels (scenes) evolved in previous work. Each scene is labeled with the mechanics it contains and was designed with a "minimalist" aesthetic to reduce structural noise and focus on specific gameplay interactions.

FI-2Pop Genetic Algorithm

To assemble these scenes into a coherent level, the authors employed the Feasible-Infeasible 2-Population (FI-2Pop) genetic algorithm. This approach maintains two distinct populations:

  1. Infeasible Population: Optimized to satisfy hard constraints, primarily ensuring that an A* agent can successfully navigate from the start to the end of the level.
  2. Feasible Population: Optimized for fitness, measuring how closely the level's mechanic sequence matches the target playtrace.

The system uses variable-length crossover and five types of mutation (Delete, Add, Split, Merge, and Change) to evolve the sequence of scenes over time.

Fitness Evaluation

Fitness is calculated by running an A* agent through the generated level. The resulting playtrace is compared to the target sequence extracted from original Nintendo levels. The fitness function penalizes both missed mechanics and "extra" emergent mechanics that were not part of the original specification, ensuring the rhythm of the generated level remains faithful to the source.

Experimental Setup

The system was tested against target playtraces extracted from Super Mario Bros. Levels 1-1, 4-2, and 6-1. These sequences served as the ground truth for the generator. The performance of the FI-2Pop system was compared against both a Greedy Baseline and a Random Baseline.

Results and Analysis

Playability and Accuracy

The evolved levels achieved near-perfect playability, ranging from 87% to 100%. This significantly outperformed the Greedy Baseline (~25-28%) and the Random Baseline (~10%). Furthermore, the FI-2Pop system was far superior at matching the target mechanical sequence. While the greedy approach often "clumped" mechanics together, the evolutionary approach successfully spaced them out to match the original rhythm of the game.

Emergent Design Strategies

One of the most notable behaviors of the evolutionary agent was the creation of "hard gates." To ensure a specific mechanic (like a high jump) occurred, the generator would evolve tall walls that forced the agent to perform that jump to progress, rather than simply placing a platform where a jump might happen. This demonstrates the system's ability to enforce gameplay requirements through structural constraints.

Structural Diversity

Using Tile Pattern KL-Divergence (TPKLDiv), the authors found that while the generated levels were mechanically accurate, they possessed lower structural diversity than the original Nintendo levels. This is a direct consequence of the minimalist scene library used as the source material, which prioritized functional clarity over visual flair.

Discussion and Limitations

While successful in replicating mechanical sequences, the system has limitations. The levels can appear visually repetitive or "flat" due to the low-entropy nature of the underlying scene library. Additionally, the system is currently optimized for an A* agent. Human players are less predictable and might bypass "forced" mechanics or trigger unintended actions that the AI does not account for.

Conclusion

This research demonstrates that mechanics can serve as an effective specification for level generation. By focusing on the player's actions rather than tile placement, the scene stitching method creates levels that preserve the "feel" of classic gameplay. Future work will explore re-generating the scene corpus with higher visual variety and testing the system with human playtraces to generate personalized training levels for players looking to master specific move sequences.

Summary updated

BibTeX
@inproceedings{green2020mario,
  author = {Michael Cerny Green and Luvneesh Mugrai and Ahmed Khalifa and Julian Togelius},
  title = {{Mario Level Generation From Mechanics Using Scene Stitching}},
  booktitle = {CoG},
  year = {2020},
  doi = {10.1109/cog47356.2020.9231692},
}
Figure