🚀Rust + Bevy Powers Self-Running Space Economy Simulator
A Rust/Bevy project simulates a bustling space economy in one binary
TL;DR
The Space Project uses Rust and Bevy to simulate hundreds of autonomous ships trading, mining, and more. It runs in a single native binary with no runtime dependencies.
The Space Project is a Rust/Bevy-driven simulation that models a bustling space economy complete with trading, mining, and ship bankruptcies. What makes it unique is its ability to run everything in one native binary without any runtime dependencies. As an autonomous system, every ship acts as an agent with credits, crew, fuel, cargo, and decision-making capabilities based on the Goal-Oriented Action Planning (GOAP) model. This setup not only simplifies deployment but also ensures deterministic behavior across all entities involved. The simulation is optimized for scale, currently handling around 485 live agents within a tight performance budget of 125 ms.
Key Points
The simulation runs ~485 live agents (282 ships · 93 facilities · 27 populations · 8 factions · 60 celestial bodies) within a 125 ms budget, ticking at p50 ≈ 10-20 ms.
Each ship is an autonomous agent with credits, crew, fuel, cargo hold, and GOAP planner deciding next actions; facilities run production recipes, degrade over time, self-repair, level up 1-10, restock from local markets, and get abandoned when chronically broke.
Factions collect taxes on member facilities, post subsidy contracts for chronic shortages, fund construction of new facilities where demand is unmet, and hold pairwise relations; populations consume food and fuel, produce labor, post food/passenger contracts under stress, migrate to happier systems when sentiment collapses.
The engine (sim_core) is pure synchronous Rust with no async imports; the Bevy client embeds it directly as a library, so simulation and renderer share same ECS world without marshalling between them. The whole project runs in-process.
Persistence: everything flushes to SQLite; sim resumes from exact tick it left off. Spatial LOD: distant ships tick less often (with rate-scaled state changes) to optimize frame budget.
Why It Matters
If you're working on a complex simulation with autonomous agents, The Space Project's architecture offers valuable insights into how Rust and Bevy can simplify deployment while maintaining deterministic behavior. For example, the use of SQLite for persistence and direct embedding of sim_core in client_bevy ensures seamless integration without performance overhead.
Frequently Asked Questions
Why does this matter?
If you're working on a complex simulation with autonomous agents, The Space Project's architecture offers valuable insights into how Rust and Bevy can simplify deployment while maintaining deterministic behavior. For example, the use of SQLite for persistence and direct embedding of sim_core in client_bevy ensures seamless integration without performance overhead.
What happened?
The Space Project uses Rust and Bevy to simulate hundreds of autonomous ships trading, mining, and more. It runs in a single native binary with no runtime dependencies.
Comments
Be the first to comment
Enjoyed this article?
Get it daily. 7am. Free. Reads in 5 minutes.
Join 2,179 builders reading daily.