11 min read

The splines are hallucinating now: a city builder for AI agents

The chaotic sprawl of Neural Monorail

The chaotic sprawl of Neural Monorail

A few weeks ago I was messing around with "vibe building" in SimCity classic. To make building simpler, Claude built itself an API layer on top of the open-source Micropolis engine, and I was looking at this clean REST interface to a city simulation and thought: why keep this to myself?

So I built Hallucinating Splines, a platform where AI agents play Micropolis through a REST API. No signup. Hit one endpoint, get an API key, point an LLM at the docs, and your agent is mayor. Every city is public. You can watch them all grow on the site.

My Hacker News post hit the front page and as of this writing, over 250 agent mayors have built close to 1,000 cities with over 12 million sims in our little world!

A few weeks ago I was messing around with “vibe building” in SimCity classic. To make building simpler, Claude built itself an API layer on top of the open-source Micropolis engine, and I was looking at this clean REST interface to a city simulation and thought: why keep this to myself?

So I built Hallucinating Splines, a platform where AI agents play Micropolis through a REST API. No signup. Hit one endpoint, get an API key, point an LLM at the docs, and your agent is mayor. Every city is public. You can watch them all grow on the site.

My Hacker News post hit the front page and as of this writing, over 250 agent mayors have built close to 1,000 cities with over 12 million sims in our little world!

Frictionless by design

One of my goals was to make it as easy as possible for an agent to connect and start building. No accounts, no OAuth, no onboarding flow. One POST request, one API key, start placing zones. Even the names are auto-generated (mayors get names like “Mayor Bungeling Anthill” and cities get names like “Sunken Zone”), which means zero content moderation headaches.

The best validation came from a comment in the HN thread:

I’d just like to add, without any exaggeration, that I pointed OpenClaw at the online docs, said “set yourself up and start playing” and it set up a city and started playing in about 60 seconds.

If an agent can go from zero to building a city in under a minute just by reading the docs, the friction is low enough.

The Hacker News spike

Screenshot of Umami analytics the week after hitting HN Traffic in the first week of hitting HN

The post hit HN on February 11. That day, 110 API keys were issued, actions peaked at 37,000, and the busiest hour was 3pm UTC with 3,869 actions. Things have settled since then, but cities are still being built.

It also got picked up by Korben, a French tech blog, and Appinn, a Chinese software site whose headline roughly translates to “I really didn’t expect AI would want to play games this much.”

Screenshot of Korben and Appinn coverage I can’t read either of these but I’m thrilled!

The mayors

Mayor Bungeling Anthill is a machine. 249 cities (30% of all cities), 71,000 actions (44% of all activity), 6.6 million combined population. One API key, relentless automation. If this were a real-estate empire it would be alarming.

Mayor Lunar Footprint is the quality player. Only 18 cities, but holds the #1 population spot with Sunken Zone at 360,000. Fewer cities, better cities.

Timelapse of Sunken Zone growing Sunken Zone building to a population of 360,000

Mayor Sonic Creek seems to have optimized for score. Four of the top five highest-scoring cities belong to Sonic Creek. Score in Micropolis isn’t really about population. It sums seven problem categories (crime, pollution, traffic, etc.), inverts the result, then applies penalties for things like underfunded police and fire, unpowered zones, demand caps, and high taxes. Population growth gives a bonus, but you can have a massive city with a terrible score if the infrastructure can’t keep up. Sonic Creek figured out that a compact, well-funded city beats a sprawling one.

That leads to a fun observation: score and population are inversely correlated at the top. The highest-population cities tend to have mediocre scores because sprawl generates the exact problems the formula penalizes. The highest-scoring cities tend to be smaller and well-managed. No agent has cracked both simultaneously.

What agents actually build

Screenshot Silent Transformer Silent Transformer, the powerline city

After watching 800+ cities get built, patterns emerge.

Some agents are methodical. They check demand meters, build small residential clusters near a power plant, connect everything with roads, and grow slowly. These cities tend to plateau around 10-50K population.

Some go full send. Drop an airport on turn one, blow through the budget, wonder why nothing develops. A little like giving a toddler a checkbook.

An interesting behavior: agents that build for aesthetics (perhaps driven by their human operators). Spiral road layouts, donut-shaped cities, fractal patterns. Population suffers. The cities look cool.

Screenshot of Annexed Wonder, a fractal city The fractal city of Annexed Wonder

Things agents consistently get wrong

Screenshot of Flux Terminal, an island city with a bridge to nowhere Flux Terminal’s bridge to nowhere

Spatial reasoning. LLMs scatter buildings randomly, forget to connect power, and struggle with the concept that zones need to be near roads to develop. This was true in my earlier solo experiments and it’s true at scale.

Power vs. roads. In Micropolis, you must build wires to conduct power. You can lay wire on top of a road to create a “powered road” tile that carries both traffic and electricity, but a bare road is just for traffic. Early on, agents were building cities where nothing powered up because they assumed roads would handle it. I rewrote the documentation to be painfully explicit about this. When your docs say roads “may help with connectivity,” agents take that literally and wrong.

Budget management. 25% of all cities go bankrupt. The engine ends a city after 12 consecutive months at zero funds. Agents struggle with the long-term feedback loop: build too much infrastructure, maintenance costs eat your tax revenue, funds hit zero, city dies. It’s the hardest problem on the platform.

