Of all the trends that have swept the gaming space in the last decade or so, few have the staying power of procedural generation, which is writing a system of rules for creating content and letting a program iterate through them starting from a randomized “seed.”
Players expect their games to have lots of content and replayability, but hiring designers and artists to make lots of unique elements can be way out of reach for many studios. Computers can help. Artificial intelligence takes the component elements of a game world and mixes and matches them into thousands, or even millions, of different arrangements. Procedural generation then harnesses that power.
Game designers started experimenting with these methods in the 1970s, but most of the titles that used them were punishing to players. Procedural generation was most commonly found in games like Rogue and Nethack, dungeon crawlers with deep, obtuse mechanics and primitive ASCII graphics. The technique was also used to create solar systems for games like Elite.
Game designer Derek Yu painstakingly hand-crafted the world of 2007’s Aquaria, an underwater Metroidvania that won critical acclaim after it was released. But for his next project, he wanted to create a game with more replayability. On forums like TIGSource, he saw other developers like Minecraft’s Notch experiment with procedural generation, and he decided to try it himself.
Inspired by classic 1983 platform game Spelunker, Yu prototyped a title in which the player descended into subterranean caverns littered with treasure and populated with aggressive fauna and deadly traps.
Although each game followed the same general narrative arc, the experience and challenges were different on every run. That’s where procedural generation came in. Spelunky’s world isn’t entirely random. Instead, the game uses a complex system to build floor plans out of a palette of elements. Each level is broken into a 4-by-4 grid of 16 “rooms,” which are chosen from a number of types. The player always starts in one of the four rooms on the top row, and the exit is always one of the four rooms on the bottom.
The algorithm constructs a path between the entrance and the exit, and then starts adding detail to the individual rooms along the way. Each “type” of room draws from a number of possible templates, and then those templates are populated with blocks that have a probability of being special types. This multi-layered decision making lets the system create terrain that is always navigable but presents a wide variety of challenges.
Finally, Spelunky took lessons from classic games like Doom and created an ecosystem in which inhabitants and objects have interesting interactions with each other. Throw in additional visual and difficulty changes as you proceed and you have a recipe for a game that boasts massive replayability. Yu wrote an entire book in 2016 about the process.
Spelunky was an unexpected hit, first released as freeware and then ported to multiple consoles, including the Xbox 360, PS3, and PS4. There’s even an HTML5 version. Because the source code is open to the community, numerous fan mods also exist. It showed that combining procedural worlds with a more popular game genre—in this case, Mario-like platforming—could capture a new audience of both casual players and hardcore speedrunners.
Procedural generation has since become a vital tool in the modern developer’s arsenal. Many of the highest-profile games of recent years have used it to create content, from Minecraft’s unique worlds to No Man’s Sky’s massive universe. The advantage to this method is that the random seed that is fed into the algorithm can be quite small, letting file sizes shrink while the program does all of the heavy lifting.
Even when these tools aren’t used to create a game’s primary content, they can still show up in the background. Artists use procedural generation to populate forests that look truly wild, or make non-player characters with diverse appearances. Every year, developers are finding new ways to harness this tool to make games that are deeper and richer.
The Crusader Kings games combine algorithmically generated personality traits to determine how its rulers behave. Shadow of Mordor, and its sequel, uses it to generate the different orcs you fight. Microsoft’s new Flight Simulator uses real-world satellite data that is gobbled up by a procedural generation algorithm to build the vast majority of the Earth’s scenery.
It’s taken many years for Yu to prepare the sequel to Spelunky. One of the bigger challenges facing developers of games that lean heavily on procedural generation is making a second game that feels significantly different, and not just like more different assets have been added to the cooking pot. A good deal of the work that he’s been putting in involves the nature of the world itself.
While the first game operated on a pretty strict grid-based system, Spelunky 2 brings with it a suite of liquid and particle effects. Lava and water can now ooze and flow through the world in physically realistic ways, creating a new dimension of challenge. Each level also has an additional “layer” that is reachable through a door. Find that door and explore the world on the other side, doubling the size of explorable space.
With the success of the first game, Yu began teaming with BlitWorks—the company that ported Spelunky to Sony consoles—to code the sequel. Its input allowed the game to be much more vigorously tested before release, which makes sense. For all of the time that random seeding can save on one end, it needs to be balanced out by extensive experimentation from the player’s end. For a game that prides itself on fairness (even at the highest difficulty), having a player get screwed out of a victory because of the algorithm is unacceptable.
Procedural generation isn’t the end-all and be-all of game design, and some stories—like the rich and complex narrative of The Last Of Us, for example—will probably never be written by a computer. But it’s instructive to see the ways it helps designers and developers fill in the gaps in their games and give us an incentive to play over and over again, always feeling like we could see something new.
Spelunky 2 is out Sept. 15 for PS4 and Sept. 29 for Windows.