The dungeon generates rooms, corridors, floors, and then populates them with collectibles (coins, keys, doors) and enemies. Rooms are positioned randomly within bounds, with collision checks to prevent overlaps. Corridors connect room centres horizontally or vertically, maintaining uniform width. Keys always generate in the last room, while the player spawns in the first. Each playthrough produces a different layout, ensuring replayability.
