A fallback connectUnreachableItems() function detects any key, orb, potion, or exit that isn’t reachable from the player start. It performs a BFS from the unreachable item to the nearest reachable floor tile and carves a direct tunnel, ensuring every important element is accessible. Robustness The game still attempts up to 50 random generations for a natural‑looking map.