The first video games were defined by repetition. Each wave of Space Invaders adopts a set formation. Every Pac-Man level is the same grid. And, well, just about everyone born after 1980 can tell you exactly what Super Mario Bros’ 1-1 looks like.
As times have changed, so has technology. There are (probably) more pixels in Nathan Drake’s sweat patches than the sprawling fields of Hyrule in Ocarina of Time. It’s not all surface, either: behind the scenes, the ability to procedurally create in-game content has led to an explosion in wholly unique playing experiences.
“Games have been gradually swinging away from concrete, scripted content towards player-orchestrated content,” observes Garth DeAngelis, senior producer for XCOM 2 at Firaxis. “It doesn’t mean there isn’t a place for compelling linear content, but game designers are thinking more systemically overall than the prior few decades.”
Dan Marshall initially designed all of The Swindle’s environments by hand – a method he says made the indie stealth title feel “flat” and “repetitive”.
After randomising the creation of the game’s buildings, “the scope of gameplay that was coughed up was immediately more exciting, both as a designer and for the gamer”.
“Random generation is one of those things that can really set games aside from movies and books in terms of the content they provide,” Marshall enthuses. “They all tell stories in their own way, but procedural generation allows us to do something more unique, more interesting.
“As the tech progresses we’re going to see more and more games going down this route – imagine an Uncharted-alike where the locations aren’t exactly the same every time, or a Skyrim with randomly-generated quests and stories. We’re scratching the surface right now, but there’s exciting stuff to be done.”
Dave Crooks, co-founder and lead designer at Enter the Gungeon creator Dodge Roll, highlights the benefits of using randomised elements in attracting a new audience to your game, too.
"Seeds have become very important in procedurally generated games as a way for players to share experiences, offer tips, or compete with one another," he observes.
"The rise of streamers and Youtube content creators has also been an influence, and helps further popularise procedurally-generated games. People who make their living creating content are likely to seek out games that give them huge replayability, provided that their audience digs the game."
"The point of being random is to design a game that can be replayed infinitely without growing stale."
Procedural generation in games isn’t a new invention. As far back as the late 1970s, primitive random mechanics were being employed to generate ASCII or tile-based environments (often dungeons). In fact, the strong influence of one of these games – Rogue – lives on in the recent revival of the ‘roguelike’ genre, led by modern touchstones such as Edmund McMillen’s seminal 2011 top-down shooter The Binding of Isaac.
“Everything in The Binding of Isaac is generally randomised, aside from specific room layouts that were designed for more precise structure, but even those elements have tons of random variables within them,” McMillen explains.
“During development we created a suite of tools specific to the game to facilitate the different tasks including a pool editor, animation editor, room editor and configs editor,” expands producer Tyrone Rodriguez. “The latter was unused because we found it quicker to edit XML files with simple text editors, adding new attributes on the fly.
“The pool editor allows anyone on the team to pick a set of items with the chances of being encountered – weights – the rate at which weight is getting decreases, when player sees it and at what weight the item is considered removed.
“Our room editor allows for placement of the entities and to visually set the room parameters. Each room is part of a configuration group – per level, special room and so on. There are different parameters that a room can have including shape, difficulty and weight. Originally, the room editor was made based on the Flash config layout; it uses one layer of entities for all grid, enemy, effects and pickups.”
Enter the Gungeon was heavily inspired by Isaac’s innovative use of random generation, but Crooks and Dodge Roll combined many of McMillen’s methods with their own unique applications.
"There are two major elements in Gungeon that rely on randomisation: floor layout and loot drops," he details. "Each room in Gungeon is hand-designed, with some randomisation baked into the room. Hundreds of rooms were created, given a room type – combat, trap, secret, boss – and assigned to a floor. At runtime the rooms are then randomly joined together following a set of rules, specific to the floor of the dungeon being generated, that we believe describe good dungeon design.
"Loot drops are similar in concept, in that each weapon and item is hand-designed and added to a pool based on quality. When a chest is opened or a player walks into a shop, an item or gun is chosen based on a complex set of rules. This set of rules takes into account where the player is, what they have unlocked, what they’ve picked up recently, have they fought the boss yet and so on.
"We chose these elements of the game for randomisation because they have the biggest impact on making each run feel different. Going into a different dungeon each time you play has a massive impact on replayability, and when you add to that the possibility of fighting a different boss at the end of the level with a totally different set of weapons, there are hopefully enough combinations to make the game continue to feel fresh despite the game being designed to be played over and over again."
While not all games opt to implement procedural generation to such an extreme, the concept can be employed to varying levels to inject a level of surprise into a player’s experience – or even to help smaller devs with the burden of asset creation.
“The Swindle’s player characters are basically like a Mr. Potato Head – we randomly assign a race and gender, and pull out an appropriate head, and set about slapping hair or glasses, moustaches, whatever onto it,” Marshall details. “They’re all animated using Spine, and share animations, but I can flip graphics in code really easily, making a near-infinite supply of characters.
“You’ll notice all the characters wear gloves. This is because they’re thieves but, more importantly, it was so they can all share ‘hand’ graphics, and there was no need to draw loads of extra hand assets.”
XCOM 2 similarly utilises random elements to create its humans-versus-aliens battlefields on-the-fly.
“We have the procedural map system, which ensures you will not see the same exact layout twice,” DeAngleis reveals. “This system blends the handcrafted artistry of XCOM: Enemy Unknown’s maps with what we call a ‘Plot and Parcel’ system. The plot is the quilt and the parcels are the patches that get sewn in.
“Both components have procedural cover elements that get loaded in at map initialisation. The streets, corners and time of day are all mix-and-match. On top of that, enemy spawn and behaviour is shuffled. The sub-objectives are also procedural, and can show up in dozens of locations. When you stir all of this together, you have a pretty replayable system.”
Whether procedural generation is the foundation of a game, or used sparingly to spice up specific elements, basing even a minor factor on virtual dice rolls can significantly extend the time a player spends with a title.
“It’s a great way to increase gameplay and value to the player without excessively increasing budget or development time,” Rodriguez urges. “There is a certain amount of research and discovery that must be done ahead of time and it all needs to be planned, but the benefits outweigh the negatives, such as having to make more custom tools, algorithms or other development requirements.”
McMillen summarises: “The point of the experience being random is to design a game that can be replayed infinitely without growing stale and move away from linear designs which are the more common and familiar route for developers.”
By its very nature, basing game design elements on chance can lead to unpredictable results.
“No paper design ever accounts for sure-to-come changes through playtesting, and those increase tenfold in a procedural game,” DeAngelis warns.
“Isaac can have a non-deterministic number of items per floor so they can’t be pre-generated,” Rodriguez offers as a specific example. “The undefined behaviour of the player and the sequenced events versus parallel ones made it really difficult to keep the outcome stable.
“One bigger problem was the item pool system, because the player can walk in any direction and visit a different sequence of rooms each time – thus, picking items that makes others less common or inverse. We tried our best to keep it stable for the rest of the run, but it’s still not perfect.”
Marshall agrees that accounting for every outcome is a near impossibility.
“The main problem is never really being able to see everything the game’s capable of doing, and the can of worms it opens up,” he says. “With proc gen, everything’s held together by random numbers – which means things can go really wrong very easily.”
Despite this monumental task, there are steps that devs using random mechanics can take to better their odds.
“We overcame the change requests by rolling up our sleeves, playing the heck out of the build, and sharing experiences,” DeAngleis explains. “Then, design would return to the code and execute changes based on feedback.”
Marshall echoes DeAngleis’ advice that putting the game and its components to the test is vital.
“Balance is all about playing the thing a billion times, day-in day-out,” he insists. “It’s testing and re-testing, seeing if something’s not quite working and tweaking the algorithms accordingly.
“The key to making sure stuff doesn’t crop up too much is to just have a massive pool to draw on. The list of potential names in The Swindle’s name generator is colossal; it’s possible you’ll get the same character twice, but it’s massively unlikely.”
McMillen faced a similar issue of proportion when developing The Binding of Isaac, due to the title’s “literally thousands of possible hand-made rooms, each with an amazing amount of changing elements”.
“Random elements were balanced by structuring the enemies and room layouts by difficulty, as well as scaling the game up as the player progresses,” he reveals of his solution. “Basically, structured chaos.
“The chances of running into the same map layout are near impossible. If you factor in the 13 playable characters with different stats, the near 500 items and their combinations, then no playthrough will ever be the same.”
Crooks reveals his own approach to overcoming the difficulty of recreating random scenarios when testing.
"Randomly-generated elements in games produce a number of headaches that you might not even consider at the outset of development," he warns. "For instance, if your levels are procedurally generated, you can’t actually look at them in the editor when the game isn’t running. It can make troubleshooting an issue pretty frustrating.
"Even with something as simple as random drops, you have to take the extra time to validate that your math is working out, and that they are dropping at your intended cadence. It leads to strange and unsure exchanges like: ‘I feel like I’m seeing _____ all the time’, ‘Really? I feel like I never see it!’ or ‘Is merchant X even showing up in the game?’ ‘…should be.’ We ended up creating a number of tools to validate drop numbers, or automate rapidly generating dungeon floors to look for errors – a tool we would run overnight. That and lots of testing."
"The best proc gen games fully embrace the experience and don’t tack on elements that don’t work."
The rise of procedural generation has allowed players to tell their own tales. Every experience is unique – a far cry from the cookie-cutter narratives of old. Despite this, scripted elements can still hold value for devs.
“All gameplay mechanics are suitable for randomisation,” begins McMillen. “The only ones that really don’t benefit from it are linear story-driven ones. Scripted or traditional narratives aren’t that interesting when it comes to game design. There is a story to Isaac, but the actual experience tells of a much deeper and more thought-provoking theme.”
The Swindle originally involved a plot, which didn’t make it into the final game. Marshall agrees that random mechanics are not a ‘one size fits all’ replacement for carefully crafted narrative.
“Devs need to learn what works and what doesn’t with this kind of game,” he advises. “In the same way the best iPhone games are the ones designed around the touchscreen input, the best proc gen games are going to be the ones that fully embrace the experience and don’t try to tack on elements that just don’t work.”
DeAngelis highlights the increasing marriage of scripted narrative beats with the freedom of random elements as a potential route forward.
“Hard-scripted content can seem more memorable and wow-inducing but its value is mostly consumed after one viewing,” he says. “But if there are designs and systems that empower the player to create their own wow moments through mechanics, then the game’s value skyrockets, and the player develops a more powerful attachment.
“Then, what if you can blend procedural or open-ended system with spectacle through cutscenes? That’s most exciting to me: to see procedural designs fuel high-production value moments. Grand Theft Auto has shown masterful examples of this, when you find yourself wandering the city streets doing whatever is in your head at that moment, and then suddenly, you have a well-designed, scripted mission like a bank heist to opt into when you so choose.”
Crooks agrees that the best procedural element is an invisible one.
"The balance of scripted versus random is the biggest difficulty in using randomisation in game design," he observes. "Players love designed experiences but also crave variety. Some people don’t enjoy procedural games because feel that in the pursuit of making something modular enough to randomise, the game loses detail or uniqueness.
"One way to mitigate this is to choose carefully where you are going to lean into RNG and where you are going to lean design. In our case, ‘flows’ are our answer to creating a structured and designed sense of space, while still having the specifics of which rooms to place and how they are connected remain random. Within the rooms there are small random elements: reinforcement waves may appear behind the player to ambush them, but not always. The structure of the experience is designed but the specifics remain random.
"I have always considered procedural generation to be a designer’s tool and not their replacement, but I also think that the mark of a truly fantastic procedural element in a game would be one that the player does not realise is random."
While procedural generation has been gathering momentum among smaller studios for years, and proven its popularity by fuelling some of the indie sector’s biggest names – from Minecraft to No Man’s Sky – it remains a concept largely disregarded by bigger developers.
“Indie devs have kind of taken procedural generation and gone: ‘Look what we can do with it’,” says Marshall.
“Seeing what triple-A studios do with it, with all their money and power, will be really interesting.”
Crooks reiterates his belief that the social elements of procedural generation will drive the concept forward.
"Streamers and Twitch integration are going play a big part in how random elements are implemented in games in the next few years," he predicts. "You are going to see more games that give the streamer, or their community, ways to interact with the random numer generator (RNG) or benefit from it somehow.
"I also think that the role of randomisation is only going to get more ambitious: levels, enemies, animations, characters, voices, puzzles and so on. If you look at what they guys at Hello Games are doing [with No Man’s Sky] already, it’s pretty awesome.
"The biggest draw for using procedural or random elements in a game’s design is to delay the player feeling that they have seen everything there is to see. Essentially, to add variety and possibility. That said, random elements lend themselves very well to certain types of games and experiences, but not every game needs an infinite mode. It is up to the developer to determine if including procedurally generated content will help deliver on the experience they have designed."
DeAngelis expects the growing presence of unpredictable mechanics to herald a new wave of timeless titles.
“I don’t think this is a fad at all,” he predicts. “It will only get more exciting.
“For sure, there are developers interested in using procedural elements in ways that haven’t been implemented before.
“It’s less about technology and explicit tools, and more about the systems being designed and the engineers that construct them in creative ways to empower the player to have experiences that can go on forever.”