Backrooms type generated map. How?

What would be the best way to approach this?
Judging by pictures of the backrooms, they seem quite random and have a ton of variety that would be hard with just a simple dungeon generator. So how would I achieve getting random wall height, elevating ground levels, angled halls, areas with no light, big open wall-less areas? That’s really all I wanna know. I’m not asking for straight code like some aimless child, but more just some insight from someone more experienced in this field. How can I make a building floor generator that follows zero rules, goes crazy and generates, but doesn’t overlap its halls and such. Last time I attempted this I found myself unable to progress any farther many many times. My second attempt was too tile-based and was extremely boring.

My main goal is to simply understand how I can do this, so that me and other people on the same page can get a head start.

SOME REFERENCES





image

Thanks in advanced,
ZonKe.

6 Likes

I’m by no means experienced in scripting something like this, but do you think math.random() would be useful here? How much of the room are you trying to generate? I’m unsure if you’re trying to make entire rooms or just walls, ceiling heights, lighting, or decoration.

Well of course, randomization is the entirety of random generation. I’m more specifically wondering how I can just randomize rooms and not have them overlap one another. Not having halls overlap one another means I can generate quite literally anything and it would fit.

3 Likes

I think taking a look at this module might help Dungeonify - Large templated structure generator with quotas and restrictions

You can make pre-made rooms and then the module can help you put it together.

2 Likes

this would basically give me the same results as my second attempt, tile to tile predictable generation with some severely hard-coded variety

Its pretty good variant, but backrooms by canon need to have not repeatable rooms, thats not really easy to make with it.

Hey there, I have been thinking about this concept for a project myself.

For me, the best way to do it would be generating random walls, items, furnitures (and possibly spawn entities, dear lord mighty) above a floor that is defined as a chunk, like in Minecraft.

All chunks would have the same size, and the game would use a custom coordination system to save and load them, or generate new ones in case they have yet to be created in that one coordinate.

Keep in mind however, that walls should keep some paths to progress and travel to other areas or levels (basically like biomes in Minecraft, yet again), so some coding to prevent enclosed spaces would be needed.

4 Likes

I’ve actually been working for months now on this, and i have a pretty good idea of how i’d do it with my skillset. Since i cant actually add any context to near areas since im stupid, i just randomize the placed walls and the height of them. Thanks to these properties all being set in stone, i can actually play around with them. Here’s what i have so far.


2 Likes

This is literally what I’ve been working on.

For this, you would want to have 4 variables.

  1. Completely random generation chance. (I use 7)
  2. Generation chance if there’s a nearby wall. (I use 2)
  3. An empty table to insert generated positions into.
  4. A variable generation chance, set at the start of the script to the base chance.

Generation chances are 1/variable, so the higher the number the less likely it is to generate.

Then, define your zone boundary.
Loop through X positions divided by X size of your wall, then nest another loop inside it doing the same thing with Z positions. With every iteration of the inner loop, check if the position has a nearby wall. If there is one, set the variable generation chance to the nearby generation chance. If not, leave it be. Then do if math.random(1, variableGenerationChance) then generate a wall at position Vector3.new(X minimum + (current X position iteration * size X of your wall), desired Y position, X position calculation but with Z instead of X) end obviously, that isn’t functioning code.
If it doesn’t generate a wall, decrease the variable generation chance by 1.

That’s about it, if you have any questions reply/dm me.

2 Likes

One method you can try to use is Wave Function Collapse. It’s an interesting algorithm with some really creative games made with it. I made a module for it recently for my survival game I’m working on in order to build the terrain. Once of the times I ran it, it produces a sort of map similar to what you might expect the backrooms to be. Here’s an image.

You could picture the green parts as walls, and the yellow as floor. Ignore the blue, that’s just water in this generation.

WaveFunctionCollapse

Essentially the idea is to create tiles or prebuilt models, sort of in a modular state so that they can attach to other parts. In your case, you could build several hall type modules and pillars, each taking up say 10x10 studs. Then, you just define which sides of the model can connect to other sides of other models. These are refereed to as “possible neighbours”.

