32
\$\begingroup\$

What the advantages/disadvantages of using random/procedural generation vs. pre-made levels?

There seems to be few that I can think of, other than the fact that items may be a problem to distribute in randomly generated terrain, and that the generated terrain may look weird.

The downside to previously made levels is that I would need to make a level editor, though. I cannot decide what is better to use.

Could answers include code/examples of both procedural and premade generation, as well as the pros/cons?

\$\endgroup\$

2 Answers 2

26
\$\begingroup\$

To briefly answer your main question first, the main advantages of a procedurally generated game world are that:

  • The world can be huge, much larger than any manually designed game world could possibly be.

  • The world (or at least parts of it) can be regenerated for each game, potentially increasing replay value, since the player will always have something new to discover.

Conversely, the main disadvantages of procedural generation are that:

  • Depending on the generation methods used, it can be hard to make sure that the world is always playable, i.e. that the player can't get stuck with no way to proceed just because they gut unlucky with the world generation.

  • Even if you can avoid generating completely unplayable worlds, random world generation can lead to a highly variable difficulty level: sometimes, the player might find everything they need just conveniently lined up for the taking, sometimes they might go a long time without finding anything useful.

    Over long periods, such random fluctuations do tend to average out, but if the game difficulty is e.g. heavily front-loaded (typical for survival games), a bad start could ruin a game while a very lucky start could rob it of all challenge.

  • Poorly done procedural generation can make the world feel monotone and boring: after you've seen a dozen randomly generated mazes, they all start to look the same, even if they differ in details.

  • Also, if the game world is completely regenerated for each game, there will be no fixed locations or features that the player could recognize from previous games. Such lack of familiarity could make it harder for the player to engage with the game on an emotional level, or to share experiences with other players.

There's also one thing that you could count in either list: in a game where the world is randomly regenerated for each game, there can be no such thing as a "walkthrough" guide, since every playthrough will be different.

(This unrepeatability could also be a problem for testing and debugging, although it can be at least partially avoided by allowing the RNG seed to be specified, at least in debug mode, and/or by providing "cheat" command that can be used to fast-forward play to different stages.)


However, if you look at the disadvantages list, you'll see that it mostly describes the disadvantages of pure procedural generation; a lot of them can be avoided by mixing manually and procedurally generated content.

For example, the player could always start in fixed, manually designed town, perhaps surrounded by a wider more or less fixed home region, but places further away from town could be randomly generated to always provide unfamiliar regions for the player to explore.

There could also be other manually designed towns or other locations placed (more or less) randomly in the world, such that the player will have to find them, but will know what to expect once they get there. Conversely, prominent features such as mountains could be manually placed (at least in the vicinity of the fixed starting location), but the details of their terrain could be randomized.

As for random placement causing deadlocks and difficulty variation, that can be addressed by implementing various consistency and balance checks on top of your procedural world generation algorithm. For example, if the player needs a particular item to be able to cross water, you could include some code making sure that at least one such item is placed so that the player can reach it without crossing water.

Similarly, you might also want to tweak your item placement rules so that no wands of balance-breaking awesomeness are placed before the player has reached level x, and maybe to ensure that at least one is placed in a fixed location where the player can reach it before getting to the stage where they're going to need it to survive.


By the way, a common way to make procedural and manually generated content mesh more or less seamlessly is to start the manual generation process by using the procedural world generator (maybe suitably tweaked, e.g. to generate a village or a mountain peak where you want it) to initialize the region you're designing, and then manually tweaking it to add and adjust the details you want. (This can also allow very compact level storage, by only saving the manual changes and the generator seed and parameters used.)

Other ways to combine manual and procedural content include leaving blank spots in your manually designed levels, to be filled in by randomized content (e.g. a castle could include a randomly generated maze in the dungeons, with only the outline and the exits fixed), or the manual design could specify only the broad outline of some parts of the level (e.g. the placement of houses in a town) and leave the details (such as the exact appearance of each house) to be picked randomly.

In fact, even many games that have entirely fixed game world use some form of procedural generation as part of their level design process, since there are some aspects of world generation (like producing natural-looking terrain, or placing individual trees in a forest) that are difficult and/or tedious to do by hand, but relatively easy to automate.

Conversely, most procedural world generators will use at least some manually designed objects and elements to build the world out of. One could even easily have multiple levels of nested random / manual generation: for example, a procedurally generated world could include a manually generated town surrounded by procedurally generated woods with a manually drawn outline, with procedurally generated trees bearing manually designed leaves.


Also note that procedural content generation isn't necessarily incompatible with a fixed world: you could just pick a fixed RNG seed and use it to generate your world. This can be useful if you want a huge world for the players to explore, but want to keep it the same for every game and every player.

