Abstract
The Clash-Royale Simulation Suite is a deterministic, integer-only Rust environment that models the game as a ground-truth testbed for agent evaluation and reinforcement learning. A fixed-point tick loop runs at 20 ticks per second and is bit-reproducible from a seed, so a recorded match replays frame-for-frame. It models 125+ heterogeneous entity types declared in JSON policies rather than hard-coded in Rust, which keeps the rule set auditable and lets the same engine drive both single-match RL and large headless evaluation batches.
Around that core sit two supporting systems: a perception pipeline that reads real match frames into card classes over ONNX Runtime with CoreML/ANE acceleration, and a data engine that mines and de-duplicates training frames at video-rate. The whole crate is exposed to Python via PyO3, and its own source is kept honest by a code-QA layer wired to an MCP code knowledge graph. Every headline number below is a measured result with its measurement context stated, not a projection.
The Problem
Evaluating an agent - or training one with RL - needs an environment that is fast, reproducible, and gives an unambiguous ground truth for what actually happened on each step. A live game client provides none of these: it is non-deterministic, wall-clock bound, and its internal state is not observable. Floating-point physics makes the problem worse, because rounding differences accumulate across ticks and two “identical” runs diverge, which destroys the paired comparisons that credit assignment and regression testing depend on.
The suite answers this by rebuilding the mechanics as an integer-only state machine. There are no floats on the hot path, so a match is a pure function of its seed and action stream. That single property is what makes 10,000 matches comparable, makes a regression corpus meaningful, and lets telemetry be trusted as ground truth rather than an approximation.
System Overview
The simulator is organised as a data-driven core: entity behaviour lives in JSON policies, and the Rust engine interprets them against an integer world state each tick. The “125+ entity types” headline is a deliberately conservative floor on distinctly-behaving units; the JSON data underneath it currently declares 214 characters, 108 buildings, 27 spells, 169 projectiles and 140 area-effect objects. The diagram below is the suite’s own architecture figure.
The Deterministic Tick Loop
Integer determinism
State advances at 20 tps in fixed-point integer arithmetic. Because the loop contains no floating-point operations, the same seed and action sequence always produce the same trajectory, bit-for-bit, across machines. This is the contract every other component leans on: recorded matches replay exactly, paired A/B rollouts are genuinely paired, and any divergence in output is a real behavioural change rather than numerical noise.
Scale & throughput
Two measured regimes bound the engine, both from the most recent benchmark, taken after the engine’s mechanics expanded, on a single Apple M1 Pro core. At 20 tps a tick has a 50 ms budget, and each regime is quoted against it. In the stress regime, a single match holding 3,000 concurrent entities sustains a p99 step time of 42.5 ms - 85% of budget. In the batch regime, 5,000 matches stepped in parallel have a batch p99 of 24.743 ms - 49.5% of the same budget - and 10,000 matches cost 3.94 µs each (mean per match, per tick), with a batch p99 of 53.151 ms, which is over the budget. Both batch points are measured directly. The 9,445-match single-core ceiling at 20 Hz is an estimate from linear interpolation between those two measured points, not a direct run at 9,445.
The defensible claim is not that batching is free: the batch cost grows with the number of matches and crosses the 50 ms tick budget between 5,000 and 10,000 of them. An earlier, smaller engine snapshot measured the 10,000-match batch at p99 = 36.7 ms; the figures on this page are the later benchmark of the current, larger engine, which is the one that matters for current-engine claims.
Perception Pipeline
To connect the simulator to real play, a perception stage reads match frames into card classes. The classifier is a MobileNetV3-Small reaching 97.89% validation accuracy. The inference path was rewritten from Python into Rust over ONNX Runtime with CoreML/ANE acceleration. In batch mode - every frame sends a fixed [5, 3, 224, 224] tensor that CoreML compiles once for the ANE - that is ~9 ms per card and 22.3 FPS over an 8,702-frame match.
A second binary, gatekeeper mode, puts a per-slot state machine in front of the model. Each of the five hand-card slots is reduced to an 8×8 RGB fingerprint; a slot locks once inference returns ≥90% confidence and unlocks when its fingerprint drifts by more than 6%. Over the same match it skips 49% of inference calls - 21,304 of 43,510. Offline it is slower wall-clock, 11.6 FPS against batch mode’s 22.3, because variable batch shapes make CoreML recompile its execution plans. It pays off where call count, not throughput, is the cost: a live stream, a shared accelerator, a per-call API.
The Data Engine
The classifier is only as good as its training set, so the suite includes a data engine that mines frames from match video. It processed 440,056 frames in 33 minutes - about 221 FPS - using zero-copy crops and rayon parallelism, then applied near-duplicate filtering for a 61.1% dataset reduction. A Real-ESRGAN upscale and a 4-stage augmentation pass expand the survivors into a ~300k-image training set.
Code-QA & Knowledge Graph
A codebase this size - ~88,000 lines of Rust (87,876 measured on 2026-06-11: roughly 50k of production code spread over the nine files at the crate source root, plus about 37.9k of extracted regression tests) - needs its own quality discipline. It is wired to an MCP code knowledge graph holding roughly 28,675 nodes and 35,340 edges over the full crate as of the same date, which answers blast-radius and call-chain questions before a change lands.
Correctness is pinned by 1,518 #[test] functions across 59 mod *_audit_tests blocks, gated by CI. Those tests were lifted out of the source files into src/tests/ on 2026-05-17, so they are no longer inline, and they trace back to 595 git-tracked audit files - 400 of them entity audits over 248 distinct cards.
Card data is checked against outside sources too: the Clash Royale Fandom MediaWiki API, through a 181-page offline cache, and 60+ creator-video transcripts for newer cards the wiki covers thinly. Across 10 hero cards, the transcripts surfaced 4 retroactive closures and 6 divergences still pending frame capture - none of which the wiki and JSON alone caught.

