Introduction
Procedural Content Generation (PCG) has become a fundamental tool in modern game development, yet the creation of level generators remains largely an ad-hoc process. Developers often build bespoke systems for specific games, making it difficult to reuse algorithms or compare different generation strategies. In "Marahel: A Language for Constructive Level Generation," Ahmed Khalifa and Julian Togelius introduce a domain-specific language (DSL) designed to formalize and modularize the creation of 2D tile-based game levels. By representing generators as machine-readable scripts, Marahel enables both human designers to iterate quickly and AI researchers to explore the space of possible generators through evolutionary search.
The Marahel Framework
Marahel is an imperative language that structures level generation into five distinct, modular components. This separation of concerns allows developers to mix and match different algorithmic approaches within a single script.
- Metadata: Establishes the global constraints of the generation process, such as the minimum and maximum dimensions of the map.
- Entities: Defines the game's ontology, specifying the types of tiles available (e.g., walls, floors, hazards, or treasures).
- Neighborhoods: Formalizes spatial relationships, allowing rules to be defined based on specific patterns like the 3x3 Moore neighborhood or a cross-shaped von Neumann neighborhood.
- Regions: Dictates how the map is partitioned. Marahel supports various partitioning algorithms, such as Binary Space Partitioning (BSP), to create structured layouts like rooms.
- Explorers: These are the active "workers" that modify the map. Explorers can be Random (placing tiles stochastically), Sequential (visiting tiles in a fixed order), Agents (moving through the map like a player to "dig" tunnels), or Connectors (using pathfinding algorithms like A* to ensure traversability between isolated regions).
Expressive Range Analysis
To evaluate the flexibility and expressive power of the language, the authors implemented five distinct generator styles inspired by classic procedural games like Rogue and Spelunky: Uniform, Nonuniform, Digger, Cave, and Mine. For each generator, 1,000 maps were produced and analyzed using "Expressive Range" plots. These plots visualize the "personality" of a generator by mapping two metrics: the percentage of white space (empty floor tiles) and the number of isolated objects (unreachable sections).
As shown in the analysis, different Marahel scripts occupy distinct areas of the expressive range. For instance, the Cave generator typically produces maps with a consistent 50/50 split between walls and floors, while the Digger generator exhibits higher stochasticity, resulting in a wider variety of layouts but a higher frequency of isolated, unreachable areas.
Key Results and Insights
The study successfully demonstrated that Marahel can recreate a wide variety of popular generation styles with minimal code. A key highlight is the Mine generator, which serves as a hybrid model. It utilizes structured BSP regions for layout but fills them using organic, cellular-automata-style rules, occupying a unique middle ground in the expressive range analysis.
Furthermore, the inclusion of the "Connector" explorer addresses a common headache in constructive PCG: broken maps. By automatically drawing paths between isolated sections, Marahel ensures that generated levels are functional and traversable without requiring manual post-processing by the developer.
Conclusion and Future Work
Marahel represents a significant step toward "Meta-PCG," where the generator itself becomes an evolvable object. By representing an algorithm as a string of code, researchers can use genetic algorithms to discover new types of level generators optimized for specific game mechanics or AI agents.
While currently limited to 2D tile-based environments, future iterations of Marahel aim to expand its scope. Planned improvements include the development of a Graphical User Interface (GUI) to allow designers to "paint" generators visually and integration with analysis tools like Danesh for real-time visualization of a generator's expressive range. Ultimately, Marahel provides a foundation for a more systematic and automated approach to game content creation.
Summary updated