Note that, if you do this (or possibly even if you don't), you really should design your world generator to work in a hierarchical fashion, using multiple RNG instances, such that e.g. the overall map generator would keep a single RNG instance that it would use to generate subregions, assigning to each subregion a different seed value that the region generator would then use to seed a separate RNG instance that it'd use to generate the region, and so on. This is to avoid the "butterfly effect", where changing even the tiniest detail of the tiniest part of the map could throw the RNG out of sync and cause everything else in the world to be completely different.

Another important way to avoid the butterfly effect, particularly if you're generating the world "on the fly" as the player explores it, is to avoid normal RNGs entirely (except for processes that happen "instantaneously" from the player's viewpoint, like generating a new level when the player enters it) and instead use random number generation methods that don't store any internal state. For example, when choosing the seed for a subregion the player is about to enter, the overall world generator could take the coordinates of the subregion (and its own overall seed) and feed them to a hash function to generate the subregion seed. That way, each region will always look the same, regardless of the order in which the player enters them.


Ps. After all that digression, let me briefly address your final question about the actual code used for procedural generation. Alas, I don't think it's really answerable in any meaningful sense without a lot more detail than you've provided, since there are literally as many different ways to do procedural world generation as there are games using them.

For example, the great grand-daddy of all procedurally generated exploration games is probably Rogue, whose level generation algorithm simply consisted of randomly placing a bunch of rectangular rooms within a larger rectangular level, and connecting those rooms with passages (and placing a staircase to the next level in one of them). Its diverse successors, from Nethack to the Diablo series, have elaborated on this system in many ways, but most have retained the basic idea of distinct levels consisting of rooms, dungeons and mazes more or less randomly placed on a grid map.

Conversely, for games featuring open outdoor settings, you'll probably want to start with some kind of fractal terrain generation algorithm and build other features (rivers, forests, towns, etc.) on top of that. Or you could do something like what Minecraft does, and generate a random 3D procedural texture determining which parts of your landscape are ground and air respectively (scaled and biased so that lower blocks are more likely to be ground), and then overlay features like water, soil/rock, vegetation, etc. on top of it.

Of course, none of the above applies if you're, say, writing a game of space exploration, in which case you'll just need to generate a bunch of randomly placed star systems according to some density function, and then generate a random set of stars and planets in each of them. Or maybe you're setting you players to explore a non-Euclidean landscape, in which case you'll be facing a completely different set of challenges (such as the fact that the volume within a given radius grows exponentially rather than polynomially, making it really hard to keep a large map in memory).

\$\endgroup\$
7
\$\begingroup\$

Advantages of Procedural Generation

  1. Can easily scale your maps / designs to truly large sizes, much larger than you could create by hand.

  2. By creating a system where chunks of terrain are created on the fly, you can avoid having to write pieces of code to load in chunks from permanent memory.

  3. Over the long term, you may be able to discover more viable levels using procedural design than with manual map editing.

  4. For your 'explorer' game, you can generate many dozens, hundreds or even thousands of levels that are different to one another which keeps the player from getting bored.

Disadvantages of Procedural Generation

  1. Requires much work to ensure that generated terrain looks 'how you want it to'.

  2. Creating 'test levels' becomes a hassle.

  3. Placement of items and other such things, as you mentioned, must be done carefully, though for a top down explorer game this would probably be less of an issue than you think.

  4. Unless extensive testing is done, you may get a scenario where your gameplay breaks completely with a particular procedural level, more so than if you made a level by hand.

  5. For truly complex terrains, you may end up spending more time on bug fixing and design work then you would have spent making a basic map design tool and file loader.

Advantages of Manual Design

  1. The game designer can be more assured that gameplay functions as it should within the context of each level.

  2. It is possible to create and place 'fine details' more easily then you can with procedural generation.

  3. Some terrain features are very difficult to produce procedurally, such as water that flows down a mountain. Doing so would require very thorough evaluation of an elevation map which may be difficult to design.

  4. Easier to guide the player along a 'linear path', though as you say you are building an 'explorer' game, this may not be so relevant.

Disadvantages of Manual Design

  1. Applying widespread changes to your terrain will be time consuming, whereas with procedural generation, merely the modification of a few values will yield completely different terrain.

  2. You will have to store each map in memory, which might be acceptable for small levels, but for larger levels, procedural generation might be your only option. Increases the permanent memory installation requirements of your game.

  3. May require the construction of a map editor and file loading system.

I've ended up listing more disadvantages for procedural content generation, though this is probably because my project is entirely procedural so I know its pitfalls. For an explorer game, I would advise you to consider how large you want each map to be and whether creating separate map editing tools is something you're willing to do.

\$\endgroup\$
1
  • \$\begingroup\$ can you (not here, but somewhere) show the code for your procedural generation? I won't use it, but i've never tried to generate my maps procedurally before. (Which is why i asked this question :P), Also, i upvoted your answer, but sort of want others' opinions, so i may not accept it right away \$\endgroup\$
    – Pip
    Commented Jun 29, 2013 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .