Search code examples
python2dprocedural-generation

Perlin worms for 2D cave generation


I've been trying to make a 2D Minecraft-like game. I'm to the point where I've done the terrain generation, but I want to do cave generation now. I've experimented with Perlin noise, but found that the best I could get to were long connecting caves that never have dead ends. I then found out about perlin worms and realized it would be able to generate worm like caves.

I tried to do research on perlin worms, but there barely seems to be anything on it. Could you make a perlin worm function from a perlin noise function? If so, can you make it so that you could input a coordinate pair and it would return a value for that position like perlin noise functions?

Thanks in advance. All I need are ideas :)


Solution

  • Perlin worms can be created from Perlin noise or any other noise by just considering if the terrain is in a narrow range around the middle value of the terrain.

    It is kind of hard to explain, so I've created a visual representation for how you transform a noise into worms.

    Original Noise (value noise)

    Noise

    Transformed to Worms

    Worms