Procedural generation is popular amongst independent developers, and for good reason: It allows the almost infinite generation of new content, and, with the help of well established rules, allows a high playtime without boring the player with too much repetition. Procedural generation can be used in many different areas, from game design to 3D, as well as music. The idea is to generate content by using mathematical formulas and randomness. Thus, we’re replacing the act of a person creating content with the machine doing the same thing. Of course all the created content relies on the rules that will create it, the challenge and quality of the labyrinth depends on these rules.
In Subaeria, procedural generation consists of building labyrinths that will connect the important locations within the city. The action/puzzle gameplay, along with part of the game’s story (quests, narration, etc) can be found in the labyrinths. It’s necessary that the rules of the labyrinth take into account gameplay and narration in order to stay coherent as the player progresses through his run.
Establishing the rules of generation
As said in the introduction, we are going to create the labyrinths according to pre-established rules and, of course, parameters allowing to influence these rules, like the size of the labyrinth or its difficulty.
The size of the labyrinth
In Subaeria the progression of the player happens through a security level system. Difficulty increases as the player advances in the labyrinth, which implies that the labyrinth has to adapt itself and change according to the level of difficulty.
The player will become more powerful as he moves forward and will get rid of enemies faster (by having higher level skills and bettering his stats). Making labyrinths longer helps to compensate for this by giving the player an added level of challenge. Though the number of secret rooms (that contain skills and buffs) will remain constant in order to have better control over the player’s progression.
4 directions, 4 paths
The labyrinth has 4 exits: north, south, east and west, because it has to connect to narrative rooms and other labyrinths. The idea is to consider a labyrinth or a narrative location as a “Gate System” that can be connected to 4 other “Gate Systems”.
The strategy to generate the labyrinth from this first rule is to start from these 4 “Gate Rooms” and to go towards the center of the labyrinth. It’s mandatory to connect the exits and entrances together, we can’t leave any unconnected, which would block the progression of the player through the city.
The entrance/exits are in red on this image, the center of the labyrinth is in yellow. A path constructed of rooms will go from each entrance/exit towards the center by using a weight system. Every direction has a different weight attributed to it, the highest weight being given to the path that leads towards the center of the labyrinth. Randomness will then determine, while taking into account the various weights, the direction in which the next room will be created.
Building alternative paths
Once the labyrinth has been created, we’re going to randomly open the doors between the rooms that shouldn’t necessarily be connected. Of course, the main path is open to allow the player to go through the labyrinth, but by opening more doors, we’re adding alternative paths, that don’t necessarily reach the exit or the center of the labyrinth.
We’re also going to create extra branches that will be dead ends, surrounding the main path, in order to add complexity to the navigation. We like when the player feels like he’s in a different labyrinth every time, but we also like the fact that he can understand how the generation works, so he can feel smart within the game (in the same spirit as Binding of Isaac).
A consistent labyrinth
It’s important to control procedural generation, most of the time by using precise rules for generation. But often, finding these formulas requires quite a bit of time as well as a thorough analysis. A technique exists that gives consistent results in 99.9% of the cases and it’s easy to put in place. It’s simply regenerating the labyrinth as long as we don’t get the desired result. Obviously there needs to be a limit to the number of attempts, so that we can avoid infinite generation. We’ve noticed that with a maximum of 10 attempts at generation we avoid ending up with undesirable labyrinths. Over millions of generations, it can happen that a labyrinth won’t be as we’d like, but it’ll remain playable, just less interesting.
To ensure the quality of the labyrinth, we’ll, for example, count the number of rooms created an compare it to the size of the labyrinth to find middle ground. We also determine the ratio of open doors to the number of rooms, in order to avoid having a labyrinth that has all doors opened or on the opposite end, a snake with rooms that only have 2 open doors, which makes for a very linear progression.
Time permitting, we could have developed a neural network based on human validation, in order to distinguish the good and bad results and to simultaneously learn which are the best rules to generate the labyrinth.
Integrating the narrative and special rooms
Subaeria, doesn’t only have roguelike gameplay, it’s also and mainly a narrative game. The problem with narration as we see it in RPGS, is that it’s linear. And this goes against the basis of procedural level generation, which signifies that every playthrough will be different from another. How then can we tell the story of the city to the player, and how can we ensure that he’ll be able to fullfill the different tasks of a quest? Multiple tools are at our disposition that allow us to enrich the Procedural death labyrinth with narrative elements, here are some of the most important:
As indicated by their name, these rooms are obligatory and the labyrinth has to place them somewhere. It’s a list of rooms, that are prepared in beforehand by the game designer, and once that labyrinth is created these rooms will be placed. Placement rules forces these rooms to be at at least x distance from the entrances/exits, in order to incite the player to search for them throughout the labyrinth. These rooms can be narrative (NPCs, quest elements) or they can be resource rooms, or special event rooms (Boss rooms)
These secret rooms are also part of the labyrinth. Contrary to mandatory rooms, these rooms are placed at the exterior of the labyrinth, in order to ensure that they’re only connected to a single other room. If we decide to place it randomly, like the mandatory room, and that we close doors to get the same result (of the room being only accessible by one door), we run the risk of cutting off the main path, and compromising the completion of the labyrinth. Usually these rooms will have more of a gameplay focus, by holding resources for the player, or special challenges. We’ll be able to define priorities on the appearance of these rooms as well as their quantity.
What comes next?
We’ll see in a second post, how to fill “normal” rooms, as up to now, we’ve just looked at the structure of the labyrinth, and not so much its content.
To find out more about Subaeria sign up for our mailing list here