Your city might drive you crazy. But all that chaos exists only at the street level. From on high, cities follow rules: They bend around topography, tower above zoning, and squeeze between bodies of water.

Anything with rules can be gamed. So imagine you're making a game, of the video sort. Building your own digital metropolis hands-on would take teraflops off your life. Instead, you could write a program incorporating a bunch of rules determining where roads lie, how buildings grow, what those structures look like. This is the logic behind procedural cities, a computational method used by videogame designers, architects, and computer hobbyists to create on-the-fly urban landscapes.

Just because cities follow rules doesn't mean they're easy to generate. At least, not if you want your city to be interesting. "The randomness you find in a city comes from a whole history of accidents that became functional," says Luís Bettencourt, professor of complex systems at the Santa Fe Institute in New Mexico. Yes, computers are great at generating randomness, but not as good at turning randomness into complexity ... and then adding more randomness and more complexity.

None of that makes solving the problem of procedural cities insurmountable. Just incomplete. But still, take a look at what's possible:

"You can use a number of algorithms or patterns to represent structures," says George Kelley, a Dublin-based web developer who worked on a project called Interactive City Generation. "Look at something like tree branching: You can define how things in botany branch and grow." Kelley and his co-authors used these kinds of algorithms to generate procedural organic road patterns.

Then, to give their city a more neighborhoody feel, they defined Voronoi cells—shapes dependent on the distance between a central seed point and surrounding points—with different rules. "That way you have different growth patterns," he says. And terrain forced randomness into the equations.

Building procedurally gets harder as you scale up to the street level. But it's not impossible. Kelley points to tools like ESRI's CityEngine, which lets you define architectural styles and building colors. "You can even have hand-painted signs and so on," he says.

Procedural methods can be a quick and dirty way to build large, varied cities, but the method does have its trade offs. "While we can generate randomness, it is difficult to generate randomness with structure to generate complexity," says Bettencourt. "The only way to do it is to have another complex system create it, which is basically a person."