0
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – congusbongus Jan 23 '18 at 2:16
  • \$\begingroup\$ 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. \$\endgroup\$ – Ryan1729 Jan 23 '18 at 4:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.