Random room placement?

I have been playing around with the idea or making a horror game for a while now, and after watching a few tutorials I decided I want to do it on BGE (mostly because I am familiar with blender) I already made some of the character models and figured out some of the mechanics, but I ran into a sang…

The game revolves around the player running around a creepy house trying to survive until the night ends (there are a total of 7 nights). However to increases the replay value I want the house to be randomly generated each night so each play through is different…. Well maybe “generated” is the wrong word. More like randomly placed.

I am making this distinction because randomly generated is typically procedurally generated rooms and corridors to make a dungeon. I don’t want it to make the rooms, I want it to place the ones I already made.

My idea is I will have 20+ premade rooms of varying sizes and door placement that will be randomly arranged onto a three 10 by 10 grids stacked to create a new layout for each phase, or night. (The house is three storys high, so it would looks something like this http://gyazo.com/9e90d5ff61848a647a29707579a70a3e )

The way the computer would figure out what room to place where is determined by how much space is available and the location of unconnected doors… gaaa let me show you an example of what I am thinking xD

So here is a sample grid, and on this sample grid you can see there is already two rooms placed and there are two doors leading to nowhere.

There is a 3 by 3 space available adjacent to the open doors

So the computer picks a room that would not only fit in that space, but has the correct door placement to put there….

Is this making any sense? xD

A different option would be if the problem cannot be solved with one room, it would use two.

Another thing I would have to put in is some sort of code to prevent the placement of doors leading off the edge of the grid, and at least two 2 story “stair room” to be placed on each level so that you can go up and down. And though this is not a priority I would like some way to prevent rooms with windows spawning right next to another rooms wall.

I got a basic idea of HOW I want to do this, but have no idea how to code it and I am pretty sure you can’t do this with logic bricks…

So do you guys have any advice? Maybe some tutorials or something? xD
I am kinda grasping at straws here ;-;

Smoking_mirror has been working on this.

can’t find the link…

The idea could work but I think you should ease up on the random generation a bit if you’re new with BGE and python programming. And you would actually put very much time into designing such algorithm with other people’s projects offering little help as it’s pretty game specific even before worrying about if you can program it or not.

You could put the staircase in predetermined location and divide the rest of the area in 3 or 4 sections. Then make couple of alternatives for each section that work with each other with doors. When you have 3 stories and 4 sections each and say 3 alternatives for each section you got already 3^12 = 531441 alternative maps. You could randomize some other things like wall/furniture color, lighting and enemy spawn points pretty easily and it would boost the randomness a lot.

You could do this simplified yet effective option mainly with logic bricks. For each section set up an empty that spawn in a random section out of the alternatives for that section. Make some couple line scripts that adjust the object color of these mesh objects and lights. Make another script that picks x number out of enemy spawn points out of n number you designed and included in the section.

Start small and see how it goes. You can always scale up later if you manage the easier version.

EDIT: amagad let me redo the math: 12 sections and 3 alternatives for each: 3^12 = 531441 total alternatives.