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:

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.
Play