This Random Cave Generator creates sprawling, intricate dungeons or caverns stored in a ds_grid, which allows a level to easily be generated from it. Changing the parameters can wildly alter the generation, creating cave systems of numerous shapes and sizes with no disconnected areas or islands to worry about.
Also included is an intelligent water creation script, which adds water at any coordinate, sensibly filling up the caverns below using a special algorithm which is guaranteed to perfectly will the map without any strange holes or air pockets that would not occur in real life (and are seen all too often in other games!).
The code is fully commented and easy to follow.