AI Game Dev Search

Procedural generation that doesn't look random: 5 techniques, tested on 1,000 seeds

Noise terrain, a Spelunky-style room grid, cellular-automata caves, Poisson-disk scattering and wave function collapse, each next to plain random and checked on 1,000 seeds.

Tested with Claude Code 2.1.296 · Opus 5.5

Two maps side by side. Random value per tile: colourful static. Layered noise: green land, blue lakes, sand shores and grey mountains. Below, five labels: Noise, Room grid, Cellular automata, Poisson disk, Wave function collapse
What we asked“Make a web page that demonstrates the procedural generation techniques one at a time, so anyone can see and feel each one within a few seconds. For each one, show the same short moment side by side: without it on the left, with it on the right, playing in a loop, with a caption that says what just happened and a replay button. Where it helps, let me play the moment myself. It will sit inside a blog post about 720 pixels wide, so it has to look good at that width and on a phone. Also make each one viewable alone with ?trick=<id>&solo, using these ids: noise, room-grid, cellular-automata, poisson-disk, wave-function-collapse. On the left show plain random generation of the same thing, and let me press a button to generate a new seed on both sides.”

What happened

  • Loaded the procgen skill
  • Wrote the five generators so each takes a seed and one on/off switch, so both sides run the same code
  • Wrote a check that generates 1,000 fixed seeds per technique and tests every result independently
Claude
Noise only reaches 53%: steep slopes sometimes skip the narrow sand band in one step. I'll tune the scale and bands against the measurement rather than relax the test.
  • Made every height band wider than the largest step between neighbouring tiles, then re-ran it at 1,000 and at 5,000 seeds
  • Built the page with Replay and New seed, and starting seeds that show each side's usual failure
  • Let you fly over the terrain, explore the room grid, pour water into the caves and plant trees
Claude
Every technique is now 100% playable at 1,000 seeds. Plain random managed 0% for four of them, and 4% for the room grid.

Pure randomness doesn’t give you worlds. It gives you static: speckled terrain, levels you can’t finish, trees in clumps. Games that generate their worlds use techniques that add structure to the randomness. Each demo below shows plain random on the left and the technique on the right, with the same seed, and checks the result. Under each one is how often it produced something playable across 1,000 seeds. New seed rolls both sides again.

1. Noise, for terrain

A random height per tile gives speckle. Smooth noise gives hills, coasts and valleys, especially when you add a few layers at different scales. Ken Perlin developed Perlin noise in the early 1980s, after working on the film Tron, and won a technical Academy Award for it in 1997 (Wikipedia). In our test, no noise map ever jumped two height bands between neighbours; random maps had about 5,000 such cliffs each. Drag to fly around.

2. A room grid with a guaranteed path, for levels

Spelunky builds each level from a 4x4 grid of rooms. It first walks a path from a start room in the top row down to the exit, then fills the rooms on that path with templates that have the right openings, and the rest with anything (Darius Kazemi’s Spelunky Generator Lessons). Our version is top-down, so you can explore it with four directions. With random rooms, the exit was reachable in only 25% of levels, and every room in 4%. With the path, 100%.

3. Cellular automata, for caves

Start with random walls, then repeat a simple rule a few times: a cell becomes wall if most of its neighbours are walls. Noise turns into smooth caves (RogueBasin). Then fill any pockets that aren’t connected to the main cave. Random walls never gave one connected cave in our test; this did every time. Tap to pour water.

4. Poisson-disk sampling, for scattering things

Placing trees, rocks or loot at random makes clumps and gaps. Poisson-disk sampling still places them randomly, but rejects any point too close to an existing one, so they spread evenly without looking like a grid. Robert Bridson’s 2007 paper made it fast (PDF). Every random map had overlapping trees; none of the Poisson maps did. Tap to plant a tree on both sides.

5. Wave function collapse, for tile maps

Give each tile rules about what may sit next to it, then repeatedly place the tile with the fewest options left and pass the rules on to its neighbours. Maxim Gumin published it in 2016, building on Paul Merrell’s model synthesis, and Bad North, Townscaper and Caves of Qud used versions of it (Wikipedia). Random tiles averaged about 119 broken edges per map; wave function collapse had none, with at most 9 restarts.

Always test with seeds

Two rules matter as much as any technique:

  • Use a seed for everything. Then any level can be reproduced, shared and debugged.
  • Measure, don’t eyeball. A generator that looks fine ten times can still break one level in a hundred. Our noise passed only 53% of the time until the test caught it. The skill’s last step generates 1,000 levels and checks every one.

Add it to your game

  1. Copy the skill at the end of this page into your project.
  2. Ask your agent: “Generate my levels procedurally, and make sure every one is playable.”
  3. Check its report: playable should be 100%.

The skill that made it work

This is the whole skill we gave Claude Code. Copy it into your project and ask your agent to generate your levels or maps. The last step makes it check 1,000 results instead of trusting a few.

procgen
  1. Find what the game generates: terrain, levels, rooms, caves, scattered objects, tiles. Note the size and what makes a result playable.
  2. Put every technique behind one named switch in a single settings object, all on by default, so each can be compared with plain random.
  3. noise. For terrain, height and textures, use smooth noise (Perlin or simplex), adding a few layers (octaves) at different scales, instead of a random value per tile. Ken Perlin created Perlin noise in the early 1980s and won a technical Academy Award for it in 1997.
  4. room-grid. For levels, lay rooms on a small grid (Spelunky uses 4x4), first walk a guaranteed path from the start in the top row to the exit in the bottom row, then fill the rooms on the path with templates that have the right exits, and the rest with anything.
  5. cellular-automata. For caves, start with random walls, then repeat a few times: a cell becomes wall if most of its neighbours are walls. Then keep only the largest connected cave.
  6. poisson-disk. For scattering trees, rocks, enemies or loot, place points at random but reject any closer than a minimum distance to an existing one, so they spread evenly without looking like a grid.
  7. wave-function-collapse. For tile maps, give each tile rules about which tiles may sit next to it, then repeatedly place the most constrained tile and spread the rules, so the whole map follows them. Bad North, Townscaper and Caves of Qud used variants of it.
  8. Always use a seed, so any result can be reproduced and shared.
  9. Measure it. Generate at least 1,000 results per technique with fixed seeds. Report how many are playable (start can reach exit, no unreachable areas, nothing overlapping), and for scattering the smallest distance between objects. Playable should be 100%.

Save it as .claude/skills/procgen/SKILL.md in your project. Or connect your agent and type /aigamedev: it loads this skill with its reference files and the results from this post.