Help creating Auto-Generated Floors

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?

Here what i want to do:

Btw, is that the right category?

3 Likes
3 Likes

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:

  1. Are all rooms some type of rectangle?
  2. Is there a size/amount limit for rooms?
  3. Are paths only rectangle-like with 90 degree corners?
  4. Are the paths always the shortest possible or they might contain unnecessary loops?
  5. Is it possible for a path to lead to a dead end?
  6. Can rooms exist if they’re not accessible?
  7. 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.

  1. Yes
  2. Also yes
  3. Yep
  4. Definitely
  5. Yea
  6. No
    But i think @EnvisionDev tutorial is perfect, i just need to execute and see if it works, that’s why it’s not the solution yet.

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.

Edit 2: https://www.youtube.com/watch?v=rBY2Dzej03A&t=519s

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.