Procedural Generation (Using Predefined Pieces)

Hello! I’m looking to do something involving Procedural Generation, primarily ‘tile dungeons’ of various types. I’m planning to use a sort of templating method for this. Basically, I would define a set of ‘masking’ templates that would indicate whether a tile is a wall, a floor, or a door (The interiors of rooms would be filled in using a different algorithm such that while you might have a lot of rooms of the same shape, you’d have ‘different’ rooms). The algorithm would be something like:

  1. Select a starting room and position.
  2. Place the room on the map. (Remove any ‘open’ doors that have just become closed.)
  3. Add all of it’s ‘open’ doors (Meaning doors that haven’t had a room attached to them) to a list.
  4. Check ‘open’ doors size > 0
    4.1) true: Select a room that can be attached to it. Then go to 2.
    4.2) false: Check if certain gen requirements are met (Number of rooms, tile coverage, whether certain required rooms were placed, etc.)
    4.2.1) true: Gen complete.
    4.2.2) false: Backtrack and to last room addition and attempt to add a different room.

Anyway, I’m trying to figure out an efficient way of doing this. Beyond writing up all of the different room types, there’s an issue that crops up when I attempt to add in doors of variable thickness: Like an opening into a hallway that is two tiles (Or if I can extend this to three dimensions two wide and several high). Any ideas/advice would be appreciated!