Caves are exiting. You do not know what lies next. It could be that motherload you have been tracking for hours, it could be a band of nasty creatures.
Caves are also beautiful and interesting. I like it when caves surface and create openings in the face of mountains, or when a large portion of ground has collapsed and you can see part of the cave's profile like a giant ant farm.
Over the past few weeks I did many attempts on creating a good cave system. It is a lot more difficult than it seems, especially if you want to generate them in real time.
I tried different solutions until I hit what I thought it was the winning formula. The key wast think of the cave system more like a dungeon in a castle, pretty much like roguelikes do in ASCII. You end up with a system of narrow tunnels that connect in meaningful ways and often lead to large interior spaces. It is then possible to give an interesting rhythm to the system. You can count on the system to reward the explorer with awesome crypts after enough tunnels have been explored.
Another challenge was to create the connections between the caves and the surface. I wanted caves to be fun and beautiful, and actually help you get around the world. For instance they often serve as shortcuts below mountains.
I also had to pay close attention on how the caves played with the rest of the terrain. If you had all the time in the world this would be hardly a problem. To generate this on-the-fly and make sure there are no odd floating bits, it is kind of tricky.
I leave you with a series of screenshots showing some caves I have encountered in my travels. At the end you will find a wireframe video that shows the profile of a cave system. I hope you like them.
Here is the video: