The Concept
Perlin Noise generates smooth, continuous random values. By setting a "threshold" (water level), we can decide which parts are walls and which are floors.
Marching Squares: To make the walls smooth instead of blocky, we interpolate between the grid points to draw angled lines.
0.45
Core Logic
// Get noise value at (x, y)
let val = noise.perlin2(x * scale, y * scale);
// Check threshold
if (val > threshold) {
drawWall(x, y);
} else {
drawFloor(x, y);
}