Im currently having an issue with a dungeon generator. While everything generates like it should, its very common for the amount of rooms to not be accurate to what it actually should be.
Things like this happen pretty frequently:
Even if the dead-end sections are removed, this can still happen:
How can I stop this from happening?
Place file: dungeon.rbxl (34.8 KB)
(100 rooms are supposed to generatem if everything generates correctly, “done” should be printed and all the green and red parts would get destroyed)
2 Likes
Thanks for providing the place file - I had some fun with it!
I noticed a couple of things.
- It will always start with End1, and fill as many rooms as it can - sometimes up to the limit.
- Sometimes, all 4 ends circle back on themselves or into other rooms; and cannot generate 100 rooms total.
The first part could be intended behavior.
The 2nd part, is a bit trickier to solve…
You may have to index the pathways and their rooms, in order to leverage better procedures.
1 Like
Dead ends and rooms that don’t fit their neighbors are inevitable if you just pick a random room every time. You’ll need some way of forcing a specific door of a room to become open, e.g. if you have a straight corridor but something connects from the side, you need to replace the straight corridor with a T intersection. Likewise, if you’ve generated 20 rooms but there are no unconnected doors left, you need to force new doors to be added to some of the rooms that have empty neighbors.
You could also go with a completely different approach. Instead of fixing levels that generate incorrectly, you could go with an algorithm that only generates correct levels. You might want to look into maze generation algorithms for this, or just look up some online tutorials, there are plenty that are not Roblox specific.