Click that "generate" button to create caves to your heart's content! Tweaking the settings can be fun too.

Not sure what I'll use this for yet. I was just in the mood to make some caves, and PROCJAM came along at a convenient time. It wouldn't surprise me if this exact combination of algorithms has been used before, but I learned a lot while building this, so I feel like it was a success.

The code is available on codesandbox.

Methodology & credits:

  1. Plot random points
  2. Get Delaunay triangles of those points using mapbox's delaunator
  3. Use the centroids of the Delaunay triangles to map the cells, instead of traditional Voronoi mapping
  4. Randomly assign each cell to either "wall" or "path" proportionally (approximately) according to the setting
  5. Combine path cells to create path shapes
  6. Smooth shapes using Chaikin’s Algorithm

Packages used

References used


Log in with to leave a comment.

Thanks for the clear explanation of the process!

Now, we are ready for a game of worms!

Loving the results! Would be cool in a simple lunar lander type game.

Good explanation of the algorithm. The "extra info" setting really helped me understand how the caves were generated. Seeing the SVG code is also nice.