When David Braben and Ian Bell needed to fit eight fully navigable galaxies, 2,048 star systems, and thousands of planets into 32 kilobytes of BBC Micro RAM, they did not hand-craft a single world. They seeded a deterministic pseudo-random number generator with a fixed value and let mathematics conjure the entire universe on demand. That game was Elite, released in September 1984. Every planet name, economy type, and government classification was computed from that seed — no disk storage, no streaming, no cloud. Procedural generation was not an aesthetic choice; it was the only engineering solution that fit the hardware reality.
Four decades later the discipline has scaled from 32 KB space operas to Hello Games' No Man's Sky, which procedurally generates 18 quintillion planets, each with unique flora, fauna, geology, and atmosphere. The mathematics changed; the core insight did not.
Procedural Content Generation (PCG) is the use of algorithms — rather than hand-authored assets — to create game content at design time, load time, or runtime. The word "procedural" signals that a defined procedure (a set of mathematical or logical rules) drives creation, producing outputs that would be impractical or impossible to create entirely by hand.
PCG operates across a spectrum of autonomy. At one end, a designer manually places every tree but uses a noise function to vary their height. At the other, a fully autonomous system designs entire quests, populates them with characters, writes dialogue, and balances loot tables — all without human input after the initial system design. Most shipped games sit somewhere in the middle: mixed-initiative PCG, where human artists constrain the parameter space and the algorithm fills it.
The content types PCG can address are broad: terrain and geography, dungeon layouts, narrative and quests, items and loot, textures and materials, music and sound, enemy placement, puzzle design, and — increasingly — character dialogue generated by large language models at runtime.
PCG offers three properties that purely hand-crafted content cannot simultaneously achieve. Speed: an algorithm can generate a 1,000-room dungeon in milliseconds; a level designer cannot. Variety: replayability improves when content differs across playthroughs; Spelunky's daily challenges, for instance, share a common seed so all players compare identical runs. Scale: hand-crafting 18 quintillion planets is not a staffing problem; it is a category error. Only procedural approaches make planetary-scale content tractable.
These benefits carry trade-offs. Algorithmic content can feel repetitive at the structural level even when surface details vary — a critique leveled at early No Man's Sky, where planets felt samey despite unique color palettes. Managing perceived variety versus structural variety is one of the central design challenges in PCG. Developers at Mojang addressed this in Minecraft by defining distinct biome identities before seeding surface detail, ensuring that a desert and a jungle felt categorically different even if their generation system shared common code.
A crucial concept for any designer working with PCG is the distinction between true randomness and pseudo-random number generation (PRNG). True randomness — sourced from hardware entropy — produces results that cannot be reproduced. PRNGs, by contrast, start from a seed value and generate a deterministic sequence that merely appears random. Given the same seed, the PRNG always produces the same sequence.
This determinism is enormously useful. Minecraft world seeds are shareable strings: entering "Glacier" on any device generates the same mountain range. Spelunky's daily challenge seed ensures fair comparison. Dwarf Fortress encodes entire civilizational histories in a single 64-bit integer. The seed is both a compression mechanism and a social artifact — players trade seeds like coordinates to interesting places.
Modern PCG systems often layer multiple PRNG streams: one for terrain macro-structure, one for biome selection, one for vegetation placement. Keeping these streams independent prevents a change to one content type from invalidating all others — a lesson learned painfully by Minecraft's development team when biome algorithm updates broke saved worlds.
Before choosing a PCG technique, define what must be consistent (playable layout, fair difficulty) versus what can be variable (visual surface, item flavor). Conflating these is the most common source of PCG-generated content that feels both random and unsatisfying.
Researchers classify PCG methods along several axes. The most practical for designers is the distinction between constructive and generate-and-test approaches. Constructive methods build content in a single pass — fast, predictable, but potentially limited in the complexity of constraints they can satisfy. Noise-based terrain is constructive. Generate-and-test methods produce candidate content, evaluate it against constraints, and regenerate if it fails — slower but able to guarantee properties like connectivity, solvability, or minimum enemy count.
Other major technique families include: grammar-based generation (using formal rewriting rules, as in L-systems for vegetation or shape grammars for architecture), search-based PCG (using evolutionary algorithms or Monte Carlo Tree Search to optimize content against a fitness function), machine learning approaches (training generative models on human-authored content), and constraint satisfaction (encoding design rules as constraints and solving for valid configurations). Later lessons in this module examine noise functions and dungeon generation in detail.
The 1980 Roguelike Rogue — which gave the genre its name — used BSP (Binary Space Partitioning) tree generation to create unique dungeon layouts every playthrough. Its developers, Michael Toy and Glenn Wichman, wrote it for Unix systems at UC Santa Cruz. The procedural dungeon was not a feature; it was a workaround for not having enough content to sustain repeated play. That practical constraint became the defining aesthetic of an entire genre.
In this lab you will discuss core PCG concepts with your AI assistant. Ask it to compare PCG techniques, explain why deterministic seeds matter, or help you think through which PCG approach suits a specific game idea. Push past surface definitions — ask for trade-offs, real examples, and design consequences.
Complete at least 3 exchanges to unlock the next lesson.
While working on the visual effects for Tron at Information International Inc., Ken Perlin was frustrated with what he called the "machine-like" quality of computer-generated textures — they looked too perfect, too regular. In 1983 he developed a gradient noise function that introduced structured, naturalistic randomness into surfaces. He called it Perlin noise. The function won him an Academy Award for Technical Achievement in 1997.
Game developers immediately recognized that the same function that made marble textures look organic could generate terrain height maps. Sample Perlin noise at different frequencies and amplitudes, sum the results (a technique called fractal Brownian motion), and you get convincing mountain ranges, rolling plains, and island coastlines — all from a single mathematical expression evaluated at a point in 2D or 3D space.
Perlin noise assigns a pseudo-random gradient vector to each integer coordinate on a grid. To evaluate the noise at any continuous point, the algorithm interpolates between the gradients of the surrounding grid corners using a smooth (fade) curve — typically 6t⁵ − 15t⁴ + 10t³, chosen because its first and second derivatives are zero at the grid corners, preventing visible discontinuities.
The result is a smooth, continuous function that: returns values roughly in the range [−1, 1]; has no preferred direction (isotropic); and tiles seamlessly if the grid is made periodic. These properties make it ideal for height maps, cloud density, cave density, and any natural phenomenon that varies smoothly but unpredictably across space.
In 2001, Perlin published an improved version called Simplex noise, which reduces computational complexity from O(2ⁿ) to O(n²) in n dimensions and eliminates the directional artifacts visible in Perlin noise at high frequencies. Simplex noise is now the default choice for new implementations, though "Perlin noise" remains the colloquial term in game development communities.
Raw single-frequency noise looks like gentle hills. Real terrain has detail at multiple scales: continent-level elevation, regional mountain ranges, local ridges, and surface roughness. Designers achieve this by layering multiple noise samples at different octaves — each octave doubling (or otherwise scaling) the frequency and reducing the amplitude.
Three parameters control this layering. Octaves sets how many layers to combine. Lacunarity (from Latin lacuna, gap) is the frequency multiplier between octaves — typically 2.0. Persistence (or gain) is the amplitude multiplier between octaves — typically 0.5, meaning each layer contributes half the influence of the previous. Raising persistence increases roughness; lowering it creates smoother, more rounded terrain.
Minecraft's terrain generation, overhauled extensively in the 1.18 "Caves & Cliffs" update released in November 2021, uses 3D noise (rather than 2D height maps) to generate its overhangs, arches, and cave systems. The shift from 2D to 3D noise was specifically what enabled overhanging terrain and floating islands — 2D noise can only describe one height value per (x,z) coordinate, making overhangs geometrically impossible.
Domain warping — feeding the input coordinates of one noise function through another noise function before evaluating — produces the swirling, folded shapes found in river deltas, lava flows, and eroded coastlines. Shader artist Inigo Quilez popularized the technique and it has since become standard for adding organic complexity to game terrain without significant additional computation.
Biome placement is typically handled by a separate, lower-frequency noise layer (or a Voronoi diagram) that assigns each region a biome category before surface detail noise is applied. Biome blending — interpolating terrain parameters (moisture, temperature, roughness) across biome boundaries — prevents the hard seams that made early procedural games feel patchwork. Minecraft's Bedrock edition uses a five-dimensional parameter space (temperature, humidity, continentalness, erosion, weirdness) to place biomes, blending them smoothly through the same interpolation techniques used in the noise functions themselves.
When tuning terrain noise for a game, start with two octaves, adjust persistence until macro-shape feels right, then add octaves one at a time to introduce detail. Adding too many octaves early makes it hard to distinguish which parameter is responsible for unwanted shapes. Good terrain generation is iterative parameter tuning, not algorithmic complexity.
Noise functions are not limited to terrain height. They drive: cave density (values below a threshold = solid rock; above = air); ore vein placement (Minecraft's ore generation uses 3D noise thresholds); wind and weather simulation (fluid simulation seeded with noise initial conditions); texture synthesis (wood grain, rock surface, skin pores); and ambient sound placement (density of bird calls, insect noise, wind intensity based on elevation noise).
The underlying principle is the same in every case: noise provides a spatially coherent, smoothly varying scalar or vector field. Any game system that needs a value to vary naturally across space — without the artist painting every square meter by hand — can be driven by appropriately tuned noise.
The Unity and Unreal Engine terrain generation tools both ship with built-in Perlin/Simplex noise utilities. Unreal's Landscape system, introduced in Unreal Engine 3 for the 2006 game Gears of War, used noise-driven height map generation as its baseline, allowing artists to sculpt on top of generated terrain rather than building from flat geometry. This hybrid approach — algorithmic base, hand-authored polish — remains the industry standard for open-world terrain pipelines.
In this lab you will explore how noise function parameters affect terrain character. Ask your AI assistant to help you reason through how changing octaves, persistence, or lacunarity would affect a specific game world — or describe a terrain type you want and ask it to suggest parameter strategies. Try to connect the math to actual player experience.
Complete at least 3 exchanges to unlock the next lesson.
When Maxim Gumin published the Wave Function Collapse algorithm on GitHub in March 2016, he framed it as a bitmap generation technique. Within weeks, game developers had adapted it to generate tile-based levels that maintained local adjacency constraints — every room connected properly, every wall logically placed — without the developer writing explicit placement rules. The algorithm, borrowed conceptually from quantum mechanics' superposition collapse, spread through the indie game community with unusual speed. By 2017, it was generating content in dozens of published games and had been integrated into several commercial game engines as a first-class tool.
Binary Space Partitioning (BSP) tree generation — the technique used in the 1980 game Rogue — works by recursively subdividing a rectangular space into two sub-regions until regions reach a minimum size, then placing rooms within each leaf region and connecting adjacent rooms with corridors. The algorithm guarantees: every room is reachable (via the connection tree), no rooms overlap, and the spatial distribution of rooms is roughly uniform.
BSP generation is deterministic, fast, and produces well-structured dungeons, but its recursive subdivision can make layouts feel grid-like and predictable after repeated exposure. The rooms in a BSP dungeon tend to be isolated rectangles connected by straight corridors — functional, but lacking the organic quality of real caves or architectural spaces. Modern implementations address this by: randomly sizing rooms within leaf regions, adding curved or L-shaped corridors, post-processing walls with cellular automata to erode hard edges, and occasionally inserting "special" hand-authored room templates at leaf positions.
Cellular automata (CA) cave generation starts with a grid of cells randomly initialized to "wall" or "floor" based on a fill percentage (typically 45–55% wall). The algorithm then applies a birth/survival rule for a fixed number of generations: a wall cell becomes floor if it has fewer than a threshold number of wall neighbors; a floor cell becomes wall if it has too many wall neighbors. The canonical rule — "if a floor cell has fewer than 4 wall neighbors, it becomes wall; if a wall cell has 5 or more wall neighbors, it stays wall" — produces cave-like structures within 4–5 generations.
CA caves look organic and natural but do not guarantee connectivity. A post-processing step using flood-fill (or a union-find data structure) identifies disconnected caverns and connects them with carved corridors. The game Dwarf Fortress, whose cave generation is among the most studied in the industry, uses CA-derived cave forms combined with geology simulation to produce caves that have bedrock layers, aquifers, and magma seas — each governed by different generation rules stacked on the same CA foundation.
Wave Function Collapse (WFC) is a constraint propagation algorithm. Given a set of tiles and adjacency rules (which tiles can neighbor which other tiles in each direction), WFC maintains for each grid cell a superposition of all still-possible tiles. It then selects the cell with the lowest entropy (fewest possible tiles), collapses it to a single tile choice, and propagates the constraint change to neighboring cells — eliminating now-impossible tiles from their superpositions. If propagation causes a contradiction (a cell with zero possible tiles), the algorithm backtracks and retries.
WFC's power is that adjacency rules can be learned from examples rather than authored manually. Feed the algorithm a hand-drawn sample tilemap and it will extract the adjacency constraints automatically, then generate new maps that respect every local pattern in the sample. This makes WFC particularly valuable for generating content that matches an art style — the generated output always "looks like" the training sample because it obeys the same local rules.
The game Bad North (2018) by Plausible Concept used WFC to generate the island landscapes that form each combat map. The studio published a detailed postmortem noting that WFC's constraint-satisfaction properties made it possible to guarantee that every island had accessible beaches, interior high ground, and tactically varied terrain — properties that random noise-based generation could not reliably ensure without extensive post-processing.
Use BSP when you need guaranteed room connectivity and rectangular, dungeon-like layouts. Use Cellular Automata when you want organic, cave-like shapes and can post-process for connectivity. Use Wave Function Collapse when you have a strong art style and need local coherence — generated content that "looks like" your sample. These are not mutually exclusive: many shipped games combine BSP macro-structure with CA surface erosion and WFC tile detail.
A generated level that is beautiful but not completable is not a game feature — it is a bug. Ensuring generated levels are playable requires defining what playability means in terms the generation system can verify. For a dungeon: Is there a path from start to exit? Are all keys reachable before their corresponding locks? Can the player reach every mandatory objective?
The standard approach is to generate a level, then run a graph reachability analysis (simulating player inventory states and checking which areas become accessible in each state). Levels failing the analysis are either rejected and regenerated or corrected by targeted edits (inserting a missing key, carving a missing corridor). The Spelunky series, developed by Derek Yu and Andy Hull, uses a generate-and-test approach where each level template is verified for a valid path from entrance to exit before the player loads in — the verification step is fast enough that rejection-and-regeneration does not impact load time.
More sophisticated approaches model the player as an agent with a capability set and test whether the agent can complete the level using those capabilities — a form of automated playtesting built directly into the generation pipeline. This is computationally heavier but catches a wider class of unplayability bugs, including soft locks caused by unconventional player routing.
The designers of Spelunky 2 (2020) intentionally restricted the WFC-like tile grammar to ensure that every generated level contains at least one "shortcut" path shorter than the standard route, preserving the feeling of discovery and rewarding player exploration of generated space. Structural constraints like this — imposed on the algorithm before generation — are how designers maintain authorial intent inside procedural systems.
Use the AI below to explore Lesson 3 concepts in depth. Challenge assumptions and work through scenarios.
When Sean Murray and the team at Hello Games shipped No Man's Sky in August 2016, they had procedurally generated 18 quintillion planets. Critics noted, almost immediately, that despite the astronomical variety, many planets felt similar. The critique exposed a fundamental tension in large-scale PCG: mathematical variety is not the same as experiential variety. No Man's Sky had enormous surface diversity — different colors, different creature silhouettes — but the underlying structural grammar repeated too visibly. The team's subsequent updates (notably the "Next" update in 2018 and the "Origins" update in 2020) did not increase the number of planets; they deepened the diversity of structural patterns within them. That distinction — between adding more and adding different — is the central design challenge of modern PCG at scale.
No modern game uses a single PCG technique. The practical reality is a layered generation pipeline in which different algorithms operate at different scales, each responsible for a different level of abstraction. No Man's Sky exemplifies this architecture at its most ambitious: the generation pipeline moves from galaxy layout (star system distribution via noise-seeded spatial hashing) → star system composition (planet count, orbit radii, star type) → planetary macro-geography (continent shapes, ocean coverage, polar cap extent) → terrain surface (Perlin/simplex noise with biome blending) → biome flora and fauna (procedural creature assembly from modular body-part grammars) → resource placement (ore veins, harvestable materials via 3D noise thresholds).
Each layer is generated deterministically from a seed propagated through the hierarchy. The planet's seed is derived from its position in the star system; its terrain seed from the planet seed; its creature seed from a biome-level sub-seed. This hierarchical seeding means every detail is reproducible and shareable, while changes at one level cascade downward consistently without disrupting sibling elements at the same level.
The same layered approach governs other large-scale PCG games. Dwarf Fortress generates geology (rock strata, aquifers, magma layers) first; then hydrology (rivers, lakes, aquifer drainage); then civilization history (migrations, wars, artifact creation) — each layer consuming outputs of the layers above it as constraints. The result is a world in which geological features shape civilization patterns in ways that feel emergent rather than scripted, because they actually are causally connected through the generation pipeline.
Spelunky (Derek Yu, 2008; rebuilt with Andy Hull in 2012) solved a problem that plagued early roguelikes: purely algorithmic generation can produce levels that are unenjoyable, unfair, or structurally incoherent even if they are technically valid. Yu's solution was designer-constraint PCG — encoding the designer's taste directly into the generation grammar rather than applying it as a post-processing filter.
Spelunky's levels are built from a 4×4 grid of "room chunks" — pre-authored room templates, each approximately 10×8 tiles, designed by Yu himself. The generator selects chunks and assembles them according to a rule set that guarantees: a navigable path from entrance to exit, a minimum number of challenge rooms, and a coherent spatial logic. The player never sees the template seams because the chunk library is large enough and the assembly rules varied enough that repetition is rare across a normal play session.
This approach — sometimes called mixed-initiative PCG or constrained template assembly — preserves authorial quality while generating variety. Every room chunk was play-tested by a human designer. The algorithm's job is assembly, not invention. The result is that Spelunky's levels feel handcrafted even though they are generated, because the atomic units of generation (the chunks) were handcrafted. This is the core trade-off: the more designer input goes into the generation grammar, the more reliably "good" the output feels, but the more the generation resembles sophisticated shuffling rather than true creation.
The most common failure mode in PCG is delegating quality judgments to the algorithm. Algorithms can guarantee structural properties (connectivity, reachability, valid tile adjacency) but cannot evaluate whether a space feels interesting without a designer-authored fitness function or a designer-authored template library. Identify which quality properties you can specify formally (as constraints or fitness criteria) and which require a human template. Design your PCG pipeline to handle each appropriately.
The newest addition to the PCG toolkit is machine learning — specifically generative models trained on human-authored content. Where traditional PCG algorithms produce content according to designer-specified rules, ML-based PCG learns statistical patterns from existing content and generates new content that matches those patterns. The appeal is obvious: the generated output "inherits" the quality of the training data without the designer having to formally specify every rule.
In practice, ML-based PCG is most useful for tasks where the desired output is stylistically consistent with a large body of training examples but where exhaustive rule specification would be impractical. Texture and material generation (training a generative model on a studio's existing art assets to produce new materials in the same style), dialogue generation (fine-tuning a language model on a game's existing NPC dialogue to generate contextual variations), and level suggestion (using a model trained on human-designed levels to propose layouts for a designer to review and edit) are current industry applications.
The critical caveat: ML-generated content inherits not just the quality of training data but also its failure modes. A model trained on fantasy dungeon maps will produce convincing fantasy dungeon maps — and will have no concept of structural requirements (connectivity, key placement, critical-path logic) unless those are explicitly encoded as constraints or evaluated by a separate validation system. Combining ML generation with traditional constraint-validation is the current state of the art for production-quality AI-assisted PCG.
The fundamental tension in PCG has not changed since Rogue's developers chose procedural dungeons over hand-authored ones in 1980: algorithmic content scales indefinitely but risks feeling mechanical; handcrafted content feels intentional but cannot scale. Every design decision in PCG is a negotiation between these poles.
Scale-priority games (No Man's Sky, Elite Dangerous, Minecraft) accept structural repetition in exchange for sheer volume — their value proposition is exploration of a space too large to exhaust. Quality-priority games (The Last of Us, Dark Souls, Portal) reject PCG almost entirely, preferring every encounter to be precisely authored. The middle ground — where most games now live — uses PCG for volume (loot tables, minor NPC dialogue variations, terrain surface detail) while hand-authoring the high-stakes content (boss encounters, main quest sequences, key narrative moments).
The emerging design discipline is PCG triage: systematically identifying which content types benefit most from generation (high-volume, low-salience content) and which must remain hand-authored (low-volume, high-salience content). A game with 10,000 procedurally generated background conversations and 40 hand-authored companion-character story moments is applying this triage correctly. Applying PCG to the companion moments to save time is the classic mistake — the algorithm saves cost but destroys the experiential value that made those moments worth having.
No Man's Sky at launch generated 18 quintillion planets from a codebase of approximately 600,000 lines. The entire universe fits in under 8 MB of generation seed data. For comparison, a single high-resolution texture in a AAA game is typically 4–16 MB. Procedural generation's compression ratio — experiential content per byte of storage — remains unmatched by any other content production technique. The engineering challenge is not storage or compute; it is ensuring that the 18 quintillionth planet is as interesting as the first.
Apply and extend the concepts from this lesson through guided conversation with an AI assistant.
Use this lab to explore how the concepts from Lesson 4 apply to your own questions and interests. The AI assistant is here to help you think through complex scenarios.
15 questions covering all lessons — free, untracked, retake anytime.