Cave Map Generator
Start with random noise, then repeatedly make every cell match whatever most of its neighbours are. Four passes of that turns static into something convincingly cave-shaped — and reliably leaves sealed-off pockets, which is the part most implementations quietly ship. Here the separate regions are found and joined by carving corridors, and the finished map is flood-filled to confirm every open cell can reach every other.
What this generator does
Fills a grid with noise, smooths it so each cell matches the majority of its eight neighbours, then finds every separate open region and carves corridors joining them to the largest. The border is kept solid so the cave never runs off the edge.
How to use this tool
- Choose the map size and how much of the noise starts as rock.
- Set how many smoothing passes to apply.
- Read how many separate pockets smoothing left behind.
- Copy the map as text for a virtual tabletop or a game.
Understanding the controls
- Map size
- Between 12 and 48 cells across. Smaller maps erode faster under smoothing, which the generator compensates for.
- Starting wall (%)
- How much of the initial noise is rock. Around 45% gives the most cave-like result; much higher and smoothing closes everything in.
- Smoothing passes
- Between 0 and 8. Zero leaves raw noise; four is the usual choice. If smoothing would erase the cave entirely the generator backs off a pass at a time and says so.
- Seed
- Reproduces exactly the same cave, which matters when a map is being used in an actual game.
Common use cases
- Cave levels for a tabletop or video game that are guaranteed walkable
- Showing what cellular-automata smoothing does to noise
- Battle maps with organic rather than rectangular shapes
- Test data for a pathfinding implementation
- Reproducing the same cave from a seed
How this generator works
Smoothing counts the eight neighbours and treats off-grid as rock, which is what keeps the cave inside its border. Connectivity is then enforced rather than hoped for: separate regions are flood-filled, their centres computed, and straight corridors carved between them. The check flood-fills the finished map and requires the reachable count to equal the open count exactly.
Randomness and fairness
The initial noise is random; the smoothing and the joining are deterministic. Seeded caves reproduce exactly and are therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator fills the noise.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Corridors are carved as straight lines, which look more deliberate than the cave around them.
- One cave per map — no levels, stairs or multi-floor structure.
- Cells are plain open or solid, with no doors, water or terrain types.
- Maps are square and stop at 48 cells across.
- Maps are not stored between visits; seed one you want to reuse.
Privacy and your data
The map is generated entirely in your browser. Nothing about it or your seed is transmitted or stored.
Related generators
- Dungeon Layout GeneratorRoom-and-corridor dungeons built by binary space partitioning, where connectivity is structural rather than checked afterwards.
- Maze GeneratorPrint a maze with exactly one route from start to finish — three textures from long corridors to short dead ends, any size up to 40 by 40.
- Terrain Heightmap GeneratorSmoothly interpolated value-noise height fields with a movable water line, and continuity checked rather than assumed.
- Game of Life Pattern GeneratorRandom Life soups run until they settle, reporting whether they died, froze, or fell into a cycle — and the exact period.