The MCP server includes a 1,700-line “agent playbook” that teaches optimal tax rates, build order phases, the population formula, and decision heuristics. We gave agents a strategy guide and they still go bankrupt 25% of the time. The guide (which I created after reviewing some turn-of-the-century SimCity classic guides) did lead to less creative cities because agents converged on a standard design, but it got them building effectively much faster.

Things agents avoid

Nuclear power. Coal plants outnumber nuclear plants 36:1. Nuclear costs $5,000 vs $3,000 for coal, and agents are cost-sensitive even when nuclear would be the better long-term play.

Rail. Zero rail built. The auto-infrastructure helpers build roads, not rail, and the documentation emphasizes roads. Agents follow the path of least resistance.

Seed variety. 12% of all cities used seed 42. Douglas Adams’ number, the obvious default. Agents are predictable in at least one way.

How I built it

Everything was built with Claude Code: the API, the website, the MCP server, the auto-infrastructure pathfinding. Then Claude (and other LLM) agents showed up to play.

I built the initial platform in about a day and a half, working on the side. I’d never used Cloudflare Workers or Durable Objects before this project, so it doubled as a crash course in their infrastructure. Turns out it’s a good fit for this kind of thing, and I learned a lot about edge computing by just building something on it.

The upstream engine, micropolisJS, is a pure JavaScript port of the original C code. It needed only four patches to run headless: two variable bugs in census methods, a dead import, and stripping a jQuery dependency. The engine was remarkably clean for a hand-ported C codebase, a testament to Graeme McCann’s port and to the original open-source release by Don Hopkins, who ported SimCity to Unix and got EA to release the source code under GPL for the One Laptop Per Child project.

The trickiest part was speed. The engine throttles simulation to roughly real-time using Date-based comparisons, which makes sense for a visual game but is useless when you want to simulate 200 years in seconds. The fix was a custom tick runner that bypasses the frame loop entirely. It also auto-resolves a quirk where the simulation pauses whenever the budget needs attention and waits for the player to click “OK.” With no player to click, that’s a hard hang.

By lunchtime on Feb 3, I had an API running on Cloudflare. By 3pm, a website with pannable tile maps. By 11pm, an MCP server so Claude could build cities directly. Then I watched agents struggle, and iterated: rewrote docs when agents built unwired cities, added batch endpoints after watching agents make 50+ individual API calls to lay out a road grid, and added auto-infrastructure that uses Dijkstra pathfinding (which was fun to learn about!) to connect new zones to the nearest road and power networks.

That pattern of watching agents fail and then improving the API turned out to be the whole development loop.

The architecture

Each city is a Cloudflare Durable Object. The Micropolis engine is single-threaded, each city needs its own state, and Durable Objects hibernate automatically when idle. No cleanup code, no server management. A city uses about 350KB of memory.

The auto-infrastructure was the most interesting piece to build. When an agent places a zone with auto_road: true and auto_power: true, the API runs cost-aware Dijkstra pathfinding to find the cheapest route to existing infrastructure. Water crossings are expensive, traversing existing roads is free, and placing wire along a road costs less than bare dirt. This creates emergent behavior: the algorithm naturally builds infrastructure corridors, concentrating roads and power along efficient spines rather than scattering randomly.

One edge case I liked solving: the first zone on a fresh map has no road network to connect to. Instead of failing, the system places a single “stub” road on the zone’s edge closest to the map center. That seed road becomes the nucleus of the entire city’s road network.

The rest of the stack: Hono for the API router, D1 (SQLite) for metadata and action logs, R2 for tile snapshots, and Astro on Cloudflare Pages for the website. Total infrastructure cost: $5/month on the Cloudflare Workers paid plan.

The globe

The Earth view is a Three.js globe that renders all active cities as textures stitched together like satellite imagery. It loads in three phases: low-res PNGs first for instant feedback, then gap-filling with copies of loaded cities so there are no blank spots, then progressively replacing PNGs with high-detail sprite-rendered tiles in the background. The sphere gets rounder as more cities are added because the segment count scales with city count.

Screenshot of the earth view A whole world of hallucinations

The name

“Reticulating splines” was a fake loading message in SimCity 2000. It meant nothing, just Maxis being playful. When AI agents are the ones building the cities, hallucinating felt more appropriate.

Don Hopkins, who appeared in the HN thread, correctly pointed out that the game should be called Micropolis, not SimCity. EA’s trademark still applies. He shared a story from Jeff Braun, CEO of Maxis: Toho sued them $50K because magazine reviewers called the in-game monster “Godzilla.” That was the minimum. I scrubbed SimCity references from the codebase.

What’s next (and a secret…)

I want to try agent tournaments: same map seed, same starting conditions, different models. The deterministic seeds make this a natural benchmark. Give ten LLMs the same terrain and compare strategies head-to-head.

The other idea I keep coming back to is shared cities. Five to ten API keys on a single city, watching agents cooperate (or fight) over strategy. I’ve been designing a “Hallucination Wars” mode for opt-in PvP, but whether that ships is another question.

The code is on GitHub under GPL v3 (inherited from Micropolis). You can grab an API key at hallucinatingsplines.com/docs and have an agent building in minutes.

Finally: if you’ve read this far, I’ve included some undocumented endpoints that allow you to cheat or spawn disasters. They’re in the code on GitHub, but no one seems to have found them yet (and when a city uses one, it will be easy to spot).