Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

Procedurally Generating the Building Interior: Furniture and Fixtures

So I’m finally starting to make progress. I’ve emerged from the first massive refactoring of my code and game architecture in one piece and only a few tears. I’m getting closer to the point where I’m happy with it all. I’m not 100% happy with it, there are some murky parts. But the key thing is I’m close to solidifying a single method when generating everything from the city layout to where filing cabinets go.

I have the some basic offices layouts down now. It’s not the only type of building in Redacted, but it’s the key type and I’m concentrating on that to begin with. It’s certinaly buggy at the moment and there needs to be a lot more work done in many areas; there are no kitchens and bathrooms – yet. We do have basic offices, meeting rooms and from there I can start to build my game on.

Real world office planning revolves around unit boxes that building designers and furniture manufacturers all adhere to. The American standard is a 5 foot box that can fit a desk and a person on a seat. At the moment my boxes are slightly larger on the account of the desks I’m using. This might change with different buildings and desk types.

To place everything I take each room and cut it into (invisible) boxes. I find out where the entrances are and mark them down. Then I mark paths from each entrance to another until all entrances are connected. I check for unreachable boxes that do not have a path next to them and attempt to draw another path from the deepest inaccessible box until it reaches a path or door.

Then I place desks on all the non-path boxes and rotate their entrance based on where there is a path or entrace. If there are many free boxes, I alternate which to use based on the x and y box coordinates to increase the chance of alternating desk layouts like we see in real life. In the above example it is obvious there is a little more work to be done to improve this. All the rooms now have desks, chairs, cabinets, lights and light switches. There are a few more key ingredients to put in but we’re getting close!


Basic Pathfinding in a Procedurally Generated Building

So there isn’t as much visually to show this week. I’ve hung up my geometry creating hat to focus on other aspects of the game now. Specifically, I’m moving towards a prototype enemy. This week I have a basic pathfinding structure done. The benefit of procedurally creating a building is that you know where everything is actually located. I already have all the data on doors, room sizes and corridors so after these have been generated, I can use the data again to build a node based map of each floor.


Procedurally Creating the Interior of a Building

Procedurally Creating the Interior of a Building

Over the last couple of weeks I have been working on generating the inside of buildings. The buildings in the game need to have rooms and interiors. Every building should be filled with possibilities, not just a handful. I’ve been reading many, many, many articles, watching loads of videos and trying to digest as much knowledge on the subject. I came to realise this problem was not much different from dungeon generation in Rogue-like games. Each floor of these buildings is like a level in a dungeon, just going up instead of down. Roguebasin became a very useful resource and will continue to be as this project continues.

First up was to tackle room generation. Watching that Subversion video over and over again, I came to realise they were subdividing spaces and then deleting walls somewhat arbitrary. It created very nice rooms. The common theme I keep seeing in procedural content generation is that simplicity allows for complexity. I settled on a simple Binary Space Partitioning to create the basic rooms. Using the structural pillars of the building to draw a base room unit, I would divide and divide again until it was either too small the divide further, or it randomly decided to stop. The building core would have to be accounted for so I started to four super rooms that surrounded it. These super rooms contained all the room units on the floor that would then be split to create something like the above layout.

Next I would generate all the walls that partition these rooms. Each wall had two points that defined it and these points will come in handy later. I then iterated through the walls and deleted a percentage of them to give some larger, interesting rooms and cleaning up loose walls after.

Next up was calculating the depth of these rooms from the core. The above image displays this, starting at white for the core. It goes red through to violet, nearest to farthest respectively. The depth will be handy for further generation and later on when assigning goals within the game.

I needed to generate corridors next. These will link up most, but not all rooms directly to the core. Initially, I attempted a really simple algorithm. I looped through all the rooms converting one of its free walls into a corridor. I avoided small rooms that I had labeled as cupboards/store rooms and any walls touching the external parts of the building were ignored. I then checked if there were any obvious gaps in the corridors and plugged those. I ended up with the above which was adequate for my purposes until I tested it on some other seeds. It fell short too often so I ditched it.

Instead I used the basic Dijkstra Map process over all the wall points. Starting from the outside walls, each corridor would attempt to work it’s way back to the core choosing the shortest path. This was more than adequate and gave rise to some very interesting floor plans. Finally, I looped through the rooms from the core, adding doors into walls and corridors until every room became accessible. The above is a final layout with geometry created.

There are some further additions I need to look into. I can definitely improvement the corridor design, like backtracking and selecting a different path if it can’t get close to the core. Corridors should prioritise larger rooms. There could be less doors or maybe slightly smarter door placement. For now – this will do!


Video of City Generation Progress

Here is the progress I’m making on the city generator. The building shells and egresses have been created and basic level of distance is in place. About 500 buildings are modelled in about 6 seconds so there’s some work to be done reducing this time and improving the quality of the models. The grey buildings in the background are serving as eye candy only.


On Architecture

On Architecture

So when building a city, architecture is a very big question. I’ve always been an admirer of it, ask me when I was 5 what I wanted to do, and the response would have been ‘an Architect’. So when it comes to choosing a style that fits the scope, scale and style of the game, I had to do a bit of research…

One key point to make is that all buildings with have explorable interiors. Every floor, lift, stairwell and room will be generated. This is a departure from most city generators that concentrate on creating exterior content. This is also another reason why all my buildings will be convex rectangles to keep calculations simple and fast. My work so far is the basic creation of a building, there is a lot more to do to the externals to make them more interesting.


The city is going to have three styles of architecture; The Chicago School, Le Corbusier and the International Style. These all fit within the simple squared building that will occupy the Redacted world. Their structures are easy to produce procedurally compared to say Postmodern or Art Deco. The sharp angles and lines also increase the sense of order. A large theme in redacted is the nature of reality and what can we trust. The player will view the world reconstructed by his drone pilot program and a lot of information will be redacted for security purposes. I remember the set designers on the Matrix motion picture used a lot of right angles and squares in the Matrix world to reinforce the sense of artificial construction. These styles are also quite cold and functional, adding to the sense that the world is like this and you’re on your own.