Making the Most out of Procedural Generation

Procedural generation gives developers the ability to use random number generation to automatically create content on the fly during gameplay. How do we make sure that we use this tool to its full potential?

First, procedural generation is not a replacement for game design. At launch, No Man’s Sky was able to randomly generate an expansive universe with millions of planets for players to explore. However, the gameplay at the time was not well fleshed out and the game was panned by critics. As a result, the initial reception was very negative. Even if a game utilizes advanced procedural generation, it is not guaranteed that the game is enjoyable. We need to utilize game design principles to create good procedural generation. For example, consider creating platformer levels. We could choose to create every single level by randomly arranging tiles and putting a start and end on a random tile. Surely, some of the levels we generate are going to be interesting and will lead to an engaging experience. However, if we consider the possibility space of all levels we could generate, we’ll find that the percent of well designed levels is close to 0. It’s hard enough to create an engaging level by hand! Now, one could argue that we could fine-tune our procedural generation algorithm so that it always creates well designed levels. However, now we rely on level and game design principles to create the algorithm, so we are back where we started!  

Designers of successful games with procedural generation put in a lot of effort to make sure that their games can be engaging even if procedural generation is removed. The designers of Spelunky, a 2D platformer featuring randomly generated levels, realized that simply randomly generating levels won’t make an engaging experience. Levels in Spelunky are created by arranging pre-designed segments to create a level that the player can always get through. These segments are designed so that each one presents a player with interesting choices and challenges. As a result, the randomly generated level is always guaranteed to challenge the player while having reasonable difficulty.

Spelunky generates maps out of preset pieces in such a way that there is always an unobstructed path from the entrance to the exit.

Spelunky generates maps out of preset pieces in such a way that there is always an unobstructed path from the entrance to the exit.

This raises a question: If we have to put in a lot of design effort anyways, why bother with procedural generation? Why not make everything by hand? I think there are two reasons procedural generation is used:

  1. Procedural Generation reduces the feeling of repetition for repeating game elements. When a player notices that a game element (map, encounter, enemy etc.) repeats, the game can lose much of its charm. Imagine doing the same level twice. The second time will be much less enjoyable because there is nothing new to encounter. Procedural generation lets us change up a given game element so that it doesn’t seem to repeat. The player will notice the pattern after a while, but the time until they notice the pattern is much longer than the time to notice a repeating element. This is one of the reasons that roguelike games rely on procedural generation so much. You have to go through the same levels every time you die in a roguelike. If the levels weren’t procedurally generated, this would get old very fast.

  2. Procedural Generation counters dominant strategies and encourages adapting to random circumstances. Players are forced to adapt their strategy on the fly if they do not know what exact challenges await them in the future, or are given different resources each time they play. As a result, players feel less confident with sticking to a dominant strategy, since there is always a chance their plans may be foiled. Consider Rimworld, a management game about running a colony on an alien planet. Each time the player starts a new colony, they are given a randomly generated piece of land to settle. Due to the procedural generation, the area poses new challenges to the player each time. For example, if a player ran their last colony by growing a lot of plants, they may think growing plants is the best way to play. If the next time they play they need to settle an area with very little arable land, they will need to reassess their strategy. Similarly in Slay the Spire, a roguelike deck-building game, the map and cards the player encounters are generated in a different order each time. This means the player cannot always rely on the same deck of cards to traverse the map in the same way.

Now that we established when to use procedural generation, let’s look into how to make the most of it. Stellaris is a 4X simulation game about running a space empire that is an example of a game with lackluster procedural generation. In the game, the appearance of each AI empire is randomly generated by selecting a set of colors, flags, species and backgrounds. On my first playthrough, the universe seemed to be teeming with life. Each empire had its own combination of visual elements that made it feel unique. However, with each consecutive playthrough, the empires started to visually blend in more and more. Soon enough, encountering a new civilization stopped being exciting. All of the empires felt bland and uninspired. Because of how the random generation was set up, you would see each element in every possible combination. As a result, there were no surprises anymore! So, how do we make sure procedural generation does not become stale fast?

1) Make sure that more interesting and intense events occur less often than common events.  Consider the two following maps. Which one looks like it would lead to more interesting gameplay?

Everything equally randomly distributed.

Everything equally randomly distributed.

Bigger structures have a lower chance of showing up.

Bigger structures have a lower chance of showing up.

I would argue that the image on the bottom looks like a much more interesting space to explore. The common elements help act as a background to the rarer and more surprising elements. You can see this idea in a lot of successful procedurally generated games. For example, Nuclear Throne is a roguelike top-down shooter that generates maps with ammo chests and weapon chests. However, very rarely one of the chests can be a mimic that attacks the player. The designers found that the mimic was the most exciting and surprising when it was very rare. The mimic was so rare that players forgot it existed most of the time. Rarity is what makes the crazy moments special. If crazy/special events occurred all the time, they would lose their charm quickly. That said, we can improve the map on the right even more.

2) Make the probability of events dependent on other events to create a sense of theming.

Below is another set of maps. Again, which one do you think seems more interesting?

Everything is independently generated.

Everything is independently generated.

Structures are generated dependent on what is nearby.

Structures are generated dependent on what is nearby.

I would say that the one on the bottom is more interesting. Each area feels like it has a set theme and feels consistent and unique. You can see this kind of idea in a lot of procedurally generated games. Minecraft and Terraria both utilize the idea of “biomes” to group together randomly generated elements into a cohesive set. This approach to procedural generation also helps support design, where designers can design themes with specific goals in mind (e.g. making sure different areas have different difficulty).

Minecraft map where four different biomes meet.

Minecraft map where four different biomes meet.

There is a place for procedural generation. It is a really powerful tool for countering dominant strategies and introducing variation into what would be a repetitive game. We can make procedural generation interesting by using unequal probabilities for different events and using dependent probabilities to introduce themes into our generated content. Just remember procedural generation is not a replacement for good game design!