← Back to Hub

Random Walk (Drunkard's Walk)

The Concept

The Drunkard's Walk algorithm starts at a random point and "walks" in random cardinal directions (North, South, East, West). Each step carves out a floor tile. This process repeats until a certain percentage of the map is filled.

It's great for organic, winding cave systems.

Floor Fill: 0%

Core Logic


// Simple move logic
const directions = [[0, 1], [0, -1], [1, 0], [-1, 0]];
const dir = directions[Math.floor(Math.random() * 4)];
x += dir[0];
y += dir[1];
grid[x][y] = 1; // Mark as floor