# Algorithms on Random Level Generation with Predefined Objects and Constraints

Let's say I'm developing a game where a city is generated and buildings are placed in a random manner. Methods to generate the roads are easy to find, it is akin to creating a maze but I can't think of a way to generate and place buildings.

There are constraints on how far buildings should be from the road, where balconies should face, where gardens or trees are placed near a buildings. More over, if there's a school its generation can't be all random. Play zone and basketball field should be in one direction and the building entrance should face that, too. A hospital have emergency and normal exit face one direction and the parking space is on the other direction where at a shopping mall have both entrances and parking spaces on the same side.

I'm yet to find a fitting solution. I thought of using physics simulations, stacking objects on the same place, giving volume to them and applying force towards where they should be and wait a short time until they settle. This would solve some constraints and prevent any overlapping but there may be downsides to this. I want to know if there's a simpler or more efficient algorithm to this problem.

• I don't think there's a single algorithm that can handle all you're asking for. You should split your problem into smaller ones. I would start by looking for a land lot generator for a single type of building, say a house lot or a parking lot. Schools and hospitals are more complex because they can contain multiple buildings/wings. – congusbongus Jan 23 '18 at 2:16
• This approach might be too heavyweight or complicated for your purposes, but your description reminds me of Answer Set Programming. Here’s a paper on using it for procedural generation. – Ryan1729 Jan 23 '18 at 4:41