Procedural Content in Video Games

Image for post
Image for post
Rogue (1980) — the original procedural generation

Content. The vague term for how a player spends his or her time in a game world before they get bored. It is burnt like fuel, and what a precious resource it is. Precious because it is the lifeblood of video games, and because it is oh so very difficult to create.

Despite what some fans may think, the developers of video games want their game to be fun. The publisher and owning studio may want to fill out their bottom line and just make money, but the people with hands on keyboards playing street lamps in a virtual environment for 8 hours a day — they want the game to be fun. The developers want to create content that can be enjoyed, and would create a bottomless well of this resource if only they could.

What is procedurally generated content?

Though it’s a vague term, content is simply the things you have to do in a game. In a sports game it’s the list of championships you can take part in. In a shooter it’s the number of campaign missions to complete. If you go online then content aligns closely with the many progression systems; level to gain, money to earn, reputation to defend. If a number is good and it can go up, the means of playing the game to do so would be content.

Content can be created either by hand, or by an algorithm. The former is like a painting by an artisan with a steady hand. It is meticulous and very time consuming. The latter is done more easily but has its own host of disadvantages. An algorithm is designed such that it can create the numerical contents that are examples above. Pseudo-randomness is added to make what is created seem hand-made and fresh.

There are clever techniques for disguising this shallowness of content. With a sufficiently sophisticated algorithm the pattern detailed in that computational blueprint may be hard to make out. Finding the same-ness may require seeing something on a larger scale, and if that’s not possible it may seem like truly infinite custom content. One peek under the hood, one glance at finding the same thing in a slightly different place will click in your mind. That idea bulb will turn on and you’ll see behind the mask procedural generation offers. Procedurally generated pieces of content are all different shades of the same color.

What content can be generated?

As mentioned before anything defined by numbers can be generated procedurally. Fortunately for video games everything is a number. Almost everything could theoretically be generated, whole games even. Reality hasn’t quite caught up to that, as some content is easier to generate than others.

Image for post
Image for post
Minecraft’s ‘Far Lands’ — a terrain generation bug.

Terrain

The first example that comes to most people’s minds is terrain. Roads, landscapes, rivers, and mountains in video games are made of polygons, and polygons are sets of numbers. If you can randomize the peaks and troughs of a valley or the widths of rivers you can come up with random terrain. The challenge is making that terrain believable. Rivers that flow uphill are easy to create but unless you’re going for an alice-in-wonderland look this will not do.

The landscape of our real world was created by countless ages of the force of nature playing through its algorithm. Water flowing through stone, sediment gathering and distributing, storms and fires shaping the lands. Some deserts exist as a direct result of rain not being able to get over mountains. Some vegetation exists because of winds blowing minerals across vast distances to other continents. We can’t hope of creating such a detailed model for our own forecasting purposes, let along for entertaining video games.

No Man’s Sky and Minecraft both use procedural terrain generation. For the first example you’re on foreign planets. There are no rivers, and vegetation generation can be glitchy even in the most polished versions of the game. For the second example Minecraft plays fast and loose with physics, allowing some inconsistencies to be hand waved away as being just another part of the fantasy. Minecraft has also had many many iterations of its terrain generation algorithm for it to arrive at what it is today.

NPCs

The human element in many games are interactions with fake people or creatures. Where there appears to be sentient life, there will be some imitation of personality and mannerisms. Behavior, looks, clothing, and scripts can be loaded into an algorithm and spat out at random.

Looks are a double-edged sword, and a line that must be walked very carefully. If you put too few limits to the shape of faces and bodies you’ll have alien-looking people with impossible dimensions. Fine, perhaps, if you’re going for a science fiction classic, but devastatingly jarring if you’re going for an earth-like medieval setting. Conversely, put too many limits on it and all the results will look the same. Every person will be just a hair away from being every other person and you’ll feel like you’re playing in a world of clones.

Clothing is probably the easiest, create a large set of outfits and apply them to characters at random. The challenge here is making sure the bard isn’t in a full set of knight’s armor, and the knight isn’t wearing a bunch of monk’s robes. This ties into behavior in that if a character’s face is obscured they shouldn’t tell you to “look [them] in the eyes.” NPCs need to be aware of what they are wearing and their behavior needs to reflect that.

Image for post
Image for post
Skyrim NPCs from a mod that tries to improve them.

