Discuss Scratch

Cyn-bolute_Solver
Scratcher
3 posts

Randomly Generating Rooms

I want randomly generating rooms but I want them to connect to each other, but I don´t want it to look like a maze either.

Anybody know some code that could help?
HighlaneGamingStudio
Scratcher
100+ posts

Randomly Generating Rooms

Try using rooms that have the same format. For example, you could make square rooms where all of the doors could be in the middle of the walls on all four sides. That way, you can guarantee that all rooms will connect to each other.

If you find that the method above creates an area that looks like a maze, you could make prefab floor plans instead of having every room randomly generate (for example, putting every room on one costume.)

Last edited by HighlaneGamingStudio (Feb. 20, 2025 17:12:16)

Whitepatchwastaken
Scratcher
100+ posts

Randomly Generating Rooms

Could you be a little more specific? Do you want the rooms to be like a snaking path? Do you want an interconnected loop? Do you want a traditional dungeon generator that doesn't make dead ends?
HighlaneGamingStudio
Scratcher
100+ posts

Randomly Generating Rooms

Whitepatchwastaken wrote:

Could you be a little more specific? Do you want the rooms to be like a snaking path? Do you want an interconnected loop? Do you want a traditional dungeon generator that doesn't make dead ends?
Cyn-bolute_Solver said they didn't want the rooms to look like a maze. I presume they don't want a snaking path.
Whitepatchwastaken
Scratcher
100+ posts

Randomly Generating Rooms

HighlaneGamingStudio wrote:

Whitepatchwastaken wrote:

Could you be a little more specific? Do you want the rooms to be like a snaking path? Do you want an interconnected loop? Do you want a traditional dungeon generator that doesn't make dead ends?
Cyn-bolute_Solver said they didn't want the rooms to look like a maze. I presume they don't want a snaking path.
Well, a snaking path isn't exactly a maze. I guess what I should've said is that it'd help if we had more info on what exactly they wanted.
Right now all we know is:
  • the rooms should randomly generate (duh, that's the name of the topic)
  • they should be interconnected (still fairly obvious, ambiguous if you overthink it though)
  • it should NOT look like a maze (then what should it look like?)
Cyn-bolute_Solver
Scratcher
3 posts

Randomly Generating Rooms

Snaking is fine and dungeon could be what Im looking for.

The idea im thinking of is
1. Generate start room
2. When I open the door to the next room, a room with a door connected to the door I just opened, spawns.
and that every time I open a door, maybe with set room spawns for halfway and at the end and maybe at the start
Whitepatchwastaken
Scratcher
100+ posts

Randomly Generating Rooms

Cyn-bolute_Solver wrote:

Snaking is fine and dungeon could be what Im looking for.

The idea im thinking of is
1. Generate start room
2. When I open the door to the next room, a room with a door connected to the door I just opened, spawns.
and that every time I open a door, maybe with set room spawns for halfway and at the end and maybe at the start
I think I understand what you're starting to get at here. The image in my mind I'm getting is kinda like Roblox DOORS (feel free to call me cringe) where every room has exactly one entrance and exit, and isn't on a grid. I could try to program something like that, though it probably already exists.

Last edited by Whitepatchwastaken (Feb. 20, 2025 18:59:30)

bsteichman
Scratcher
500+ posts

Randomly Generating Rooms

what do you want these rooms to look like? what would be in them, and would you want to make the rooms on the fly or at game start.


one of the earliest randomly generated dungeon crawlers divided up the screen into 9 sections of tiles, then drew a rectangle on each section, with 1 entrance and exit each, then connected them in order of distance from the start point
Cyn-bolute_Solver
Scratcher
3 posts

Randomly Generating Rooms

Whitepatchwastaken wrote:

Cyn-bolute_Solver wrote:

Snaking is fine and dungeon could be what Im looking for.

The idea im thinking of is
1. Generate start room
2. When I open the door to the next room, a room with a door connected to the door I just opened, spawns.
and that every time I open a door, maybe with set room spawns for halfway and at the end and maybe at the start
I think I understand what you're starting to get at here. The image in my mind I'm getting is kinda like Roblox DOORS (feel free to call me cringe) where every room has exactly one entrance and exit, and isn't on a grid. I could try to program something like that, though it probably already exists.


I think thats sorta what Im going for
ItBeJC
Scratcher
1000+ posts

Randomly Generating Rooms

Whitepatchwastaken wrote:

Cyn-bolute_Solver wrote:

Snaking is fine and dungeon could be what Im looking for.

The idea im thinking of is
1. Generate start room
2. When I open the door to the next room, a room with a door connected to the door I just opened, spawns.
and that every time I open a door, maybe with set room spawns for halfway and at the end and maybe at the start
I think I understand what you're starting to get at here. The image in my mind I'm getting is kinda like Roblox DOORS (feel free to call me cringe) where every room has exactly one entrance and exit, and isn't on a grid. I could try to program something like that, though it probably already exists.
Noodle On!

I believe that makes room generation much easier, especially since games like DOORS often have a general set of room types that can be slightly modified at random. For example, dupe rooms (for those who don't know, that's basically when you're trying to go through the correct door but there's a “dupe” door or fake door that will damage you if you enter it) and how they can randomly be put in a set room type.

You can even see it in the new DOORS update-notice how when spectating the player can see the name the game has given the room that the player is currently in, such as “main hallway” or something like “large room.” Notice how these names are things that can be added to-maybe the main hallway has a random number of drawers (DOORS uses things like drawers & tables). Or the large room could have a random number of slightly randomized miniature rooms inside of it (again, like DOORS).

All that to say, I think that formatting your game like that may be useful because it allows you to implement the generation easier-
the basic concept is to make some premade costumes (such as the main hallway and large room ideas mentioned above) and then some premade subroom costumes and have the game randomly combine them.

In all honesty all I wanted to say was “Noodle On” but that technically doesn't contribute anything to the problem so I had to make something up.
Koamodo975
Scratcher
1000+ posts

Randomly Generating Rooms

Okay I'm tryna do something like this myself; here's the basics(in theory):
-when you enter the door, you either
–(if the rooms are a uniform shape and can't be rotated) check to see what rooms you have that can fit the doorway; i.e., you go thru a doorway to the right, use a room with a left doorway
–(if the above isn't true) find a room that'll fit with the space beyond the door.
-then, if you're doing the first option, just snap the room with the door and yer done.
-the second option is a bit more complicated; I'm no pro but I think what you would do is snap one of the doors on the room to the door you're entering; if it doesn't fit(touching another room or blocking doors) it snaps the next door, then the next and the next until you've run out of doors to snap on that room. If it STILL doesn't fit, try the next room.
-once you find a room that fits, generate it permanently and let the player through.

Again this is in theory, I dunno if it'll actually work. If it does, lemme know; I might be able to get a few pointers for my own thing.
I also gotta say it now so Noodle On!

Powered by DjangoBB