CityScape

There’s a joke that game developers often use when discussing beginners –

I’m making a fantasy MMO RPG. All I need are a few programmers and a 3D artist!

Almost every burgeoning developer has an overblown image of their own abilities. Massively multiplayer games are near-impossible for even the largest AAA studios to develop and support. Experienced devs are almost unanimous with their advice: start small. Make a tiny game that nobody will play. Work your way up. Make something new every month. Iterate.

This post details the dumbest long-term decision I’ve ever made. Of all the projects I could have chose, I picked the most complex, ambitious, and tedious idea I’ve ever had.


Making a Pseudo-Random City Generation Algorithm

map

Disclaimer: the picture above is from one of my art projects, not from my algorithm

Here’s a field guide for those who don’t obsessively crawl through dev forums like I do.

Procedural Generation: An umbrella term for artificial creativity. The practice of using computer programs to generate things that seem hand-made. For example, an AI that writes Beethoven-style music, or a game that designs a different dungeon for each playthrough.

Pseudorandom: a mathematical process of generating numbers that ‘seem random’. In reality, these numbers are generated by a seed, a number that is used to consistently generate the same set of numbers. This is useful for making algorithms consistent. For example, each minecraft world has its own seed. Every time a player loads the same game, it re-generates the same map.

History

Procedural city generators aren’t new. Academics Pascal and Muller pioneered the topic by using organic L-system methods for generating city maps. Introversion’s cancelled project Subversion is still the most impressive real time system to date, although the software was never released. Esri’s City Engine is a proprietary solution to generating very large static city maps.

All of these examples have one thing in common - they aren’t accessible to the general public.

I’ve been obsessively fascinated with procedural generation ever since I started actively experimenting with game development. More specifically, procedural cities. I’ve wanted to get my hands on something like City Engine or Subversion city generator for years. Today, I’ve finally taken this yearning into my own hands…

…I made my own city generator.

Philosophy

joke

Many hobbyist city generators I see on the internet use stock building models that are repeated along a road map. Typically, the roads are square grids to minimize complexity. These two factors make them look lifeless, artificial. In an act of self-torture and regretful lack of foresight, I’m doing the exact opposite.

In this city, every building will be more or less unique. My cities will have complex and organic road maps to showcase these unique buildings.

Walking around a real-life city (I actually do leave the basement sometimes), one might notice that there’s a clear dynamic between road patterns and architecture. Sometimes, buildings are plopped down first and roads are squeezed in later. Other times, building facades expand to fill the block’s outline like water filling a container. I want to capture the organic growth and complimentary structure of urban design.

The theme I’ve chosen for these dynamic structures is dystopian sci-fi. My favorite fiction books are classic cyberpunk novels like Neuromancer and Snow Crash. It’s probably cliché at this point, but hear me out; Cyberpunk is about overwhelming corporate power that promotes massive, diverse megacities. What better way is there to convey cyberpunk atmosphere than an infinite procedural city? Miles and miles of concrete and glass have replaced any semblance of nature.

My Implementation

joke

The things I have so far:

  1. An undirected graph system for holding roadmap information
  2. A system for meshing and visualizing roads (using system #1). This system can make roads of any width, and supports any n-way intersection. The one thing it lacks (which I may never implement) is curved roads.
  3. A system for designing and meshing buildings, which you can find in this lengthy report. I’ve added many features since writing the report, but it gives a good general idea of how things work.

I’m using Unity, which is typically quite straightforward. However, its mesh library is quite barebones. I spent the first month just typing up a script that makes creating custom meshes way easier.

My todo list (in no particular order):

  1. Adding more complexity to buildings, including multiple wings, stair-platforms, and shop-lined bases.
  2. Adding props to roads, sidewalks, roofs, and walls.
  3. Making a color palette generator to increase unique city iterations.

And without further ado…

Results

All of these cities were generated with the same algorithm using different seeds. I’ll let the screenshots speak for themselves.

A crowded slum-like neighborhood

1

Night time for this NYC-style metropolis

2

Hi-tech ‘scrapers

3

Budget housing

4

A sweeping grid valley

5

A purple avenue

6

Tall and white

7

A dark future

8

Conclusion

For such a lofty commitment, I haven’t given up on the project yet. This whole thing is about 5 months in the making, and I’m excited about what directions I can take it. Once things like street lights and advertisements are added, the cities will feel more real and lived-in.

Who knows? Maybe someday I’ll get to add some RPG elements, and a casual MMO feature.


I’m far from done, but I’ve come a long way. Hopefully this blog will help push me to keep adding interesting features and communicate with like-minded developers.

There’s a lot to unpack here, but stay tuned for more focused and technique-centered posts.