Some of you may know how much I enjoy random content generation. Last night I was thinking to myself, "how could I easily generate a random city for use in, I don't know, a zombie game?" I came up with this post. I have not implemented this yet, but I don't see how it could be particularly difficult.

Step 1.

First, you need a simple grid of streets and lots (to place buildings or other features in). This is the framework for your city.

Step 2.

Second, you will randomly remove some lots from the city and replace them with some non-city feature (such as a forest, a lake, whatever). You need to store the location of the streets from these blocks that you have removed because they will be used later.

Step 3.

Next, you will create an invisible maze structure (the hunt and kill algorithm is simple to implement and works fine) which is layered over your city.

The walls of the maze (purple lines) now tell us what parts of the city are supposed to be somehow walled off.

Step 4.

The fourth step is to randomly remove some (not all) of the streets that are blocked by a wall in the maze. You need to save these locations because they will later be turned into a feature such as a blocked alleyway.

Step 5.

This picture shows what information you should have at this point. The yellow lines indicate that something needs to be on that street to block players from crossing (fire, rubble, dead bodies, whatever). The blue lines (which are the streets that were removed in the second step) indicate you need some way to cross whatever random feature you have placed here (a path through the forest, a tunnel through a mountain, a boat to cross a lake, etc).

Step 6.

The last step is to generate your buildings. Divide the remaining lots into four quadrants, and place the walls for the buildings. Some buildings can be more than one quadrant big, you just have to make sure you don't extend it past a wall in our invisible maze. In this picture, yellow means "this area needs to be blocked."

You can then make your buildings more interesting by placing things inside them, or perhaps making some of them 2-3 stories tall with stairs, etc.

Other stuff to do

You can add all sorts of details to your basic city such as sidewalks, benches, night lights, manholes (which you could then create sewer systems for!), traffic lights, etc.


Anyone have any suggestions on ways to improve this? I am terrible at explaining things, so if you have any questions about something, just ask. Thanks for reading!
Well that's a very nice guide, I've got to admit. It's actually coolest to me because it brought up the idea of a randomly generated city in a zombie game which I hadn't thought of.

Just one thing I think would be cool is maybe talking about how to implement this in DM. Like it's a great guide if you know how to use DM very well but it doesn't really help people who don't know DM well enough to implement this on their own.

Maybe even just some sort of pesudo-codish talk to get people started in working on making it would be nice.
In response to Zecronious
You might want to check out my Directional Grid library. That should handle most of the maze details. (For a more zoomed-in city view, BSP Maze might be useful.)
In response to ACWraith
Ah true, I remember those now. Well good luck to anyone who attempts this.