The wave function then creates a grid of your map area, you can sort of image this as a chess board. Each square is referred to as a “cell” which holds the possible models that could fit into that area, a sort of superposition. The algorithm then gets the cell with the lowest possible models or in other words entropy, and “collapses” it, which means it chooses one of it’s possible cells to permanently remain there.

After this, the code propagates this information to the neighbours of the cell and continues until all cells are updates, before it repeats the cycle again and again until the board is fully collapsed.

Oskar Stalberg, a notable game developer has made some pretty creative games with a much more fleshed out version of this algorithm, allowing for more control over how things generate. You can find his work with a quick google, I’m not sure if I can post links so I won’t try that, but you can check out his work on his website.

[EDIT] My spelling was horrible and I was embarrassed.

6 Likes

Or mix up the rng chunks with modular chunks, especially for spawns (which would be infinetely random).

I have made this following my original reply, it’s fully random and infinite.
Rn I’m working on biomes (levels) in a procedural way

3 Likes

Hey, I was scrolling through and just wanted to see if maybe I could get some info on how you did this.

First of all, save chunks on the server when no players are nearby, this is key for making it endless.

The loading and generation are based off the player’s location, which is divided by the global chunks size (I suggest a size of 250+ to make the server less worked up).

Each player character loops their locations and check for chunks around them using the custom chunk grid (position/ChunksSize), if the position doesn’t have a chunk, then it’s generated, otherwise it’s loaded from the server’s folder.

To unload chunks I loop with a more long task.wait() so the server doesn’t get worked up, the chunk checks all players and their location (divided by chunk size).

In my game, 250 studs equals 1 chunk, so the player’s position on the first chunk to ever create in their server would be 0,0,0 until they travel out of the chunk.

The main chunk system is fully done on one script, the generation of stuff inside the chunks (per level) is done with ModuleScripts, but you can still make it into one if you want.

2 Likes

Would I be able to look at any of this? I have a lot of fancy mechanics in my game but its solely the generation that seems to be the problem right now. All credit where you want it, heres my project so far.




8 Likes

Hey, I’m super interested in your game. Please reply to me because I want to ask you about some stuff. You seem to be a great developer.

1 Like

sure, ask away. Its currently in some development hell but its making progress for sure.
only thing i really have to show for it is a few videos and a model for the next monster

1 Like

Thanks for replying. And sorry for not responding I had some exams, so I have 3 questions which are 1 how did you make the entity spawn in randomly generated rooms? - 2 how did you make the entity animations, was it from blender or moonanimater or something else because they are super smooth. and last is how you could make a randomly generated level that stops when entering another level, I’ve always had problems with stuff like this, oh and I’m super sorry for asking too
many questions, and if you don’t want to reply to some of them then it’s ok, I’ll be grateful for anything to respond. btw last thing how many years do you have of making games? I only started a month ago you could say I’m a beginner. That’s all thanks.

Oh, I forgot to ask but when is the game coming out? I am hyped for it looks super good from fancy game mechanics to quality, and it’s just AWESOME Hope your game blow’s up.

1 - areas are split by light sources, if there’s not any light it adds it to a list and in the end picks a random place and spawns. from there it will raycast in a random direction to find a corner then place him there.
2 - i made them in the roblox animator :\ no fancy answer to that
3 - placing random rooms infront of one-another, branch paths that dead end, and end the main branch with the elevator. for the more random schizoid generation i just placed down tiles with random walls and had giant areas that deleted all parts within them.
4 - about 8 years. I’ve always had a thing for art but i see a genuine lack in a lot of unique content on roblox so im hoping to fill that void within the next two years.

2 Likes

this game, currently titled WELTER, is in a severe state of development hell as of now. I’m great at sound design, art design, fancy visual programming, all that. Its just the level design. I for the life of me cannot do level design. I currently have polls going out asking for map designers but i seriously suck at map design.

the main reason for this is the fact that it isnt my comfort zone, which is fast paced fps arenas. Every area within welter is aimed towards being realistic indoor environments that have odd aspects to them to keep it feeling alien. Since most of the game is exploration, gathering, and ambience the map design is absolutely crucial to the game’s overall quality.

:pray:

2 Likes