MMMatthew Mercado
All case files

Case 03SELF-PLAY ML & RUST SIM

YomiBench

An open-source bot arena, self-play training harness, and in-game AI mod for the fighting game Your Only Move Is HUSTLE, built with the developer's permission. HustleBot previews every pair of moves, solves each simultaneous turn as a payoff table, and learns from 812,000+ self-play games powered by a bit-exact Rust rewrite of the game's simulation. Anyone can play the trained bot straight from the game's own menu.

Role
Creator
Timeline
2026 – Present
Status
Live and growing
1,800×
Peak Rust preview speedup over Godot (240×+ single-thread)
12.45M
Simulation ticks verified bit-exact against the real game
812,000+
Self-play games generated across 20 generations
432 KB
Trained value net running live in-game on CPU
YomiBench interface

01 Why build it

In Your Only Move Is HUSTLE both players lock in a move without seeing the other's, so every turn is a guessing game and optimal play is a mix, not a single move. That makes it an ideal testbed for game-theory search plus learning—the AlphaZero recipe—with strict, pre-registered promotion tests. The catch was speed: previewing turns through headless Godot took ~12.5 ms each (~3 hours for 100 games), making large-scale self-play impractical until I rewrote the simulation core in deterministic, bit-exact Rust.

02 Training loop

One generation, start to finish.

  1. Preview

    For each pair of candidate moves, the simulator plays the turn out in parallel and returns the resulting game state.

  2. Solve

    The bot scores those positions into a payoff table and solves it with regret matching and a double oracle for a mixed strategy.

  3. Self-play

    A 4-machine fleet plays the current best against itself, recording every position, candidate set and solved strategy.

  4. Learn

    A compact PyTorch value net trains on 17.5M+ positions to predict who wins from a state, checked on a held-out slice.

  5. Gate

    The new net plays the current best in seat-swapped pairs with a pre-registered, staged test. Only a clear win promotes it.

03 The engine rewrite

Why self-play needed a native simulator.

Headless Godot proved the loop worked, but IPC and scene-copy overhead capped throughput. Hand-porting the simulation to Rust (kept private with the developer's permission) unlocked 50,000+ games a day on home hardware while staying bit-exact with the real game.

MeasureBeforeAfter
12-tick state preview12.5 ms in headless Godot7–53 µs in Rust
100 full value-net games~3 hours on one Godot server~2.7 min on 4-node fleet
Preview-vs-step fidelity~99.0% (Godot copy drift)100% bit-exact
Live fleet throughputSerial single-engine search1.47B previews / hr

04 Inside the system

From game-theory search to a bit-exact Rust engine.

  1. The real game as an engine

    An open-source GDScript mod turns headless copies of the player's own Steam install into engine servers speaking a JSON-lines protocol with batched previews and rollouts. Nothing from the game lives in the public repo, and a toy engine lets anyone run the harness without it.

  2. Search plus learning

    Each turn's moves have continuous aims and timings, so the bot builds a finite candidate set from the game's action panel, previews the pairs, and solves the payoff table with regret matching and a double oracle. A Rust build of the solver's inner loop is 30–130× faster with bit-identical answers.

  3. A bit-exact Rust simulator

    To scale self-play, I hand-ported the simulation into ~43,000 lines of deterministic Rust (private, with the developer's permission) with PyO3/NumPy batch bindings and fused Rust neural-net inference. It reproduces fixed-point math, RNG, and engine quirks with zero divergences across 12.45M ticks, 1.04M turns, and 5,427 matches across all five characters, while cutting heap allocations by 88.6%.

  4. Fleet-scale self-play on home hardware

    Four heterogeneous consumer machines (desktops, Mac, mini-PC) run parallel batch workers sustaining ~2,180 full games/hour and ~1.47B simulated previews/hour (~407k/sec). Each GPU training run fits a compact value net on 17.5M+ positions across 20 generations and 812,000+ self-play games.

  5. Honest promotion

    Every generation must beat the current best in a staged, seat-swapped test with 95% confidence intervals and a per-matchup floor, decided by rules fixed before the first game. Public ratings come from a Bradley–Terry fit over every published result.

  6. Play it, or beat it

    Trained models export to a ~432 KB CPU-runnable checkpoint and drop straight into the real game via a Windows mod that adds Multiplayer (vs bot) while refusing online lobbies. The Arena also accepts outside submissions under one fixed thinking budget, so ratings measure the bot rather than the hardware.

05 The site

06 Built with

  • Rust
  • Python
  • PyO3
  • PyTorch
  • NumPy
  • GDScript
  • GitHub Pages
Next case fileEnterprise AI Agent Tooling