Evolving Cities and Video
For now, I've finished my work on simulating the economies of planets. Population and wealth grows and shrinks over time, players have the ability to influence their planets' growth via governmental policies. Mines consume resources, factories produce goods from raw materials. The overall desirability of the planet's economic indicators drives natural immigration to the planet or incites the population to vacate. I can generate the economic indicators of any planet at any time.
This is all fine and good on a spreadsheet or in the game UI
But do people want to play a spreadsheet or a video game? How will these changes manifest themselves on planets in the game, and not just as graphs and metrics in the UI? Enter the concept of Evolving Cities.
Initially, Pegwars biomes included a few different sized city tiles mixed in with all the natural biomes, all generated and placed during each planets' inception. This was done to make sure the engine could handling rendering large cities at distance, and be integrated into the biome system.
While a semi-random scattering of trees, flowers, bushes, crystals and rocks look fine, having a similar random scattering of residential, light, medium and dense city tiles makes no sense, as the following screenshot portrays. Random city looks random:
Cities are artificial, they are built for specific reasons and in specific configurations. Cities in the game should also look like they are built-for-purpose, but not only that, they should reflect the real economic data. As populations grow, cities on planets should expand. As populations and wealth wane, installation should be left abandoned, city growth should taper off. It wouldn't make sense to have a world with a massive population yet only a few buildings and houses.
There is some excellent research into procedural cities:
- A Survey of Procedural Techniques for City Generation
- Phiresky - procedural cities
- Interactive Procedural Street Modelling
Of particular use was the survey paper which summarises many existing techniques, and highlights their strengths and weaknesses for particular use-cases. This provided a great framework for choosing an appropriate strategy for the game.
For Pegwars the agent-based papers made the most sense. Specific city blocks are chosen and placed based on their ability to satisfy certain desires. This fits in well with evolving cities over time in the game in response to population growth determined by the economic model. For example,
- cities tend to spread in the path-of-least-resistance, i.e on flat areas rather than going up mountains
- residential tiles on the other hand prefer to grow near water features, on hills, near city centres, near forests, near places of work.
- high density tiles prefer to grow near city centres. Cities should have a central CBD containing larger buildings, and semi-organically taper off
- the population doesn't like to live too far from the city centre, and so once a certain distance is reached, it becomes more desirable to upgrade a lower-density tile near the city center rather than building new low-density tiles far away.
- subscribe to PLANET_EVOLVED events. These come with a payload of all the economic indicators for each new year in the evolution of a planet, e.g. population size, number of mines, factories, airports and spaceports.
- determine the delta in population, and the delta in installations. We need to manifest these changes as changes to the planet itself.
- I want to allow the player to manipulate time, like a fast-foward button. Sometimes time is advancing rapidly, and each planet terraforming cycle takes some non-negligble time in background jobs to get done. Especially when the planet heights get changed and the Vertex Buffers need to be re-uploaded to the GPU. So we don't necessarily evolve a planet year by year, sometimes the delta in population and installations can be much larger as they represent a change over say 50 years.
- Choose the location for, and build the requisite amount of new installations
- Choose the location for new residential and city tiles. The choice depends upon geographical proximity to the city centre, geographical features such as hills and water.
- Increase the population capacity to accommodate population growth by either building new residential tiles (sprawl), or upgrading exiting tiles from low to medium to high density tiles.
When a player is running a planet, they choose the initial HQ location, and also the location of mines, factories, airports and other installations. The chosen location of the HQ is important, as cities grow from the HQ and some locations are more desirable (meaning more population growth) than others. The location of mines are very important due to proximity-to-resources.
Each non-HQ installation also gets included in the evolving city process. Workers need to work at mines and factories, and they don't want to travel too far. While the major city centre will build up around the HQ, minor cities will spring up around minor installations as well. If a mine or factory has been around long enough, and the population needs of the planets are high, you might even find large cities forming around them.
Where to Next?
I'd like to include road systems in the city build since roads are very important features of cities, and even dictate to some degree where city tiles will be built. Highways between the HQ and installations would be a really nice feature.
Part of the desirability calculation is Eco desirability, I'd like to mix in forests and parks in the city evolution process, much like in real life.
Finally I think I'm getting closer to the core gameplay elements, such as flying your spaceship to other planets and dropping bombs on their cities. City tiles will be blown up, and this will directly impact the population size, the population capacity, and desirability.
Conversely, it will be important for city governors to build defense installations, like surface-air lasers. They'll need to build airports and build a defence fighter capacity. And hopefully, rich planets will be able to build energy-shield domes around important cities and installations. Maybe even entire-planet shields?