What is procedural generation in video games?
If you have ever played the same game twice and found a different map waiting for you, you have met procedural generation in video games. It is a way of building game content with rules and code instead of placing every piece by hand. This guide explains how it works, what it gets used for, where it helps and where it hurts, and ends with a worked example you can play in your browser.
Procedural generation in video games: a plain definition
Procedural generation means the game creates content while it runs, by following a procedure. A designer writes the rules once. The computer then applies those rules to produce a level, a map, a set of rewards or a tune.
Think of the difference between a drawn map and a recipe for maps. A drawn map is one map. A recipe can produce thousands, and each one follows the same principles. Procedural generation is the recipe.
The key word is rules. Pure randomness gives you noise. Procedural generation gives you variety that still makes sense, because every result has to pass through constraints the designer chose.
How procedural generation works: rules, randomness and seeds
Most generators combine three parts.
- A source of randomness. Games use a pseudorandom number generator. It produces numbers that look random but come from a formula.
- A seed. This is the starting number fed into that formula. The same seed always produces the same sequence of numbers, so it always produces the same content.
- Rules and checks. These shape the random numbers into something playable. Rules decide what may go where. Checks reject results that break the game.
A common pattern is called generate and test. You build a candidate, test it against your rules, and throw it away if it fails. Then you draw again.
Here is the idea in plain steps, the way a designer might write it down:
- Pick a seed, for example
seed = 48213. - Fill half of a grid with walls, using numbers drawn from that seed.
- Mirror that half onto the other side so the layout is balanced.
- Clear the spots that must stay open, like spawn points.
- Run a path check. If any required spot cannot reach its target, go back to step 2 with the next numbers.
- Hand the finished grid to the game.
Steps 3 to 5 are where design lives. Without them you get a random grid. With them you get a level.
What games generate procedurally: levels, maps, loot, enemies and music
Almost anything made of data can be generated. The usual targets are:
- Levels and maps. Room layouts, dungeon floors, terrain, cave systems, arenas.
- Loot and rewards. Which items drop, which upgrades you are offered, what stats they roll.
- Enemies and waves. Which enemies appear, how many, and in what mix, often scaling with progress.
- Music and sound. Melodies or layers assembled from rules, so the soundtrack shifts with play.
- Names, text and quests. Planet names, item names, simple mission goals.
Many games mix generated and fixed parts. A designer might hand build the enemy types and let the generator choose the order. Or hand build every room and let the generator choose how they connect.
Famous examples: the roguelike tradition and beyond
The best known home of procedural generation is the roguelike, a genre named after an early dungeon game from 1980. In a roguelike every run builds a new dungeon, and the fresh layout is what makes starting over worth it.
Since then the technique has spread well past dungeons. You can see a few clear patterns across popular games:
- Huge worlds. Terrain is built from a seed, often with a noise function, so players can share a whole world by sharing one short number.
- Stitched rooms. Designers hand build many small rooms, and the generator stitches them into a full level. Each room is crafted. The route through them is new every time.
- Fixed areas, shuffled contents. The map pieces are known, but rewards, enemy groups and choices change every run.
Those last two patterns are the most practical. They keep the hand of a designer in every piece, and let the generator handle variety.
Procedural vs handcrafted design: benefits and drawbacks
Procedural generation is a tool, not an upgrade. It trades some things for others.
Benefits
- Replay value. You cannot memorize a map that changes. You have to read each one fresh.
- Small files, big content. A generator plus a seed takes far less space than thousands of stored levels.
Drawbacks
- Sameness. A generator has a fixed set of rules and pieces, so its levels can start to repeat.
- Broken output. Without good checks you get unwinnable maps, blocked exits or unfair spawns.
- Weaker set pieces. A carefully paced moment, where every wall teaches you something, is hard to generate.
Handcrafted levels win at teaching and pacing. Generated levels win at freshness. Plenty of good games use both.
How procedural generation powers replayable browser games
Browser games are a good fit, because a generator is small to download and builds a fresh map in the moment. For how a browser draws a game at all, read What is WebGL? How games run in a web browser.
Tank City Reboot is a useful case because its two games take opposite approaches.
The handcrafted side: the first game
The first game, at tankcityreboot.vlvd.net, uses six fixed stages named FIREWALL, CACHE, COOLANT, ENCRYPTION, DATA BUS and KERNEL. Each map is drawn by hand on a 13 by 13 grid. COOLANT, for example, has two coolant rivers across the map, each with one gap on the left and one on the right. That is a deliberate lesson about choke points. After stage 6 the maps repeat with faster enemies. You can learn these maps, and learning them is part of the fun.
The procedural side: Zero Day
The second game, Tank City Zero Day, builds a freshly generated arena for every wave. Its generator follows the same generate and test pattern from earlier:
- Each arena is a 13 by 13 grid drawn from a seed.
- It is a mirror image from left to right, so neither side is favored.
- It always keeps clear the three enemy gates on the top row, your starting spot and the wall around the CPU core.
- It runs a fairness check: every gate and your start must be able to reach the core by going round silicon and coolant. Firewall counts as open in this check, because any tank can shoot through it.
- If the arena fails, it is drawn again.


Notice the design choice in step 4. The check does not ask whether a path is open right now. It asks whether a path could be opened by shooting. That rule reflects the game's terrain: coolant blocks tanks but not shots, while silicon and firewall both block shots. Any tank can break firewall, but silicon only gives way to upgraded shots, such as Pipelining at level 2, so the check treats it as solid.
Zero Day also generates choices, not just maps. After each wave, Patch Tuesday offers upgrade cards drawn from upgrades that have not hit their limit. About one offer in five draws two upgrades instead of three, and a Two-factor card (one extra life) fills the gap. That is procedural loot with a rule attached: you are never offered something you cannot take.
The enemy mix follows rules too. Waves 1 and 2 send only botnet drones and worms. Ransomware joins from wave 3, cryptominers from wave 4, and a zero-day boss breaks through the walls every fifth wave. The arena is new, but the difficulty curve is designed.
Try reading a generated arena
Here is a short workflow for your next Zero Day run. When a wave starts, look at the top row first and find the three gates. Trace the cheapest route from each gate to the core, counting firewall as a door. Those routes are the openings you may need to defend. Keep in mind that botnet drones hunt you, not the core, so watch your own position too. Then check where silicon blocks shots near the core. You are doing the same path check the generator did, only faster, and it tells you where to stand.
Frequently asked questions
Is procedural generation the same as random generation?
No. Randomness is one ingredient, but procedural generation adds rules and checks that shape the result. A random grid can trap you; a procedural arena is tested so every route to the goal can be opened.
What is a seed in procedural generation?
A seed is the starting number for the game's pseudorandom number generator. The same seed with the same rules always rebuilds the same content, which makes results repeatable and easy to share or test.
Does procedural generation use AI?
Usually not in the machine learning sense. Most generators are hand written rules, noise functions and checks, like the arena check above.
Why do roguelikes use procedural generation?
A new layout every run keeps each attempt fresh and rewards reading the map over memorizing it, and it gives a small team far more content than it could draw by hand.
Get started
Want to compare both styles in one sitting? Play a few stages of the first game to learn its handmade maps, then open Zero Day and see how each new arena changes your plan. Both run in a current browser with WebGL 2, on a computer or a phone, and each game remembers your best score in that browser.
Play Tank City Reboot: it is free, plays in your browser on a computer or a phone, and needs no account.
Comments
No comments yet.
Sign in or make an account to comment.