#2665

 · 
vanilla

Rather than occurring entirely randomly, a secret passage can only generate to close off a dead end, where exactly 2 of the 4 adjacent squares, on opposite sides, are corridors, and the other 2 are rock. The dead end criterion is tested by trying to pathfind an alternate route from one of the adjacent corridor spaces to the other; if none can be found, this space must be blocking a dead end, so it is valid.