samcorcos/legatum
GamesAn open-source browser 4X strategy game with simultaneous turns, hex combat, and AI empires that play under the same rules as humans.
What it is
Legatum is a turn-based historical 4X strategy game in the Civilization tradition, written in Rust and compiled to WebAssembly so it runs in a browser. You found cities, research 45 technologies across nine eras, raise armies, negotiate alliances and wars, and race rivals for public victory points. A full game is described as taking three to six hours, and it supports solo play against one to seven AI empires plus online multiplayer and a two-human co-op mode against six AI empires.
The design puts emphasis on simultaneous planning: every empire submits orders at once and the engine resolves them in fixed stages, so nobody waits on a slow player. Yields, costs and combat odds can be expanded into breakdowns, attacks show a forecast before committing, and the victory race is visible from turn one. The AI at Easy, Normal and Hard does not receive extra yields, cheaper costs or stronger units; difficulty changes its decisions only.
Internally the project keeps the rules in one deterministic Rust engine, legatum-core, with the browser interface, a simulation runner and the AI as separate hosts around it. A turn is treated as a pure function of state, orders and a seed.
Play in the browser
The fastest route is the hosted build at playlegatum.com: no installation, single-player and online multiplayer both work there. It targets laptops and desktops (tablets work; phones are not a target yet), is tested most in Chrome, and the first load is about 7 MB. Progress autosaves in the browser, and Menu → Save to file produces a copy you control.
On a first game, send your starting units exploring, queue production in the capital, and use the forecast cards before ordering attacks. The in-app How to Play covers the rules, and the code-checked rules reference documents how systems work.
Build from source
Building requires rustup (installs Rust 1.98.1, rustfmt, clippy and the WebAssembly target), wasm-pack 0.15.0, Node.js 22, npm and Python 3. The first engine build is fully optimised and typically takes 5 to 15 minutes; later builds are much faster.
git clone https://github.com/samcorcos/legatum && cd legatum
nvm use
scripts/build-wasm.sh
cd app && npm ci && npm run dev
The dev server then serves the game at http://localhost:5173. scripts/build-web.sh produces the static site in app/dist, and scripts/build-wasm.sh --dev gives a quicker, slower-running engine for a first look. If downloading wasm-opt fails, LEGATUM_WASM_NO_OPT=1 scripts/build-wasm.sh skips that step.
To run AI-only simulations for balance and pacing measurements:
cargo run --release -p legatum-sim -- --games 20 --players 4 --map-size small --label smoke
The architecture notes describe the crate map, the turn pipeline and the determinism rules.
Online play
Multiplayer needs no server program you operate. The host's browser tab runs the game and the AI, while a small Cloudflare Worker relay keeps the list of open games and passes messages between players. Everyone must run the same version, the host's tab must stay open for the session to continue, and a game holds up to eight players. Hosts can save to file and later host from that save so players rejoin their old seats; the plan is documented in online-play.md.
Constraints and caveats
- The project is pre-release and changing fast. Saves from an older rules version are not migrated; the hosted site may reopen them in the build that made them for up to 30 days, otherwise the build rejects them with a message.
- The web build is the only supported way to play. It is smoke-tested in Chromium before each deploy; other browsers and the Rust crates on other systems are expected to work but are not routinely tested.
- The hosted browser version uploads every game record for AI tuning and bug finding. Names are replaced before upload, and no accounts, cookies or tracking are used, but there is no switch to disable uploads in the hosted build; the privacy section lists exactly what is sent. Builds from source upload nothing.
- Balance is unfinished. A November 2026 simulation census cited in the roadmap measured a large win-rate spread between factions, and the roadmap states the target gap has not been met; treat faction strength as actively tuned.
- The AI is explicitly not yet at strong-human level and is the first roadmap priority.
- Code is MIT licensed; the AI-generated art is offered under CC BY 4.0; music and sound effects are third-party works under a mix of CC0, CC BY-SA, CC BY and GPL terms, listed in the audio credits and third-party notices.
HotRepo's take
Legatum entered HotRepo's new-project record for Rust on 2026-11-25, gaining 5 stars and 3 forks in the tracked window and reaching 108 stars and 35 forks in total. The same day, an HN thread about the maintainer's AI-assisted development drew 36 comments, and the discussion split over whether a side project built largely with coding agents says anything about his day job. That attention is about how the game was made and who made it, not about the game's own measurements; the project's determinism reports and simulation logs are the place to judge the engine and AI claims.
Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.