Concepts / Procedural Generation in Gaming

Procedural Generation in Gaming

Procedural generation means using algorithms to generate data, as opposed to generating it manually, and it is common in gaming for levels, maps, items, and characters.

  • Programming

Game Worlds Built as You Play

Think about a game with thousands of levels, maps, weapons, and characters. A common question is whether a developer typed out every one of them and stored the whole collection in advance. In many games, the answer is no. Much of this content is created by an algorithm, and it is produced while the game runs rather than being saved beforehand. This technique is called procedural generation, and gaming is the clearest everyday example of it.

What do you think happens?

If a game shows a map that no developer ever drew by hand, where does that map come from?

  • It was stored in a file before the game was released

  • It is produced as the game runs, by an algorithm following a defined procedure

  • A player typed it in during the game

Reveal answer
Answer:

It is produced as the game runs, by an algorithm following a defined procedure

Procedural generation means the content is created on the fly as the game runs, rather than being stored in advance. A program follows a defined procedure, so the same procedure can produce many items without a person writing each one.

Manual Versus Procedural Creation

There are two broad ways to get a set of data items. In manual generation, a person creates each item by hand. In procedural generation, the items are produced by an algorithm that follows a defined procedure. The difference is not only who does the work, but how the work scales. With manual generation, the number of items you can get is limited by how many a person writes. With procedural generation, the same procedure can produce many items, because the program repeats the procedure rather than waiting for a person to write each one.

Designerwrites each itemItem 1hand madeProceduredefined onceAlgorithm runrepeatedMany itemsproduced by the programItem 2hand madeItem Nhand madewriteswriteswritesappliedoutputs
How the workflow differs when a designer places each item by hand versus when an algorithm produces many items from one procedure.
In the real world

Game content such as levels, maps, items, and characters is commonly created on the fly through procedural generation. The same underlying method that builds these game elements is the one the source says can, in principle, be applied to AI as well, which is why the technique is worth understanding in a data context.

Tracing a Rule-Based Generator by Hand

Rule-based data synthesis is a traditional approach that produces data from predefined rules. The rules are written before generation begins. The generator does not learn them from examples. It applies them. Each output is a product of the rules, so understanding a rule-based generator means understanding its rules. The best way to see this is to run one by hand.

Worked example

Generating three items by hand

A rule-based generator makes items numbered i = 1, 2, 3. Rule A: the item type depends on i. If i leaves remainder 1 when divided by 3, the type is sword. If the remainder is 2, the type is shield. If the remainder is 0, the type is potion. Rule B: the damage value of each item is 2 times i. Rule C: keep a running total of damage across all items produced so far. Trace the generator and report every output.

  1. 1
    Start, i = 1, total = 0

    The generator begins with the first item number. The running total starts at zero because no items exist yet.

  2. 2
    Item 1

    1 leaves remainder 1 when divided by 3, so Rule A gives sword. Rule B gives damage 2 times 1, which is 2. The total becomes 0 plus 2, which is 2. Output: sword, damage 2.

  3. 3
    Item 2

    The output of step one set the total to 2. Now i = 2. Two leaves remainder 2, so the type is shield. Damage is 2 times 2, which is 4. The total becomes 2 plus 4, which is 6. Output: shield, damage 4.

  4. 4
    Item 3

    The total is now 6. Three leaves remainder 0, so the type is potion. Damage is 2 times 3, which is 6. The total becomes 6 plus 6, which is 12. Output: potion, damage 6.

  5. 5
    Stop

    i has reached 3, the last value in the planned range, so the generator stops. The final total is 12.

Result

Three items were produced: sword with damage 2, shield with damage 4, and potion with damage 6. The running total ended at 12. Every value was determined by the rules, and each step used the total left by the step before it.

Starti = 1, total = 0Is i at most 3?range rulePick item typefrom remainder of i dividedby 3Compute damage2 times iRecord itemtype and damageAdd damage to totalrunning totalIncrease i by 1next item numberFinishtotal = 12beginyestype setdamage setitem storedtotal updatedcheck againno
What happens at each step when the predefined rules are applied, and how each output feeds into the next step.

Why Rule-Based Output Is Predictable but Limited

