x and y are the ground coordinates of the centre of the map,
marked by a small red cross.
z is depth, from 1 at the highest layer.
Even z values are for connection layers (up/down tunnels).
The values of z and scale cannot be less than 1.
(The RUN button should not be necessary; just enter values
to redraw the map.)
A white or coloured cell means a cave is open at this point.
Blue means the layer above is also open, so there is an
Pink means the layer below is open, for a downward tunnel.
Green means both layers above and below are open.
Some caves are unreachable but that hardly matters.
Right-click and view source to see how it is done.
The very small function isCaveOpen() does all the work,
exploring a function of the player's position (x, y, z).
I wrote about the technique in "Practical Computing" (UK)
in 1982, when using it in the first version of The Forest
(the current version is at myforest.uk).