Hey everyone! I’m Greg Underwood and I’m the engineer in charge of the Zoning System for the new SimCity. The Zoning System is what we use to handle the physical placement of buildings instead of the grid from previous versions of the game.

Building a city is very much a geometric problem – buildings and roads need to be positioned in the world somehow, and the city needs to develop in a natural, cohesive, and believable way.
The grid system of previous games was a handy shortcut – it pre-divides the space into a series of regular cells. Roads and buildings each take up a set number of cells. This greatly simplifies city growth and building placement, turning it into something akin to a game of Tetris.

SimCity’s new curved roads and full 3D environment change things and we need a new way to handle building placement and city growth. Enter the Zoning System! For this game we decided to start with the roads – draw a road and then you can place buildings or paint zones and let RCI grow. Behind the scenes, when you draw a road we generate a set of zoning lots:

These lots are an ad-hoc division of the world, providing us with an organic grid, one that conforms to whatever curves you throw at us. When you paint R, C, or I zones with the Zoning Tool you can get a sense of their shape.

When one of the Zoning Rules runs and asks if there is space for a particular R, C, or I building to be placed, the Zoning System searches through those zoning lots for a group that can fit the building. This is a complex problem when the grid isn’t square and regular. Because zoning lots conform to the curves of the road they’re sometimes wider or narrower at one end and they can overlap each other in unusual ways. That means any collected group of zoning lots won’t necessarily be a rectangle. In these next images I’ve enabled one of our debug draw modes to highlight which lots are zoned to what type of zoning. This has the nice side effect of letting you see the shapes of collections of lots under a couple of different road configurations.

This presents an interesting computational problem to be solved – given the outline of a building’s lot, can it fit into a potentially oddly-shaped polygon described by the collection of zoning lots? There’s a mathematical description of this called the Polygon Containment Problem. The TL;DR version of which is “how many different ways do I have to try to see if one shape can fit inside another?” Since there are an infinite number of shapes the details of the solution are fairly complex and a full implementation of it takes quite a bit of computational time. However, the nature of SimCity means there are two key facts that change how much of the solution we need to implement.
We know the orientation of the building we’re trying to fit into a collection of lots – it has to face the road. We know the shape of the building – it will always be a rectangle.
These two facts allow us to strip the Polygon Containment Problem’s solution down to just a couple of quick tests and allow us to quickly place buildings along your city streets.
There’s quite a bit more going on as well – consider intersections (and the overlapping zoning lots that result), steep hills, bridges, waterfronts, and cliffs. Not to mention buildings, especially those with internal roads and Modules that you can place on top of the building’s lot. All of the buildings in the game live in the Zoning System in some form and they all interact with each other. Keeping track of it all and growing your city in a believable and cohesive way with such a variety of conditions to balance is probably the most interesting and fun challenge I’ve had in my career. I hope you enjoy the end result as much as I enjoy the details of the solution!