Skip to main content
2 of 2
replaced http://farm7.static.flickr.com/ with https://farm7.static.flickr.com/

I've recently implemented an algorithm for a procedural city layout. It's still very much a work in progress, but seems promising to me. Take a look:

procedural city example

The algorithm used to create this layout is loosely based on L-Systems. I have a base Element class, that has a rectangle marking its place on map and a method Grow, which creates other Elements inside the rectangle, and/or spawns some objects on map. Then there are actual elements, inherited from this base class: City, Street, Building etc.

The generation starts with a number of "seed" objects (in my case, just a single City element randomly placed on the map). Then the system iterates over all elements, calling Grow, until all elements become inactive (Grow returns false), or some large number of iteration passes.

The city in the picture is built using only a few simple rules:

  • City becomes a Street element splitting the area someplace.
  • All Streets grow 0-3 side streets, further splitting the area.
  • Also, Streets continuously try to fit a random-sized Building at the side.

The result is not terribly interesting, but not bad either. The system can be extended easily, and is simple enough to understand what's going on (-8

Nevermind
  • 7.6k
  • 33
  • 37