Chance in Video Games

Procedural Generation and the Odds of a Rare Map

How seeds and weighted tables let games generate huge numbers of layouts, and how to work out the chance that a rare room, map or item turns up in a run.

On this page
  1. What procedural generation does
  2. Seeds: one number, one world
  3. Weighted tables decide what appears
  4. The chance that a rare room appears
  5. Counting how many layouts exist
  6. Rarity is partly a definition
  7. Reading claims about rare seeds

What procedural generation does

Procedural generation means building game content with rules and random numbers instead of placing everything by hand. A dungeon crawler may assemble each floor from a library of room templates. A survival game may grow terrain from mathematical noise. A roguelike may decide which items appear in which chests. The result is that a player meets a different arrangement on each run, without the developers having to draw each one.

Two ingredients do most of the work: a seed, which fixes the random sequence, and weighted choices, which decide how often each option appears.

Seeds: one number, one world

A seed is the starting number for a pseudo-random generator. If the game, the version and the seed are all the same, the generator produces the same sequence of values, so the same world or layout is built again. That is why players can share seeds to compare maps, and why a bug can be reproduced by loading the same one.

Some points worth knowing:

  • Many games pick a seed at random for each new world, often from the clock. The player may be able to type one in instead.
  • Different versions of a game may build different worlds from the same seed, because changes to the generation rules alter how the numbers are used.
  • The number of possible seeds is large but finite. A 32-bit seed allows 2³², or 4,294,967,296, values. A 64-bit seed allows about 1.8 × 10¹⁹. But the number of worlds that feel meaningfully different is usually much smaller than the number of seeds.

More about how the underlying sequences work is in the article on pseudo-random generators.

Weighted tables decide what appears

Within the generator, the choice of room, biome or item is typically made from a weighted table. Say a level builder picks each room from this list:

Room type Weight Chance
Ordinary corridor 70 70%
Treasure room 20 20%
Trap room 8 8%
Hidden vault 2 2%

The weights add to 100, so each weight equals the chance as a percentage. With weights that do not add to 100, each chance is the weight divided by the total. The idea is explained in more detail in the article on weighted tables.

The chance that a rare room appears

If a level has 10 rooms and each one is chosen independently with the 2% vault chance, the chance of at least one vault is easiest to find by first working out the chance of none, the shortcut known as complement counting.

  • Chance a single room is not a vault: 0.98
  • Chance none of 10 rooms is a vault: 0.98¹⁰, about 0.817
  • Chance of at least one vault: 1 − 0.817, about 0.183, or 18%

So roughly 1 level in 5 or 6 would include a vault, even though each individual room is only 2%. Over more levels, the chance of seeing one at some point rises, though never to certainty. Across 5 levels, the chance of no vault at all is 0.817 raised to the 5th power, which is about 0.36, so around 64% of runs would see at least one.

This is the same arithmetic as loot drop rates: small chances repeated many times add up, but not as fast as people tend to guess.

Counting how many layouts exist

The number of possible layouts grows very quickly. If a level has 8 room slots and each slot can be filled with any of 6 room types, the count is 6 × 6 × 6 × 6 × 6 × 6 × 6 × 6 = 6⁸ = 1,679,616 layouts. Each extra slot multiplies the total by 6. That is the multiplication principle: independent choices multiply instead of add.

A huge number of layouts does not mean each is equally likely or equally different to a player. Weighted tables make some layouts far more common than others, and two layouts that differ only in a few rooms can feel the same. Many generated worlds feel similar because the choices stay within the same limits, even when the count of possibilities is enormous.

Rarity is partly a definition

When players talk about a rare map, the rarity depends on what counts as the same. A very specific layout, such as one exact arrangement of rooms, is almost always extremely unlikely, because there are so many arrangements. A feature, such as a vault or a particular biome next to a lake, can be reasonably common. So a statement like “one in a million seed” can be true of a pattern while being meaningless for how often a player sees something distinctive.

It also matters whether the generator has constraints. Most generators check that the level can be completed, that rooms connect and that important items are reachable. A constraint can reject or rewrite random results, which changes the chances from what the raw table would suggest. A designer may also guarantee that a feature appears at least once in a fixed number of floors, which turns an independent chance into something closer to a pity timer.

Reading claims about rare seeds

When you see claims about how rare a seed or map is, some questions help:

  • Is it the exact world that is rare, or a feature within it?
  • Which game version produced it?
  • Do the quoted odds account for constraints in the generator, or are they a simple product of chances?
  • Are the numbers estimated by counting, or measured by generating many worlds and checking? A Monte Carlo simulation, meaning a large number of generated worlds checked for the feature, is a practical way to estimate a frequency when the exact calculation is hard.

Treat any quoted frequency as an estimate unless the method is shown.

The complete guide to chance in video games

How Randomness Works in Video Games
Read the guide

Keep exploring

Guides from other topics

All topics →