Generate caves that look natural and still leave every tunnel reachable
Scattering stone at random and smoothing it gives pleasing caves, but also sealed pockets the player can never enter, with ore inside. Here is the smoothing rule, why it has to change all cells at once, and the final step that fixes the pockets.
Why this works
Smoothing makes each cell follow the majority around it, so random speckle turns into rounded chambers and tunnels. But smoothing alone leaves cut-off pockets, and anything placed there is lost. Keeping one connected area means every part of the cave can be reached.
When not to use it
Wrong when you want straight, designed rooms, a maze, or a story level with a fixed layout, as the result always looks organic. It also wastes sealed pockets that could be secret rooms. Build those by hand or connect them with a tunnel.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- A diagram of every state
- 52 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Generate caves that look natural and still leave every tunnel reachable" (read_entry survival-cave-one-connected-system) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP