Random room generation assistance

Hello everyone. I am here to ask for help on where to start with a random map generator using preset tiles.

The current things stopping me, is figuring out a good way to decide what tiles to use. Currently all the tiles are the same size but I would like to allow for abnormally sized tiles, even if they have to fall in line with a certain number.

For example, the current tiles are 25 by 25, and I would like to account for having rooms in multiples of that size like 50 by 50, 25 by 50, 100 by 100 and so on.

My goal is also to allow the generation of 2 staircases per floor which brings the another problem to mind that is making sure the floor as a whole is not separated into 2 different “wings”

The current way I was going about things had each room detecting if it was colliding with other rooms and then continuing to clone rooms and while this worked to some degree I would still have the issue of floors being separated into “wings” as stated above, as well as some trouble on when to generate staircases/bigger rooms.

Any help would be appreciated, thank you!

I would probably use some kind of connector system.
So every room would have 1 or more connectors that will be used to place the new room.
This way you can have rooms of various sizes because you will place the connector relative to the room.

You would use the same method for placing staircases by having connections in the room and the staircase and place them relative to each other.

When placing a new room you would set the connector as primary part and use PivotTo to move the model to the position of the previous rooms connector. If multiple connectors then you could randomize which to use.

That is the system I am currently using, my main concern right now is the staircases. As I want there to be at least 2 per floor, but don’t want the floors to branch into wings and be separate from one another but am unsure of how I would solve that problem.

I have a hard time visualizing what it is you are trying to achieve.
Where are the staircases going and why can’t you prevent them from branching of?

So currently as it stands, my system starts on the edge of a barrier.

Each room can have anywhere from 1 to 3 “Pathways” which are my “Connectors”

I currently cycle through my rooms, and use some parts are detectors to tell whether or not the room is suitable and make sure its not generating in on itself.

The amount of rooms is scaled down just for example but it will generate a floor and 2 of these generated rooms will be staircases.

Once this floor is finished it starts working on the next floor, but since my previous method used only 1 starting place, I am not really sure about how to make this next floor whole since my current method of allowing and placing rooms has been reliant on detecting that its not going to go in on itself and making a room.

Hope the images help capture what I’m trying to accomplish.

Perhaps you could keep track of what direction the generation is “traveling”.

So, first room can be placed in directions/connectors “Forward, Left, Right”.
If the room is placed on the Right connector then the next valid directions is to continue right or turn left. Right would not be valid since that would make the rooms go back on itself.
If the next room is placed on the Left connector then again the directions “Forward, left, right” would be valid again, and so on.

This would make sure that the rooms are always traveling “forward” and never going back on itself.
The second floors would make use of the same method.

This is the only method I can think of that is not to complex to solve.

So I guess it could be something to detect which “direction” is open and then calculate which turns would be needed to make sure the pathways connect correctly?

I guess its something I will have to experiment with, I appreciate the help.

Every room could have 4 connectors. BACK, FORWARD, LEFT, RIGHT.
When placing a new room you always use the BACK connector to place the new room.

You start by setting DIRECTION = ‘FORWARD’

You have a table with valid directions depending on current direction. So with FORWARD the valid directions would be LEFT, RIGHT, FORWARD.

You pick a random direction, and if LEFT. Then the new valid directions would be RIGHT, FORWARD. So “forward” in this example would actually be to continue in “Left” direction but it would be “Forward” relatively to the last placed room. Hope that makes sence.

Yes it makes sense, i’m now just thinking of how to implement it as a whole now.

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