RocketSim patches

Our changes to RocketSim, and how to test a new one.

5 min read

We run a copy of RocketSim with small fixes where it measurably differs from the real game. This page lists each patch and each candidate, how they're wired in, and how to test a new one. The evidence for each patch is on Sim vs real differences.

We change RocketSim only when a scenario reproduces a difference, repeated real captures agree, and RocketSim's history shows the behaviour wasn't intentional. Every patch must improve agreement with the game.

The vendored copy#

Upstreamhttps://github.com/ZealanL/RocketSim, branch v3-rust
Commit6cf55d33d070ff611a09564885dac230f66fd2f6 ("Bump version to 0.2.11")
Sourcethe published rocketsim 0.2.11 crate (its src/ is identical to that commit)
LicenseMIT, see vendor/rocketsim/LICENSE
Locationvendor/rocketsim/, one section per patch in PATCHES.md
Wired in by[patch.crates-io] rocketsim = { path = "vendor/rocketsim" } in the workspace Cargo.toml
  • One switch for everything. The [patch.crates-io] line replaces RocketSim for every crate: sim-runner, rlenv, the CLI, rlviser-rocketsim and the GPU simulator's oracle tools. Training and testing always use the same simulator.

  • Marked in the source. Every change carries a // PHYSLAB PATCH (Pn) comment.

  • Unpatched baseline: comment out the [patch.crates-io] line and rebuild.

  • Full diff against upstream:

    sh
    diff -ru ~/.cargo/registry/src/*/rocketsim-0.2.11/src vendor/rocketsim/src

P1: angular velocity quantization grid#

vendored not yet reported upstream

src/shared/quantize.rs, quantize().

Every tick, both the game and RocketSim round the ball's state onto a fixed grid. Upstream computes quantize_vec_ue3(ang_vel * BT_TO_UU, ANG_VEL_SCALE) * UU_TO_BT. Angular velocity is in rad/s in both Bullet and Unreal units, so the BT_TO_UU factor makes the grid 50× finer than the game's: 2e-6 rad/s instead of 1e-4. P1 quantizes ang_vel directly, matching the game's 1e-4 rad/s grid (truncate toward zero, then add 1e-5 away from zero).

Effect:

  • Rolling the ball for 10 s at 200 uu/s, the end position error drops from 6.59 to 0.017 uu (diagonal) and from 4.61 to 0.004 uu (along x).

  • The rest of the ball suite improves or holds. ball-long-chaotic (15 s) no longer diverges.

  • RocketSim's own replay benchmark (5 real matches, 709,990 car-ticks) rises from 91.08% to 91.85% of ticks within tolerance, with gains in every contact category (car–ball 75.48 → 78.17%, car–car 56.94 → 59.55%).

Why we think it's a bug: the scaling arrived with the first quantization commit (4c8bd9f, 2026-06-22, "Add quantization replication ... (WIP)"), was moved unchanged in fc61e1f, and bac6ebf corrected only the position rounding. No upstream issue, PR or test covers the angular grid. Full evidence: D1.

P2 (candidate): small boost pad radius#

candidate, not vendored not yet reported upstream

src/sim/consts.rs, boost_pads::CYL_RAD_SMALL.

A car picks up a pad when its origin is within the pad's radius, measured horizontally. RocketSim uses 144 uu for small pads; the game uses about 176 uu. P2 would change CYL_RAD_SMALL from 144 to 176. Big pads (208 uu) already match.

Evidence so far:

  • Real game: passing a small pad sideways, the game gave boost at every offset up to 174 uu, once in two at 176 and never from 178. RocketSim gave none at any of those offsets.

  • Replay benchmark: 91.85% → 92.24% of ticks within tolerance. Every contact category improves or holds (car–car unchanged), and so does every recording. Boost within 0.5 of the game's rises from 97.28% to 98.94%.

  • History: the radii came from a community video with the first boost pad commit (7e64819, 2023-02-15) and haven't changed since.

Left out: the game seems to check a position slightly behind the state after the step, but by an amount that varies between identical runs. Modelling it adds no physics gain.

Before vendoring: the training environment's exported-episode replay tests are bit-exact, so their episodes have to be re-exported with P2. Full evidence: D4.

Testing a new patch#

  1. Find the difference first: a real capture, a compare report or real-fidelity output. Write it up in Sim vs real differences before writing code.

  2. Make the change in a scratch copy, or in vendor/rocketsim/src/ behind a // PHYSLAB PATCH (Pn) marker.

  3. Measure it against the real game. Re-run RocketSim on the scenarios that show the difference and compare with the existing real captures; repeats are identical, so you don't need new ones. pwsh scripts/ball-suite.ps1 -SkipReal does the whole ball suite, and just real-fidelity gives the one-tick view. Run the same with the patch off for the baseline.

  4. Measure it on RocketSim's replay benchmark, which covers cars and real matches. Work in a scratch workspace, not .external/: copy rocketsim_test/ from the RocketSim checkout, point its rocketsim dependency at vendor/rocketsim, create the empty folder rocketsim_test/tests/rl_comparison_test/test_recordings (or build.rs panics), and put collision_meshes/ at the workspace root.

  5. Keep it only if it improves agreement and nothing gets meaningfully worse. Add a Pn section to vendor/rocketsim/PATCHES.md and to this page.

  6. Re-run what depends on RocketSim: just ci, just py-sync (rebuilds the Python extension) and just gpu-validate (the GPU simulator must still match RocketSim bit for bit).

Rejected candidates#

These were tried and dropped because they made agreement with the real game worse:

CandidateResult
Other ways of merging the ball's contact points with the arena: deepest, shallowest, fastest- or slowest-closing, first or last, depth- or speed-weighted means, no bounce on differing facets, bounce from one pointall worse than RocketSim's plain mean
The older ball–world solver (8d7a217^)worse
Old Bullet's (≤ 2.80) rule that zeroes the bounce for contacts older than 2 ticks, in three formsall worse: curved-ramp steps 94.73% / 94.73% / 98.68%, against 99.16% without
A patch for multi-facet bounce suppression (D2)not needed: the difference came from our replay tool

The merge-rule tests ran with an earlier, broken replay tool; even there RocketSim's rule scored best. Details: D2.