crucible
A C++ engine for very large simulations that replay exactly, on the desktop and in a browser tab.
What it's for
Factory, colony and strategy games where millions of things exist but only some of them move on any tick, and where multiplayer and replays need every machine to reach the same state. The targets: 10 million resident entities natively and 1 million in the browser, a quarter of them awake each tick, at 60 updates a second.
- 10 million natively: 6.1–8.8 ms at the 99th percentile on six threads of a laptop i7-13800H, against a 16.6 ms budget.
- 1 million in the browser: 0.97 ms a tick on average, 1.2 ms at p99, on one thread in Chrome.
- Exact replay: ten minutes of simulation (36,000 ticks, a million machines and 100,000 walkers) reaches the same state hash on 1, 6 and 20 threads, on replay, and in WebAssembly. All 216,000 per-tick checksums match.
Those are simulation benchmarks; rendering is measured separately.
How it's built
- An ECS with a sleep store. flecs runs the systems. The busy entity types sit in a store of its own that keeps awake and sleeping entities in separate column ranges, so a tick touches only what is awake.
- Deterministic by construction. A seeded RNG, an order-independent state hash, fixed-point math where it matters and Jolt physics in its deterministic mode. Input logs record only commands, about 7 bytes each, and per-tick traces find the first tick two runs diverge.
- One renderer, two tiers. WebGPU (Dawn natively, the browser's own on the web), with a GLES3/WebGL2 fallback. Shaders are written once in WGSL and translated for the fallback. Quality presets and an automatic render scale hold frame rate on weak GPUs.
- Networking. Lockstep, rollback and state replication over ENet, WebSocket, WebTransport or WebRTC. Two clients in lockstep or rollback cost about 7 kbps each way.
- Moddable. Games load ordered JSON data packs that add or patch definitions, and run sandboxed Luau scripts that take events in and send commands out.
- An editor agents can drive. A Dear ImGui editor for scenes and levels, plus an MCP server with 36 tools so an AI agent can build and change levels through the same document model.
- Tested on both targets. About 1,700 doctest cases in 165 test files run natively and as WebAssembly under Node, and the replay tests were checked to fail on purpose when lanes merge in a thread-dependent order.