By Mark Damon Hughes [email protected]
The original Rogue algorithm is pretty nifty. Any time you need a random dungeon, give this a try:
- Divide the map into a grid (Rogue uses 3x3, but any size will work).
- Give each grid a flag indicating if it's "connected" or not, and an array of which grid numbers it's connected to.
- Pick a random room to start with, and mark it "connected".
- While there are unconnected neighbor rooms, connect to one of them, make that the current room, mark it "connected", and repeat.
- While there are unconnected rooms, try to connect them to a random connected neighbor (if a room has no connected neighbors yet, just keep cycling, you'll fill out to it eventually).
- All rooms are now connected at least once.