What's the best way to make random room generation?

I’m trying to make a randomly generated map and I seem to only find tutorials that involve a single large forward’s path, and they don’t seem to ever include rooms that can go 3 different ways for example.
Does anyone know how to? I’m trying to replicate the way maps are made similar to SCP:CB.

4 Likes

Make room models inside ServerStorage, use math.random to get random room, clone the room, set the cloned room’s Parent to workspace, set its position to your desired position.

2 Likes

There’s a good chance that the buildings will overlap

1 Like

Maybe make a hitbox for each room and use GetPartsInPart to check if the 2 hitboxes overlaps.

1 Like

As I am working with this type of system myself, I recommend doing Hitboxes for the maps so they don’t overlap, and also make a room chance (common rooms have a higher chance of spawning). I also suggest using 2 DoorPositions so that the rooms can generate and not look the same, aswell as furniture spawns. This is a system that the game DOORS uses, however I don’t know how the SCP:CB system works, as I never played the game.

1 Like

For example, if you go into a room that has 4 ways (Infront, your left, your right, and the door you just walked through to get into the room) all those doors have individual rooms which can have the same thing (I will add a limit but that’s separate) and the main issue I only have is overlapping. While yes, the “check for overlapping” is smart, I tried this earlier today and it always resulted in exhausting as there’s no possible replacement.

1 Like

Make your rooms so they tile nicely like having all rooms fit in a square grid or having lots of small-ish shapes. Or find some way to deal with it, for example by automatically removing the opening and just not having a room behind a door, or perhaps rooms that can be made bigger or smaller to fit in different spaces.

You could also go down a different route and no rely on authored rooms, i.e. also generating the shape of the rooms.

1 Like

Apologies for the bump but funnily enough if you look into SCP:CB’s source code anything is possible.

This is all on a grid system like CB, just look at mapgen, scroll all the way down, angles are a pain in the bum.

1 Like

Sorry, for the late reply.

Is this meaning that the source code for map gen is available? where could I find it?

Github, SCP:CB’s source is FULLY open.

Personally I wouldn’t dare run it through chatgpt because as ‘good’ as it is you need to learn this on your own, learn 2d grids and allat, maybe start out how I did coding random maze’s with 2d grids.

2 Likes

(sorry for bump)

How did you figure out the angles for the room placement? I’ve got the mapgen working fully, most of the rooms are just rotated incorrectly.

I was wondering if you would be able to share the angles you used, or tell me how you figured it out, because honestly I’m lost. Thanks in advance!

1 Like

My angles are DEFINITELY different as you have to make sure every room type leads in the same dir.
ie.
EVERY ROOM1 TYPE END DOOR IS FACING THE SAME WAY
EVERY ROOM2 TYPE has the same doors
EVERY ROOM3 IS THE RIGHT one
so on and so fourth, room4 is not needed. (less u wanna)

Just play around, I recommend doing what I did and just running the game looking for abnormalities each run and then grabbing a ss, annotating and adjusting your code. :smiley: hope this helped