Because the rules are explicit, a rule-based approach makes the structure of the output easy to control. In the trace above, you could predict every item before running the generator, because the rules fully determine the output. If a rule says a value must fall in a certain range, every generated value falls in that range. The same explicitness is the limit. The generator can only produce what its rules describe. If no rule covers a situation, the generator cannot produce it, no matter how many items it creates.

How Simulation-Based Synthesis Records a Run

Simulation-based data synthesis is the second traditional approach. Instead of writing data-producing rules directly, it generates data by running a simulation. The data comes out of the run of the model rather than being assembled field by field. A rule-based generator asks, for each item, what the rules allow. A simulation-based generator lets a modeled process unfold and records what it produces as it goes. The source places robotics among the fields where data synthesis has a long history, and it describes simulation as a traditional technique alongside rule-based synthesis. The source does not describe a specific simulator, so treat this as a conceptual contrast rather than a recipe for any particular tool.

Modeled processsimulated environmentCurrent statestate at this stepState updatesrun moves forwardNew outputproduced by the runRecorded datasetoutputs kept in orderstarts atadvancesyieldsrecordednext step
How data flows out of a modeled process as it runs, the state updates, and each new output is recorded.

Three Approaches Side by Side

Traditionally, data synthesis and augmentation have followed two approaches: rule-based and simulation-based. A newer method, made possible by advanced AI models, uses AI itself to synthesize data. The useful distinction is about what drives the output. The first two approaches rely on rules or simulations that a person designs. The third relies on an AI model to produce the data. The source introduces the AI approach here only as a preview and develops it in the next section.

ApproachWhat produces the dataWhere the knowledge comes fromMain limit
Manual generationA person creates each item by handThe person doing the writingOutput grows only as fast as people can write it
Rule-based synthesisPredefined rules applied by a generatorRules written before generation beginsCan only produce what the rules describe
Simulation-based synthesisA modeled process run and recordedThe model that a person designsOutput reflects what the model captures
AI-powered synthesisAn AI model that synthesizes the dataThe AI model, per the source's previewCovered in the next section of the source

Manual, rule-based, simulation-based, and AI-powered approaches compared at a conceptual level

Mistakes Beginners Make

  • Common mistake

    Thinking procedural generation means the content is random and unstructured

    Why it fails

    Procedural generation follows a defined procedure. The rules give the output its structure, which is why a rule-based generator is described as predictable.

    Do this instead

    Describe procedural output as produced by a defined procedure, and check which rules shape each part of the output.

  • Common mistake

    Assuming a rule-based generator will eventually produce any possible item if it runs long enough

    Why it fails

    The generator can only produce what its rules describe. Running it more times does not add cases the rules never allowed.

    Do this instead

    Ask whether a rule covers the case you want before expecting the generator to produce it.

  • Common mistake

    Treating simulation-based synthesis as just another list of rules

    Why it fails

    In simulation-based synthesis, data comes out of the run of a modeled process rather than being assembled field by field from rules.

    Do this instead

    Think of the output as a record of a process unfolding over time.

  • Common mistake

    Confusing the traditional approaches with the AI-powered approach, which uses an AI model to produce the data

Practice Tracing the Generator

EASY

Use the same three rules from the worked example, but start the total at 0 and run i from 1 to 4. After item 4 is produced, what is the running total?

Hints
  • Work through items 1, 2, and 3 first. Their totals should match the worked example: 2, then 6, then 12.
  • For item 4, 4 leaves remainder 1 when divided by 3, so the type is sword. Its damage is 2 times 4.
  • Add the damage of item 4 to the total you had after item 3.
MEDIUM

Explain in one or two sentences why you could predict every output of this generator before running it, and what you would have to change in the rules to produce an item type that the current rules never allow.

Hints
  • Think about which parts of the output the rules fully determine.
  • A new kind of item needs a new rule that describes it.

Key Takeaways

  • Procedural generation uses algorithms to produce data according to a defined procedure, in contrast to manual generation, where a person creates each item by hand.
  • A rule-based generator applies predefined rules, so its output is predictable and controllable, but its coverage is limited to what the rules describe.
  • Simulation-based synthesis produces data by running a modeled process and recording what it produces, rather than assembling data field by field from rules.
  • The traditional approaches rely on rules or simulations that a person designs, while the newer AI-powered approach uses an AI model itself to synthesize data.
  • Gaming is the clearest everyday example, where levels, maps, items, and characters are produced on the fly as the game runs.

Related concepts

More concepts starting with P