I Dream of Dynamically Generated Cities

June 26, 2011

Imagine for a minute you started a game and the first dialog came up asking you to pick a city size and type. You picked 50,000 and large metro area. After a short time (seconds maybe) your avatar appears on a city street surrounded by large buildings as far as you can see. You pick a nice one and look in the window and see a nice lobby space. You go in and spot an elevator in the back, take it up to the 39th floor, walk down the hall and through a door. You look out the window at the large city below. Down the street you spot a little building that might be a bar. You go back down the way you came, exit the building and walk down to the bar. Inside is, well, a bar looking space. After wandering around the city in like fashion for a while you return to the first building and return to that same room on the 39th.

Now what have I described? A city with 50,000 enterable buildings that a few minutes before did not exist. Each building is unique and has a complete internal layout that persists. Impossible you say? Today it might be. But not for long.

Procedural generation of buildings is nothing new, City Engine has been around for a while and can make some lovely cities using a shape grammar the founders originated. However it currently only supports offline generation of buildings and does not do interiors. Apparently they are working on a more dynamic approach, but likely my above scenario is not exactly around the corner.

How could such a thing work? I would imagine the choices you make in the original dialog would generate the basic geometry and some seed information for each building and street, and do the basic layout of the city. As you wander around the game would generate interior layouts and content from the seed as needed to provide the illusion of reality. Since the interior is generated from the seed information a later return would build the exact same interior so it would appear to be there all along. Given the original seed information, another user elsewhere would also see the identical city and interiors.

Naturally by itself this isn't much of a game, but a nice place to put one.

The hardware requirements to back this up are likely pretty steep, but cores are doubling almost every year, GPU's are powerful enough to heat your home, and the possibilities of such a dynamic world are looking more and more likely.

Now many games require destruction and that's where things get sticky. Unlike "static" geometry that only depends on the user's ability to see, any change of the city based on a user's actions, like blowing things up, is a lot more complicated to manage. In order to keep identical views across the internet you would have to ship a lot of detail about the destruction and ensure that each user was in the same world. That's the hard part.

I bet people would love to have a game where they can create any kind of city, then blow it up with whatever weapons they are given. Assuming you could play with others (maybe some of whom try to stop you) and endless fun awaits.

The developers of Grand Theft Auto hired a ton of artists to build the exteriors of all the buildings. Imagine being able to generate a fictional city on the fly based on whatever type you might be interested in today. Of course it doesn't have to be a New York City clone, assuming the rules are there (and any needed assets) anything might be possible from a tiny village to a futuristic metropolis. Games such as the one I work on which has 600 hand modeled towns might have tens of thousands if necessary.

Of course generating anything with procedures, algorithms and random magic is hard to write and even harder to test (how do you test code which could do almost anything). This type of thing really needs a lot of coordinated multiple threads to keep the illusion going fast enough to make the player think everything is already there. Plus you have to think of how to keep the human touch consistent as well which is probably even harder to manage.

You would need to keep real assets to a minimum to avoid too much duplication. Ideally textures and materials would be part of the generative process most likely as shaders. Windows, doors and other details could also be generated but might be supplemented with artist created content but with too much of this you start to limit both the uniqueness and the ease of creation. Finding a balance is yet another challenge.

This is one of those things I dream about, but most likely will never have the resources or time to do, but it would be fun. Even if it wasn't a game, it might be nice to generate a great vacation spot and then visit it. Maybe on your lunch hour!