How to generate room in 4 direcions?

You can write your topic however you want, but you need to answer these questions:

Hi, i am trying to make a room generator where there is a base room, and 4 exits, and once the script starts running, generate in 4 different ways, still connecting throughout . But i just can’t seem to figure out how. I’ve tried looking for tutorials on how to do it but none of them are specifically what im looking for. if somebody could help that would be great. (Picture down below)

anything helps!

5 Likes

The specific design relies on your specific constraints. Are they all the same size? Do you want loops? How big is it?

A simple algorithm (though very slow with a pure luck based implementation [which is how I technically describe it]) is to simply generate a grid. Then create a random walker which keeps randomly picking a new cell to go into. If it’s a cell you haven’t visited yet, then create a door from the cell it left to the new room. Once or has visited all of the rooms, or the amount of rooms you wished it to, then you end it there and every room will be connected to the start. And of course there are aillion and a half variations on that idea.

You could also generate a lot of random rooms, and separate the shapes so they no longer overlap, then create paths between these rooms based on a simple pathfinding algorithm. This is what I do in one of my projects.