Behavior is the most difficult thing to create procedurally. I went into more detail in this in my blog post NPC Immersion in Video Games, but the gist of it is that NPC interactions are meant to be human (most of the time.) Players (humans) are very good at picking up even the slightest fault in what a normal human’s behavior. Countless generations of evolution and interacting with other people has finely tuned the parts of our brains that deal with human-to-human interaction. Trying to subvert that is going to be a monumental challenge.

The Elder Scrolls and Fallout series by Bethesda try very hard to do procedural creation of NPCs, but unless their next game has a huge boost to the quantity of voice actors it’s going to be same feeling of 5 people in 100 people’s skins as the last few open world RPGs. If you look for Skyrim mods related to NPCs you’ll find a load dedicated to trying to fix exactly this.

Architecture

The land that cities sit on needs to be there first, but once it is deciding where the cities go can be just as challenging. Buildings, walls, landmarks, banners, poles, streets, so on and so forth. These are almost always placed by hand, and it consumes an incredible amount of time.

An example I once heard of the difference between contributing as a video game developer to an indie studio and a huge AAA-title behemoth studio is that with the former you make a very real and very noticeable contribution. In the latter, with the AAA title, there is so much content that you as an individual are going to make a tiny tiny contribution to the whole — and that feels less rewarding. Telling someone that you put that light pole there on that street is not nearly as impressive as saying you build the town from the ground up.

Image for post
Image for post
A poorly generated Minecraft village.

Minecraft has had some trouble with this ever since it added procedurally created towns. You can stumble upon them at random, and upon their initial release it was rare to find a town that didn’t look horribly designed somehow. Buildings half-buried in sand, some with whole walls missing or no entrances. Blacksmith shops that you had to swim to because they were flooded. Towns where some buildings were fine, but half of one building was inexplicably at the bottom of a mile-deep trench. Since those days the algorithm has improved thanks to the great minds at Mojang. However, if you try hard enough and find enough towns in even today’s version you’ll be sure to stumble upon one, where if it were designed by a real architect it would convince you they must have been drunk when the plans were drawn up.

Custom Content

Content created for a video game by hand has been the leading method of creation for a long time. Putting every piece in just the right place, to tell the story exactly as you see it being told, to guide the player at the pace you see fit. It’s about controlling the experience. A lot of games, because they take so long to make, can be expensive. If I were a game developer and I wanted to spend my time making something you can enjoy, I want to make sure you will enjoy it, not let your enjoyment be determined randomly by what may be a faulty piece of software. With control over the experience I can more closely shape the enjoyment into something beautiful.

Historically the only deviations from this were called roguelikes. Games where a group of rooms are generated with random shapes, and random entrances connecting all the rooms. Your goal in roguelikes could vary wildly, but the stage on which it is carried out had its own variation. The first notable example of this was called ‘rogue’, thus the name roguelikes. At the time graphics were limited, and one’s imagination had to take the place of what would be procedurally generated these days. Regardless, it shows that the advantage of quick-development by procedural generation didn’t take developers long.

Image for post
Image for post

Procedural Content

The picture I have painted of procedural generation up to this point may seem to cast a pretty dim light on the entire idea. Like so many other things procedurally generated content has its pros and cons. There are times when it is the best choice, even over custom-crafted content. The most significant of these is time.

As mentioned before, video games take a huge sum of hours to engineer. Each piece of content has to justify its existence in order to make it into the game. The time of a developer is like gold, it cannot be wasted. For every hour spent by the developer how do you ensure you get as much content out of it as possible? How do you balance quantity and quality of content? These are not the questions I have answers for, and the fact that the industry still struggles with this makes me feel justified in this ignorance. We can inform our decision by asking us how much time we have to spend at all.

Imagine we have two roads ahead of us. We spend 50 hours writing an algorithm for procedurally generated content of some kind. It entertains the players for some amount of time n. Alternatively, we can spend 100 hours hand-crafting content for the player. How much above n do we need to reach in order for the extra 50 hours to be worth it? A 50% increase? Do we need to double it? Triple it? What if we only have 60 hours available to us? Ah, you might see my point now. With only 60 hours to spare we’ll never get the custom content done in time. It’s better to generate it procedurally to get something rather than nothing into the game. Where time is limited, procedural generation can be the gateway to a feature’s completion.

There is a business aspect here, too. Time is money, and developer time at a big name studio can be worth a fortune. More content may mean a longer subscription time if the model is organized that way. Suddenly this turns into an Return On Investment(ROI) calculation. How much money (developer time) can I spend per money (subscriptions paid) I can get back?

Software developer by day, gamer by night. I use medium to write about video games and some of their many aspects.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store