Hello! So… basicly, in my game, there’s Dungeons, each dungeons as a quantity of floors, i want the floors to be random and auto-generated, but i don’t know how to make it… The Floor should have some rooms and halls connecting each room with another, any help?
Another approach other than @EnvisionDev’s solution (a totally valid one, by the way) is to use a procedural algorithm such as WFC to generate floors. This does require you to design assets but can result in a lot of variety.
There are some pros and cons for both approaches, but they’re both good approaches. If you are purely wanting a room/hallway configuration, the above post is a good resource
I’d start by defining a clear set of rules before trying to implement any algorithms. For example:
Are all rooms some type of rectangle?
Is there a size/amount limit for rooms?
Are paths only rectangle-like with 90 degree corners?
Are the paths always the shortest possible or they might contain unnecessary loops?
Is it possible for a path to lead to a dead end?
Can rooms exist if they’re not accessible?
etc
By having a clearly defined ruleset of how your game will generate floors/maps it will be much easier to figure out an algorithm or implement an already existing one.
If I was you I would also try to separate out exactly which part of the problem I consider dynamic and which known/static.
Personally I would use a node system with a random function. Now hear me out. Perlin noise is nice for generating values that are smooth, but pure psuedo random is nice when you dont want like 50 hallways in a row.
Basically have building nodes, that have connector nodes. Connector nodes only connect to other corresponding nodes of choice. This can be designated using numbers. Like node 1 can pair with node 16/17. Anyways, The random generator function will select a node to begin attaching to the first available node. The process is repeated and recursively expanded in a tree format.
I would like to try and make this but I already know someone will solve this before I can even make it.
There is wave collapse function, not sure if its implemented in lua yet. But there are a lot of youtube videos on that.
Edit: I saw you wanted inter-connected rooms, my idea might be obsolete.