The rooms / layout are pre-made, but they are connected randomly. So the game would have to know which rooms have doors on their left, right, top or bottom and which don't, place a room next to it that fits that criteria, and do it again until finished. It would also have to remember the the order, so they player can back track, and possibly create a mini-map of the floor plan.