The City That Designs Itself — Procedural Urban Planning
Terrain emerges. Roads grow via Wave Function Collapse. Districts cluster by centrality. Buildings rise. 1100 commuter agents leave traffic heat trails. A different city every reload.
What this is
Press regenerate. Watch terrain ripple into existence. Then road tiles start sprouting from low-cost downtown seeds and growing outward via Wave Function Collapse, snaking through valleys, avoiding ridges. Then betweenness centrality colors the roads — red for downtown core, orange for commercial, blue for residential, gray for industrial. Then buildings rise on every lot adjacent to a road, taller where the road is busier. Then 1100 commuters spawn and start traveling between random origin/ destination pairs. Their accumulated traffic warms the most-used roads to glowing white over time.
Why this is mind-blowing
You can describe an entire urban planning pipeline in one paragraph and the model will assemble it from algorithms it learned from research papers. The downtown emerges from the rules — you didn't place it. The traffic patterns reveal which roads are the actual arteries of this particular city. Each reload is a new place that feels like it has reasons.
Build a single-file procedural city generator. Five stages run in sequence
before your eyes. Stage 1: Perlin-noise terrain, low-poly faceted shading.
Stage 2: grow a road network using Wave Function Collapse, respecting
terrain (avoid steep slopes, follow valleys). Stage 3: betweenness
centrality on the road graph clusters tiles into downtown / commercial /
residential / industrial districts. Stage 4: drop boxy buildings whose
height tracks local centrality. Stage 5: spawn 1000+ commuter agents
that pathfind on the road graph; their accumulated traffic glows on the
most-trafficked roads. Press R to regenerate.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Wave Function Collapse — Maxim Gumin's 2016 algorithm — is the single most useful procedural generation primitive of the last decade. The model knows it. Just say the words.
- Sampled betweenness centrality (a few hundred random BFS pairs) gives you districts that feel organic without the O(V³) cost of computing it exactly. Approximation is the right answer for visualization.
- Show the city building itself in stages instead of dropping a finished result. The process IS the demo. Every reveal is a new wow moment.