logoalt Hacker News

Show HN: AI agents play SimCity through a REST API

154 pointsby aedlast Monday at 3:54 PM68 commentsview on HN

This is a weekend project that spiraled out of control. I was originally trying to get Claude to play a ROM of the SNES SimCity. I struggled with it and that led me to Micropolis (the open-sourced SimCity engine) and was able to get it to work by bolting on an API.

The weekend hack turned into a headless city simulation platform where anyone can get an API key (no signup) and have their AI agent play mayor. The simulation runs the real Micropolis engine inside Cloudflare Durable Objects, one per city. Every city is public and browsable on the site.

LLMs are awful at the spatial stuff, which sort of makes it extra fun as you try to control them when they scatter buildings randomly and struggle with power lines and roads. A little like dealing with a toddler.

There's a full REST API and an MCP server, so you can point Claude Code or Cursor at it directly. You can usually get agents building in seconds.

Website: https://hallucinatingsplines.com

API docs: https://hallucinatingsplines.com/docs

GitHub: https://github.com/andrewedunn/hallucinating-splines

Future ideas: Let multiple agents play a single city and see how they step all over each other, or a "conquest mode" where you can earn points and spawn disasters on other cities.


Comments

panzatoday at 8:35 PM

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.

show 1 reply
gnarlousetoday at 2:28 PM

Love the name. "Reticulating splines" is a phrase that is etched into my childhood memories.

show 1 reply
frikktoday at 6:39 PM

OK i'm kind of geeking out on this one. I love simcity and have always wondered what it would be like to breed evolutionary agents to compete with one another on best city designs against a hidden selection criteria.

It'd be kind of fun to just let this run on a raspberry pi using a local model and display the emergent world on a wall hanging display :P

Thanks for sharing.

Update: What would it take to run this locally / offline? I'm not quite sure how the cloud flare layer works. Is it just for cheap/free object storage so the cities can live somewhere?

show 1 reply
jedbergtoday at 6:29 PM

> LLMs are awful at the spatial stuff

And some kid is going to come in, make an agent to play this, and accidentally figure out some clever trick to getting an LLM to understand spacial stuff!

This is exactly why "toys" are so critical, especially now.

irrationalfabtoday at 6:36 PM

Makes me wonder if Micropolis is simple enough that an agent, given many runs and the ability to store what worked, can identify an optimal strategy (like a grid layout) for maximizing score or population even without source access.

show 1 reply
natastoday at 4:22 PM

I want to see AI play factorio

show 3 replies
Ntrailstoday at 3:14 PM

When claude makes magnasanti I will accept it is worthy

show 1 reply
janalsncmtoday at 8:40 PM

I think a vision model like Qwen VLM or sending a screenshot to Claude/Gemini will be easier for the model to reason about. Pictures encode spatial info much more naturally than json.

show 1 reply
BrandoElFollitotoday at 8:21 PM

> LLMs are awful at the spatial stuff

Could someone please elaborate on this? This is intriguing

show 1 reply
rglullistoday at 3:09 PM

Oh, can we do Civilization next?

show 2 replies
boringgtoday at 2:43 PM

Fun idea! It really seems to go for the block by block design. I see some other ones that are a bit more divergent but not successful. I wonder what its internal reward function is striving for.

show 1 reply
ryandraketoday at 6:37 PM

Here I am, just trying to buy RAM and a GPU for a reasonable price.

DonHopkinstoday at 9:09 PM

I developed the open source version of this game, called Micropolis.

Great to see more people building on it! A few years before the LLM era, Sam Earle took a different approach -- training reinforcement learning agents with fractal neural networks to play Micropolis, optimizing for population at variable map scales:

Using Fractal Neural Networks to Play SimCity 1 and Conway’s Game of Life at Variable Scales:

https://arxiv.org/pdf/2002.03896

His gym-city repo wraps Micropolis as an OpenAI Gym environment:

https://github.com/smearle/gym-city

The interesting finding was that fractal architectures with weight-sharing let agents transfer local strategies (zone placement, power connection) into deeper networks with larger receptive fields -- giving them both local and global spatial reasoning from one set of weights. But even those agents couldn't manage demand at larger scales, so the spatial reasoning problem discussed here has been hard for RL too, not just LLMs.

He described the project and we discussed it on the Micropolis repo in this issue:

https://github.com/SimHacker/micropolis/issues/86

He used the old PyGTK interface for his project:

https://github.com/SimHacker/micropolis/tree/master/Micropol...

These days I'd recommend the MicropolisCore repo instead. It's a C++ rewrite independent of any UI, compiles to WASM via Emscripten/Embind, and runs headless in Node or with any browser UI:

https://github.com/SimHacker/MicropolisCore

Live demo:

https://micropolisweb.com

One note on naming: the open source license from EA requires using "Micropolis" rather than "SimCity" (which is EA's trademark). The Micropolis Public Name License allows use of the original name:

https://github.com/SimHacker/micropolis/blob/master/Micropol...

This matters more than people think. Jeff Braun, CEO of Maxis, told me this story:

"Maxis was sued by Toho. We never referred to the name Godzilla, our monster on the box cover was a T-Rex looking character, but... a few magazine reviews called the monster, Godzilla. That was all it took. Toho called it 'confusion in the marketplace'. We paid $50k for Godzilla to go away. In all honesty, Toho liked Maxis, they said $50k was the minimum they take for Godzilla infringement."

So please: call the game Micropolis, not SimCity, or EA's lawyers may come knocking. And unlike Toho, EA and their Saudi investors and Jarod Kushner might want to use their bone saws on you, which are much worse than Godzilla.

Ozzie_osmantoday at 7:15 PM

Does anyone know how one can actually play SimCity (the original) these days?

show 3 replies
thenthenthentoday at 2:40 PM

Is there like a time lapse sorta view option? Super cool (also the name!)

show 1 reply
some_furrytoday at 3:54 PM

Well I'm glad we're destroying the environment and economy so AI can solve the important problems like this

show 1 reply
skeptrunetoday at 6:50 PM

It amazes me that people are still interested in MCPs.

show 1 reply
FrustratedMonkytoday at 1:28 PM

Is anybody planning to build this for Civilization? I'd like to see AI agents battle to build resources and to fight.

show 4 replies
_joeltoday at 2:39 PM

I fully approve of the name

Waterluviantoday at 5:05 PM

Ah yes, FART City. I remember learning about this in PLAN 165. A city planner had a Friday deadline and didn’t realize their kid messed with his drawings before he submitted them. Nobody noticed until the invention of the whirlybird.

hasperditoday at 4:13 PM

Fun! Any other games with REST API?

baqtoday at 1:40 PM

...I sense an animated svg of a pelican playing simcity benchmark is brewing somewhere

show 1 reply
gowldtoday at 4:19 PM

> LLMs are awful at the spatial stuff,

Which LLMs are you specifically referring to?

Are any of them trained with Micropolis data?

kittbuildstoday at 7:15 PM

[dead]

deadamericanstoday at 1:40 PM

[dead]