Procedural buildings?

Started by
2 comments, last by Plethora 11 years, 2 months ago

I was thinking about how someone would set up an algorithm to generate semi-procedural buildings.

The example I'm thinking of would be The Elder Scrolls II Daggerfall. While I didn't played it myself (saw a number of videos/read about it), I know it had procedural generated cities, with buildings sprouting here and there, while also spawning special buildings that weren't quite procedurally generated (ie, guild halls, quest related stuff).

Now, Daggerfall had buildings that weren't really complex. So I want to add a twist to it. Say that instead of spawning entire buildings I have a list of specific room types. Say, a list of 10 kitchens, 10 living rooms, 10 dormitories, etc.

All pre-authored stuff. So an artist would design a kitchen and add it up to the kitchens list for example. The kitchen could be of any size, maybe having several entrances/exits.

A house needs a bare minimum of room types to "function", ie, a certain number of dormitories depending on how many people live there, an entrance, a kitchen, a storage room, etc. Maybe even if we're dealing with an upper class house, we have guest rooms, several kitchens, dinning room, a library, etc. So each "house tier" has its own basic requirements, maybe a size limit (so you don't have a massive lower class house or such things).

Now, the idea would be feed these room lists to an algorithm that could randomly select a room of some room type list, and build up the house from there, selecting more rooms as it goes, placing them according to their entrances/exits.

I know that FPS from Wolfire constructed its scenes in a similar way. It has entire places predefined, and it constructs a level from those. My idea would be "micro manage" this procedure by having only predefined rooms instead.

Ideas are all fine and good but I have problems imagining how the algorithm would work IF it could work. Maybe I'd need to severely restrict door sizes and their position so the algorithm is simpler. But it still sounds like I'm missing a lot of things, like bounds checking, some sort of "sense" checking (not entering a dormitory from the bathroom for example) and probably many particular limitations the algorithm would need.

So I don't know if it's actually too complex to do. Have in mind that it shouldn't necessarily work in real time. It could be a "pre-pass" at world creation or something like that.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Advertisement
I would start by designing a few houses by hand. You will probably find that you are using some sort of algorithm, and if your introspection skills are good you might be able to program it.

The way I think of these problems is by looking at design as a top-down process. If someone gives you the boundaries of the house and you have to put rooms there, think of how you would divide the house into rooms, and then think of the design of each individual room later on. Similarly you may need code that turns the problem of designing a town into several instances of designing a neighborhood, a neighborhood into blocks, a block into buildings... This hierarchical approach divides the design process into manageable chunks.

A relevant classic paper in architecture is "A city is not a tree", by Christopher Alexander. The main thesis of the paper is that a purely hierarchical approach can never produce a reasonable city, because there are relationships between elements at the same level of detail. I believe one can avoid the difficulties described in the paper by incorporating enough context when dividing the design problem into sub-problems. For instance, instead of "design a kitchen in this space", the task would be "design a kitchen in this space that connects to the dining area through this door, to the pantry through this other door and which has a view of the river through this window". That's what I mean by "enough context".

If you think of one design step (e.g., house -> rooms) as having to fulfill a bunch of preferences, you can encode those preferences in a utility function that needs to be maximized. You can then use some approximate optimizer (e.g., simulated annealing) to find a desirable configuration. Your utility function can encode things like the undesirability of having to enter a dormitory through the bathroom.

You can try to stop the design-refinement process at some level, for instance by using pre-authored rooms. You can either inform how you design the house of what pre-authored rooms are available and just assemble them, or you can make your pre-authored rooms somewhat flexible so you can change a couple of parameters and adjust it to the room you want to make.

I would start by designing a few houses by hand. You will probably find that you are using some sort of algorithm, and if your introspection skills are good you might be able to program it.

Hm, I hadn't thought it that way. Well, i actually played quite a bit of Sims before :D I often started doing the 4 walls of the biggest room in the house, usually the living room, then added rooms from there (living, then kitchen, then dorm, then bathroom).

That sounds more easier to design. You have the living room as the center piece of the house, and then design the rest of the rooms on top of that. Easier to assemble too I guess.


The way I think of these problems is by looking at design as a top-down process. If someone gives you the boundaries of the house and you have to put rooms there, think of how you would divide the house into rooms, and then think of the design of each individual room later on. Similarly you may need code that turns the problem of designing a town into several instances of designing a neighborhood, a neighborhood into blocks, a block into buildings... This hierarchical approach divides the design process into manageable chunks.

A relevant classic paper in architecture is "A city is not a tree", by Christopher Alexander. The main thesis of the paper is that a purely hierarchical approach can never produce a reasonable city, because there are relationships between elements at the same level of detail. I believe one can avoid the difficulties described in the paper by incorporating enough context when dividing the design problem into sub-problems. For instance, instead of "design a kitchen in this space", the task would be "design a kitchen in this space that connects to the dining area through this door, to the pantry through this other door and which has a view of the river through this window". That's what I mean by "enough context".

That's the thing I hoped to avoid by having pre authored rooms. If I start with the boundaries of the house, subdividing it into rooms, then I can no longer have pre authored stuff and I would need to code a way to furnish the house which sounds waaaay more complex than just assembling a house out of a room list.

I thought about it as neighborhoods, divided by lower, middle and upper class. First Assassin's Creed cities were divided and unlocked by lower, middle and upper neighborhoods. With each type of neighborhood comes a "tier" of rooms. Lower class have fewer room types, with less furniture and such. Middle class have more or less the same room types, but with more furniture, costly things and such. Upper class have several room types (libraries, spas, "piano room", etc) with more complex houses.

But, with that there comes the problem of position. Neighborhoods have limits, roads, houses should accommodate to those limits. And while I can imagine more or less a way to assemble houses (via bounding boxes, "access portals" and some rules for positioning), I have no idea if you could actually create roads and blocks procedurally in a way that makes sense and it isn't boring (ie, no massive grid layout). Sounds pretty complex.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

If the point is to simplify things by pre arranging individual rooms, why not do that with buildings as well. It shouldn't be overly difficult to template up a whole bunch of different designs and arrange your rooms to fit into your templates in some way that allows some variance and randomization. Say you have a template that says this house will have four rooms. One room is 4x5, one is 2x3, one is 8x6 and one is 5x6, and they are arranged in "this" manner.

So you write an algorithm that will run through the list of rooms you've made and will randomly choose 4 rooms that fit those size requirements. Maybe you always want the living room to be the 8x6 room but the 4x5 and 5x6 rooms could be interchangeable between kitchen and bedroom for example. From there you can just predifine a whole bunch of house templates and build some simple rules like the bathroom can't be bigger than any other rooms or whatever. This has the advantage of being relatively easy to code, and you could add as many templates as you think you need once you have an algorithm that works. You could even code up a utility where you could quickly simulate through a whole bunch of buildings and just add templates 2 or 3 at a time until the level of variation seems good to you.

I'm working on a game! It's called "Spellbook Tactics". I'd love it if you checked it out, offered some feedback, etc. I am very excited about my progress thus far and confident about future progress as well!

http://infinityelephant.wordpress.com

This topic is closed to new replies.

Advertisement