Slightly related to a recent post.
I understand procedural generation in video games is basically an instruction set to tell the computer to run through to get the same result every time so that it doesn’t load a whole level each time, it builds the level based on a set of parameters.
How is this different than just loading a built level? Isn’t that what a normal script of code is in any other game? Is an instruction set to tell the computer to load the level?
Is it just the difference between one being done by a programmer and one done by a level designer/artist? They both need assets already designed and made to work right?
In: 30
Your grasp on precedural generation is flawed. Procedural generation means that while the game has some set parameters according to which it generates maps, it has no specific instructions. Parameters may include things like “structures have to be supported” “each structure has to be made of the same material” “X plants or trees need x,y,z conditions to grow” “a desert biome can’t be next to an arctic biome” “mountains need to stay within specific gradients” etc etc. Basically all those rules and limitations guide how the map can be made, but they’re not clear instructions like “a mountain here, a river there, a cave over there”
Procedural generation means that random maps are created but they have to adhere to specific parameters.
Regular generation means that the map has been designed before hand and it’s simply loaded into your game.
Consider a chessboard. You want to make a chess “level” by putting pieces on the chessboard.
A “built level” would work like this…you decide where to place the pieces on the chessboard, and write down what piece is in each square on the chessboard. So like, king on the first square, then nothing, then a pawn, then a rook, then nothing…”. So when the level is “loaded” somebody reads your instructions and puts pieces on the board according to what piece you said goes in each square.
A “procedurally generated” level would work like this. You write down “for each square, roll a 6 sided dice. If it lands on a 1, place down a chess piece. Roll another 6 sided dice to decide what kind of piece it is”. Then when the level is “loaded” somebody reads your instructions, rolls the dice, and places pieces. You can control how likely different things show up based on the instructions you provide, but the details are random.
To understand seeds, imagine that instead of rolling dice you have sheets of paper covered with long lists of random numbers between 1 and 6. To “load” the level, instead of rolling dice someone just reads down this paper one by one starting at the first number. Anyone who uses this particular “seed” and your instructions will get the same board pattern. Anyone using a different sheet of paper with different number (a different seed) will get a different board pattern. There are some technical differences here…real seeds aren’t the lists of random numbers themselves, but a number that _makes_ a particular list, but hopefully this helps give you the idea.
For regular games: (an RPG or first person shooter) designing the level involves designing the terrain, and the flora and fauna, and the buildings, and the characters, and all the various 3D models and animations/model-rigging and textures.
For procedural generation (PG) : designing the level involves the developer building a system/algorithm that can generate the scene from a series of random numbers. With a different series of numbers, you get a different scene.
e.g. To build a mountain level, the first number might be the number of mountains (say.. “7”), then the next 7 numbers would be interpreted as the heights of each mountain, then the next 14 numbers would be the x and y (or latitude and longitude) of each of those mountains etc. Or more typically, you’d use the number series to generate a “height map” which is just a grid of squares and each number is the height of the next point.
Typically though, you use a mix of both. On huge, non-procedural games, they don’t hand-craft every single tree and bush, but let procedural generation place a lot of these kind of objects, and then hand-craft the interesting locations.
Similarly very, very few games are completely PG (with procedurally generated models and textures) but rather they have a set of hand-crafted tree models, and building models, and outpost layouts etc., and uses the PG system to place these, and select which of the trees to use, and which way to rotate it etc.
Hand-crafted games are usually more interesting and varied, but increase the game size, and take a lot of time and effort from the designers.
PG games can generate effectively infinite content, with far, far less game size needed; but often become very repetitive and boring once you start seeing patterns emerge. They can also present problems for the game AI, with characters getting stuck on the terrain or not being able to path-find (since no one may ever see much of the PG content, let alone test it to make sure it’s traversable by the player and by the NPCs).
Imagine a space game where we have different planets. Each planet’s characteristics is determined by a set of 16 digits strung together, say the first 3 numbers represent size, the next digit is the color, the next is type of planet, and then then the next few digits are the x y and z coordinates.
So a planet would look like 4783079433924570.
With regular generation, we would manually pick values for each planet and store them in a list. If we had a million planets, each of those values would have to be stored on a hard drive somewhere. That would be a million x 16 digits, so roughly 15.26 MB of data.
For procedural based generation, instead of storing data on the harddrive, we could instead find a decimal number that repeats infinitly with no patterns. For example, pi or the square root of 2. We could use that list of digits and do some fancy math to split the number up in to 16 digit chunks and generate our planets from that. We just need to store that math function and do some extra processing to get our planets.
Procedural saves on hard drive space, but takes up more computing power to get the same level of detail. We would also need to find a cool infinite number to use, otherwise, there could be weird results, like 3 planets stacked inside each other. With regular generation, we could hand pick our values. More work, but we can minimize any weirdness and make every look good.
Latest Answers