Roguelike: Drunkard's Walk
Generate organic cave maps with a random walker algorithm — set a starting position, pick random directions, and carve floor tiles until you hit a coverage target.
No login required.
The Walker
A drunkard's walk starts at the center of the map and stumbles outward, carving floor tiles as it goes. You'll place the walker, set up the loop, pick random directions, and carve tiles.
Random walkers are the simplest procedural generation algorithm -- they produce organic, cave-like shapes with zero configuration.
Loading game...
Click the game window to interact with it
What You'll Build
You will implement a drunkard's walk algorithm that carves organic cave maps. A walker starts at the center, picks a random cardinal direction each step, and marks the tile as floor. The process repeats until a target percentage of the grid is carved. The result is a natural-looking cave with winding passages.
Learning Goals
- ✓Random walker algorithm with direction arrays
- ✓While loop with a coverage target exit condition
- ✓Grid boundary clamping to keep the walker in bounds
- ✓Counting carved tiles to calculate floor coverage percentage
GDScript Concepts in This Part
Tips
- ✨Define directions as a constant array [Vector2i.UP, DOWN, LEFT, RIGHT] and pick with rng.randi() % 4 for clean random walks.
- ✨Start with a 40-50% coverage target — too low creates sparse caves, too high fills the entire grid.