Telemetry & Replays
Because every match is deterministic, telemetry is exact: a seed plus an action stream fully reconstructs a game, so the dashboard replays and inspects any recorded match without storing frames. Capturing the full state of a tick costs about 5 µs (measured 2026-05-19), so instrumentation stays cheap relative to the 50 ms tick budget. The live telemetry dashboard is available at clash-telemetry-web.vercel.app.

Limitations
- The simulator is a model of the game, not the game. The 125+ entity types are encoded from observed behaviour; edge-case interactions the JSON policies do not yet capture will diverge from live play.
- The 97.89% figure is validation accuracy on the mined dataset, and the perception throughput (22.3 FPS, ~9 ms/card) is measured on Apple CoreML/ANE hardware - other targets will differ.
- Throughput numbers describe the headless engine. Real-time play adds perception and I/O cost outside the tick loop itself.
- The stress and batch timings on this page (3,000 entities, 5,000 and 10,000 matches) come from the most recent benchmark, taken after the engine’s mechanics expanded. The state-capture cost below was measured earlier, on 2026-05-19, on a previous engine revision. The published write-ups linked below predate both and still quote the earlier revision’s ≈ 2.7 µs per-match number; where they disagree with this page, this page is the newer measurement and the write-ups have not yet been regenerated.
- The suite is not affiliated with or endorsed by Supercell; it is an independent research and engineering project.
Conclusion
The Clash-Royale Simulation Suite turns a fast, chaotic game into a controlled instrument: an integer-only, bit-reproducible core that runs 5,000 parallel matches inside the 50 ms tick budget (24.743 ms p99) and 10,000 at 3.94 µs per match (53.151 ms batch p99), a Rust perception path that reads real frames at 22.3 FPS, and a data engine that feeds it - all held together by a code-QA layer that treats its own source as something to be measured, not trusted. It exists to make agent evaluation and RL over this domain honest and repeatable.
Source, write-ups, and the live dashboard are linked below.