Show HN: A self-running space economy SIM in Rust and Bevy
Posted by kalcode 3 days ago
I built this with Claude cause I always wanted to tinker with a simulation economoy and I love space themes.
A space-economy sim where nothing is scripted. A few hundred autonomous ships each run their own planner. Some chase the best trade route, take a delivery contract, refuel, retrofit at a shipyard, or dock so the crew can rest before morale tanks.
Markets price everything off supply with shortage-urgency multipliers, factions tax and subsidize, populations migrate when they're unhappy, and stations that go broke get abandoned and rot.
It started as an Elixir/Phoenix prototype, but the BEAM scheduler struggled on Windows gaming PCs, so I had Claude rewrite the engine in Rust.
The sim core is pure, synchronous, IO-free (its own hecs ECS), and the Bevy client embeds it directly as a library, sim and renderer share one world with zero marshalling. Ship AI is a GOAP planner over a world state; ships replan mid-flight when a better option appears. ~485 agents today at p50 ~10-20ms/tick, architected to push toward 100k+. Single native binary, bundled SQLite, no runtime deps. Getting into 100k has been a struggle, but I have pushed it into the thousand and it was running fine.
It's a sandbox, not a game yet, there's no objective yet, and I'm not actively pushing it toward "shippable." Anyone can fork it and take it over. Or it can stay as some type of AI slop, but part of me thinks it is already in a pretty good shape for a simulation use for various games or ideas.
(Full disclosure: a lot of this was built pairing with Claude. That's how I had the bandwidth to take it this far. Happy to talk about what that workflow actually looked like.)
Comments
Comment by sulam 3 days ago
Comment by awhitty 3 days ago
Comment by kalcode 3 days ago
But I did think, one station info per station probably also did not make sense, technology-wise, so I thought expanding it worked.
The faction system was my answer to what makes ships or planets' goals go beyond their immediate needs, and factions came naturally next. They want to make money and shift priorities to do it through incentives. Like subsidies almost.
I was hoping/thinking they (factions) could escalate to blockades, monopolies or just more supply control, skyrocket prices and events combat to hold choke points, blockades or sanctions. That way that agents FSM is focused on those goal oriented actions and ships can focus on their well being plus their factions incentives, and the crews needs handle immediate needs.
Does that make sense? (Terrible at proofreading)
Comment by eightysixfour 3 days ago
I miss EV so much. I've always wondered if an MMO version of it, like EVE but with the interface/graphics of EV, would work.
Comment by Levitating 3 days ago
Comment by lantry 3 days ago
makes me wonder if ECS will ever catch on outside the gaming industry. not sure if it's really the right architecture for web SAAS. Might be interesting to rewrite some big piece of software with ECS.
Comment by kalcode 3 days ago
So their are apps that do use similar or ECSs architecture under the hood, it is just more problem related not a solve everything solution.
Comment by lantry 2 days ago
Comment by teravor 3 days ago
Comment by echelon 3 days ago
I keep seeing Mr.Doob post amazing stuff in Threejs and the vibe coding scene blowing up with all kinds of generative work, and I feel really drawn to it.
Do you feel like Claude gets Bevy well enough? I know it kicks ass at Rust, but Bevy is relatively niche still.
Do you feel like Bevy is pretty performant?
Comment by lantry 2 days ago
I can't really comment on the performance. I haven't noticed any performance issues for the things I'm doing.
Comment by killix 2 days ago
Comment by Sharlin 3 days ago
Comment by qwertyastronaut 3 days ago
X4 Foundations just got a big update if you’re looking for a game built around this industry sandbox idea.
Comment by natebc 3 days ago
I came across this recently ... hints of Tradewars from the good old days.
Comment by aliasxneo 3 days ago
Comment by zipy124 3 days ago
Comment by hersko 3 days ago
I think it would be cool if you can host a simulation and enable online viewers. Have the simulation accessible from a website (god-mode disabled of course), and have an agent generate some sort of newspaper or news bulletin of interesting things that happen.
Comment by dangoodmanUT 3 days ago
Are we all having this idea?
Comment by ivanjermakov 3 days ago
Comment by digilypse 3 days ago
Comment by kalcode 3 days ago
Bevu/Rust just made it easier to brute force that scaling, since they have smaller footprints (overhead?)for each thread/process spawning.
Comment by spacecadet 3 days ago
The whole thing originated years ago to see what LLMs were capable of. Just spent a chunk of my Fable access hacking away at it. Is it intended to be 100% realistic, no. Its more art, tho I do try to lean into physics...
Comment by nine_k 3 days ago
Comment by chadcmulligan 3 days ago
Comment by thomascountz 3 days ago
Comment by nixpulvis 3 days ago
Comment by prios8 2 days ago
Comment by greenleafone7 3 days ago