#Basic Procedural Random Dungeon Generation
- Create one set holding used rooms.
- Create one set holding open ends.
- Place a random room, add it two both sets and flag it as the entrance.
- Repeat as long as you don't have your intended number of rooms:
- Randomly pick a used room ("current room").
- Pick a random direction.
- If the chosen direction is the border of the map, continue the loop.
- Remove the current room from the open ends.
- If there's no room in the target direction, add a new room.
- Add the new room to the open ends.
- Add the new room to the used rooms.
- Decide randomly whether the new room contains a hidden key. If it does, add one key to the available keys.
- Connect both rooms using a door.
- Decide randomly whether the door is locked (if keys are available).
- If it's locked, remove one available key again.
- Pick a random open end and make it a boss room and remove it from open ends.
- Pick a random open end and make it a treasure room and remove it from open ends.
- Pick a random open end and make it a shop and remove it from open ends.
- To make the dungeon more random, iterate over all remaining open ends:
- Decide randomly whether you add another connection to a nearby normal room or do nothing.
- Other key items or tools allowing you to pass some area as well as obstacles can be added the same way.