Random, but repeatable
Many games generate levels, maps, planets or dungeons by program rather than by hand. This is procedural generation. A natural worry is that “random” content should be impossible to reproduce, yet many games let players share a seed, a short number or text, so friends see the identical world.
The explanation is that computers usually do not produce truly unpredictable numbers. They use pseudo-random generators: deterministic formulas that, given the same starting value, always output the same sequence. That starting value is the seed.
How a seed works
A generator keeps an internal state. Each time the game asks for a number, the generator updates its state and returns a value that looks random. Start from the same seed and ask in the same way, and the exact same sequence appears.
A game might then use that sequence to make decisions:
- Is there a room to the north? Use the next number: below a threshold means yes.
- How wide is the corridor? Map the next number onto a range.
- Which item sits in the chest? Use the next number with a weighted random table.
Because every decision is derived from the sequence, the entire world is determined by the seed and the rules. Change the seed and a different world appears. Keep the seed and nothing changes.
How many worlds can a seed describe?
A seed stored in 32 bits can take 2^32 different values, which is 4,294,967,296. A 64-bit seed allows 2^64, about 1.8 × 10^19 values. These large counts are why a game can feel endlessly varied.
There is a catch. The number of distinct seeds limits the number of distinct worlds that seed alone can produce. If a game lets you pick from about 4.3 billion seeds, it cannot show you more than that many different worlds from that mechanism, however large the visible world appears. Different seeds can also yield very similar results if the rules leave little room for variation. Variety depends on the generation rules as much as the seed.
Generating without storing
Seeded generation has a practical benefit: large worlds need not be stored. A game can compute a region when the player arrives. To make this work for regions visited in any order, many games derive a local value from the seed and the region’s coordinates, then use that value to generate the region. That way, a region always looks the same no matter when it is first visited.
This is a different approach from drawing one long sequence from start to finish. If a world is generated by a single sequence, the result depends on the order in which things are generated.
The order-of-use pitfall
Because the sequence is fixed, any change to the order or number of requests changes everything after it. Suppose a game generates a lake, then a forest, then a village, each consuming numbers from one sequence. If a developer adds a new feature that uses an extra number before the village, the village is generated from different numbers and lands somewhere else. Worlds made before and after the update can differ even for the same seed.
For this reason, games often use separate generators for separate tasks, or derive sub-seeds, so a change in one area does not disturb the others. It is also why shared seeds are sometimes tied to a specific game version.
Randomness combined with rules
Pure randomness makes poor levels. If every tile were chosen independently, a map might block the exit or place all treasure in one corner. Designers therefore combine randomness with constraints:
- Rules and templates. Random choices pick from hand-made pieces that fit together.
- Smooth noise. Terrain often uses functions that vary gradually, so hills look like hills.
- Validation. The generator checks the result, such as confirming the exit is reachable, and retries or repairs if not.
- Controlled item flow. Mechanisms like shuffle bags guarantee a steady supply of key items, rather than leaving them to chance. This links to broader game design randomness.
Shaping random output so that it feels fair and interesting is a design problem more than a mathematical one.
What seeded randomness means for players
- Shared seeds let players compare runs on the same layout, which can make competition fairer in some modes.
- Knowing the seed can allow planning, because the world is fixed. That is useful for challenges, but it removes surprise.
- A “random” world is not “fair”. The same rules that produce a good world can sometimes produce a frustrating one by chance.
- Streaks of similar content appear in random generation just as they do in dice. Seeing three similar rooms in a row does not prove the generator is broken.
A note on testing
Developers often check generators by producing very many worlds and counting how often something occurs, a Monte Carlo simulation approach. This reveals how frequently a rare layout shows up, something that is hard to work out by hand.
Procedural generation is a use of chance that is not tied to winning or losing. It is a tool for building variety, and the main idea to keep is simple: a seed makes randomness reproducible, and the rules around it decide what the result looks like.