Planet Box
An ambient planet conquest simulation where AI factions compete for control of procedurally generated star maps.
Built in response to a creative coding prompt at Recurse Center:
- Sandbox + Multithreading — Each planet is its own sandboxed AI running in a dedicated Web Worker thread, making independent decisions in parallel.
- Resource Leaks + Web Crawlers — Planets grow units over time and leak their excess into space to conquer neighbors. AIs discover the galaxy incrementally as they expand, crawling along graph edges to reveal new planets.
- Floating Point — Production uses fractional accumulation rates, so planets generate units at precise but non-integer speeds.
How to Play
This is a spectator experience — just watch! Each faction uses a different AI strategy:
- Aggressive — Sends units early and targets weak enemies.
- Defensive — Accumulates near capacity before striking.
- Expansionist — Prioritizes conquering neutral planets.
- Cautious — Only attacks with a 2x unit advantage.
The game resets automatically when one faction conquers all planets or after a 5-minute stalemate.
How It's Built
Two standalone Rust crates compiled to WebAssembly:
- planetbox — Game engine and renderer built with macroquad. Owns all game state and simulation logic (production, combat, fleet movement, captures).
- planetbox-ai — Stateless AI decision module built with wasm-bindgen. Each planet gets its own Web Worker with an isolated WASM instance.
- JS bridge — A thin JavaScript layer that routes messages between the macroquad game engine and the AI Workers. Manages Worker lifecycle, buffers AI decisions, and handles edge cases — but contains no game logic.