Game Reviews

Procedural Vs. Random Generation: Is There a Difference?

The term ‘procedural generation’ has been thrown around the game industry a lot lately. With the release of No Man’s Sky, the phrase has become more popularized than ever before. Hello Game’s space-faring adventure isn’t the only recent game to feature procedural generation; games like Minecraft, Cube World, and Terraria also utilize it. But whatever happened to ‘random’ generation? Is it dead? Do developers still use it? Or are these two terms simply synonyms? You may be interested to find out that there is, in fact, a difference between procedural and random generation.

Take note of the games that I mentioned above. What do they all have in common? Yes, I know they all have crafting and near infinite sized worlds, but I’m referring more to the way that they generate their landscapes. Take Minecraft, for example. If the game just randomly placed different blocks all over the place, the land would look ridiculous; there would be single blocks of water dotting the ground, snow would be found in the middle of deserts, and trees would not match any specific biome. What I’m getting at is this: there’s a method to the madness. When it comes to procedural generation (which will further be referred to as progen), worlds are weaved based specific patterns and rules. When a snow tile is placed, there is a very high probability that another snow tile will be placed beside it in an attempt to create a biome. Ground gradually increases and decreases to prevent sporadic spikes of land or holes in the earth. More specific conditions are set for trees and plants, which are only spawned in the correct environments. If the game wants to place a tree in a grassy area, it makes sure that the tree isn’t a pine, since those only grow in winter biomes. Terraria, Cube World, and No Man’s Sky work the same way; their algorithms create land based on rules that the developers set.

If you haven’t played Cube World, what are you doing still reading this???

Now I know what you’re thinking: don’t ALL games with some sort of randomized generation have rules set in place to control said generation? Yes, that’s true, but random generation is a bit more…well…you guessed it: random. The rules of randomly generated lands aren’t as strict as those of progen environments. Take Phantasy Star Online: Episodes 1 and 2 for example. Every time you enter one of the dungeons, the rooms have been swapped around. Pretty much any two rooms can potentially lead to each other, with the exception of some places like the second forest area, which is always the same. So in this instance, there aren’t really any conditions set on which room you’ll run into next. I’m not saying this is a bad thing; in fact, in this case, it works quite well. The dungeons each have a personality and feel to them without being completely predictable every time you enter. But in terms of complexity, there isn’t much going on. The rooms themselves aren’t procedurally generated; even the boxes are in the same places every time. That leads me to my second condition for identifying progen: the use of seeds.

In Phantasy Star Online, the dungeon areas are randomly generated using pre-designed rooms.

Most progen titles, such as Cube World, Minecraft and Terraria, let the player input a number of their choice called a seed when they start a new game. The seed is like the variable for the progen algorithm. To make things easier to understand, picture this algorithm as a simple math equation:

2 + X = Y

I know, I know, we’re all scared of algebra, but stay with me for a minute. Let’s say that X is the seed, and Y is the output. If you were to put in 3 for X, you would always get the answer 5. That’s because the variable, or seed, is the only thing that’s subject to change in the equation. Three plus two is always equal to five. It works the same way in Minecraft: if you choose a seed of 50, start the game, walk around the world a bit, exit, create a new file, and choose 50 for the seed again, you would end up back in the same world. That’s because, if we stick to our mock equation, two plus fifty is always 52. Now obviously the real progen algorithms of games like Minecraft are much more complicated than our example, but the concept is still the same. Random generation, on the other hand, doesn’t tend to use algorithms or even simple equations, it instead relies on generating random numbers to control spawns; such as the contents of boxes, number of enemies, and weather conditions. The choices it’s randomly choosing from are usually set values rather than an entirely creative amount; for example, the weather can either be stormy, sunny, or snowy, but not anything in between. Also, with random generation, there’s no way to get back to a previous result. The creation process is random every time, excluding the use of seeds or algorithms.

Now let’s study one more game; this time, the one I made myself! If you’ve been following my twitter (@Hybrid_Games_), you’ve probably seen my current project, Shooty Space. In case you’ve never heard of it, Shooty Space is a Galaga-style space shooter with a unique twist: you can land your ship inside giant frigates, get out, take control of your bite-sized pilot, and continue to blast away enemies in what I call Pilot Mode. The insides of the frigates are procedurally generated each time, so you never enter the same ship twice. But wait; is it actually procedural, or is it random? I asked myself this question at one point in the development process because I had kept telling my friends that my game had progen in it, and I wanted to make sure I wasn’t accidently lying to them. After analyzing the methods by which the rooms are generated and the contents of said generation; I can confirm that Shooty Space’s frigate sections are indeed procedurally generated.

Pilot-Mode gamplay from the upcoming game Shooty Space.

Allow me to back myself up. For starters, each frigate room is made completely from scratch every time you get to one. Rather than choosing from a selection of pre-designed rooms, a-la Phantasy Star Online, there is literally an infinite number of possible layouts for the inside of a frigate. The algorithm that I’ve crafted for Shooty Space involves using two overlapping data structure grids; one for wall-placing and one for enemy pathfinding.  The algorithm itself is also split up into many sub-sections that control the order of object placement. The walls and floors are placed first, then obstacles such as crates and pillars are added in, and then, lastly, the enemies.  Along with being built from the ground up every time, these areas also have specific spawning rules. The hackable computer, for example, can only spawn against a northwards wall. This decision was made because I wanted the player to always be able to see the hackable computer’s screen.  By setting up the algorithm this way, I have conformed to one of the aspects of progen: method. These rooms have method to them. Walls will never trail off-screen, the enemy amount is always within the same amount, and, as I already stated, some objects can only spawn against certain walls. Now recall that there were two conditions I’ve said that generation had to follow to be considered progen: the use of method and the use of seeds. I’ve already shown how Shooty Space uses method, but what about seeds? Well, there’s no option in the game to load a previously-created frigate interior, so the use of seeds isn’t needed. However, it would be easy to implement it if I had the desire to do so; and that is because of the way I have set up the creation algorithm. I could potentially save the values created within the ds grid to another object so that rooms could be recreated. However, like I’ve already stated, a game like Shooty Space, which is intended to be different every time you play, has no need for a seed feature such as that. What it does feature is simple procedural generation that adds a sense of excitement and discovery to the already solid Galaga-style formula set in place.

Objects and obstacles, such as those pillars and boxes, are procedurally placed in the rooms based on set conditions.

Hopefully, this post has helped to clear up any questions regarding the fine line between procedural and random generation. The topic itself has been popular lately, and I think that a lot of developers want to know more about the progen strategy and the reasons behind its recent success. Like I said previously; there’s absolutely nothing wrong with random generation, but the important thing is to know where to use it. It’s up to you, the developer, to utilize these two main tools of generation to, well, generate the most important thing of all: awesome game-playing experiences.


Join us!

How about writing your own piece for IndieWatch?

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblocker Detected

Please, consider turning off your Adblocker so you can enjoy IndieWatch and contribute to our site's existence. We need to display ads so we can keep our gears smooth and running. Thanks for you cooperation!