spire-mentor

A fast, bit-exact Slay the Spire 2 engine in Rust, and an AI that plays it

spire-mentor reimplements Slay the Spire 2 in Rust, checks itself against the game's own code after every action, and runs fast enough to train an AI on billions of its own decisions. That AI, Instinct, is one neural network that plays whole runs with no search and wins 80% of Ironclad runs at Ascension 10 in the simulator. Two front ends show it thinking: a browser workbench and a mod for the real game.

The browser workbench in the act-3 boss fight (Ironclad vs the Queen): the best card, Dominate+, carries a 95% win badge, and the machine-reasoning panel ranks every legal move by value and visits.
The browser workbench in the act-3 boss fight, here with the combat search as the advisor: it marks the best card with its win chance, and the machine-reasoning panel ranks every legal move.

Overview

Six pieces, each usable on its own:

Engine

Rust, deterministic, the whole game: five characters, ~580 cards, ~300 relics, three acts. Built for speed (1.3 M actions a second on one core, 31 M on a 24-core server; about 1,500× the shipped game's throughput per core), checked against the game's own code after every action, and usable from Python.

Parity harness

Runs the game's own assembly headless and checks the engine against it after every single action, plus a fuzzer that hunts for divergences.

The AI

Instinct: one transformer that makes every decision of a run, fights included, in a single forward pass with no search. Trained end to end by self-play in the simulator, it wins 80% of Ironclad runs at A10 and 53 to 72% with the other five characters. The earlier agent, a chance-node MCTS for fights plus a PPO run policy per character, won 21% of Ironclad A10 test runs where Instinct won 81%; it remains as an analysis tool and a fallback.

Workbench

The game in your browser, on any platform: rewind and branch, Instinct as advisor or player, autobattle, post-run blunder review, the combat search tree, state import from the real game, and SimLab.

Spire Mentor

A mod that puts the AI inside the real game as a coach, an autopilot and a rewind button.

Extraction & wiki

just import-game decompiles your copy and extracts data, art and sound; a generator builds a static wiki.

The engine

sts2-rs re-implements the game's rules in Rust, for game build v0.111.0 by default (the stable v0.111.1 plays identically; the v0.113.0 beta with its sixth character, The Fool, and the older v0.107.1 are also modelled), with the game's decompiled C# as the specification for every mechanic. It is not an approximation: the random number generator is a hand port of the game's MegaRandom (a Xoshiro256** generator with Splitmix64 seeding, which replaced .NET's System.Random after v0.103.x), and every RNG stream is consumed in the game's order. A seed yields the same map, the same card rewards, the same shuffles and the same monster rolls as the real game.

Content implemented in the engine
KindCountNotes
Characters5Ironclad, Silent, Defect, Regent, Necrobinder
Cards580card ids incl. colorless, status and curse cards
Relics297
Potions63
Powers272
Monsters121with their intent state machines
Events69incl. the Ancients
Acts34 act models (act 1 rolls Overgrowth or Underdocks)

Performance

Full benchmarks → one core against the whole machine, the shipped game compared five ways, Instinct's training and inference speed, the search, the hardware, and two other Slay the Spire 2 simulators.

MeasurementResult
Random-play fights per second, one core59,400
Engine actions per second, same fights, one core1.30 M (766 ns each)
The same on the whole machine (24 cores, 48 threads)1.41 M fights/s
31.0 M actions/s
Against the shipped game run headless, best measured throughput1,500× per core
2,430× whole machine
Against the shipped game, CPU time per action2,970× (2,250× its game thread)
Against the previous engine (12 Oct 2026), same fights2.25×
Against two other simulators, same random-play fights, one core3.13× faster than sansb
sts2core 1.56× faster
Instinct's training, one machine with four RTX 30908,000 decisions/s on average
9.0 B decisions in 313 h
Instinct in the browser (WASM with SIMD), a whole run8.6 ms per decision
The combat search behind the browser hint, 1,000 simulations13.7 ms native
18.4 ms WASM in Chromium
The same search at the hint's default 2,000 simulations, WASM in Chromium39.9 ms
Search on an Act-1 boss, 8,000 simulations (the advisor's setting then; heuristic playouts)275 ms on 1 thread
39.6 ms on 8

The engine and search rows were measured on 14 October 2026 on one AMD EPYC 7443P server (24 cores, 48 threads, Linux) on a quiet host, with plain release builds; medians of interleaved runs. The Instinct rows are from November 2026 and are described on the benchmarks page. The fights are random play: Ironclad's starter deck and Burning Blood against each of the 22 Act-1 Overgrowth encounters in turn, 22.0 actions per fight on average (an action is a card play or an end of turn). One core means one process on one physical core with its second hardware thread idle. The shipped game is its own assembly run headless by the project's harness on the same fights. One game process spends most of its time asleep in the harness's 1 ms polling, so the fair comparison runs many game processes at once, the best counts measured: 16 on one core, 192 on the machine. Earlier versions of this page said 23,000×: that was the wall time of one cold game process per fight, a different measurement, explained on the benchmarks page. Both other simulators are combat only. sansb/sts2-sim (game build v0.111.0) is certified against checksums the real game writes, and its review solver searches the true state by design; the 3.13× has our relic switched off, as Burning Blood is inert there. lain-wood/sts2core is effectively Ironclad only, with partial content and its own RNG, and its live solver is given the true draw-pile order. The comparison is random play, with no search involved (details). Method: 2026-10-14-benchmarks.md.

Workspace

A cargo workspace of fifteen crates: sts2-core (state, hooks, damage, powers, RNG), sts2-content (every card, relic, potion, monster and event), sts2-e2e (Instinct: its tokenizer, its network and the training rollout loop), sts2-mcts, sts2-runai (run arena, seed panels, the version 1 nets with ONNX inference), sts2-advisor (the mod's advisor process), sts2-cli (REPL, replays, sweeps), sts2-wire, sts2-py (PyO3 bindings), sts2-bench, sts2-workbench + sts2-workbench-wasm, and helpers. 7,000+ Rust tests, plus a cargo-fuzz target on the combat step.

Parity with the game

Claims of accuracy are cheap, so the project checks them mechanically. The game's own C# assembly, taken from your copy, is IL-patched and run headless with Godot stubbed out. The engine and that oracle then play the same seed with the same actions, in lockstep:

seed + actions
game's C# assembly
headless oracle
Rust engine
sts2-rs
compare after every action:
HP, block, energy, powers · ordered draw/discard/exhaust piles · hand costs · relics · monster state
first divergence → bucketed (draw order, hand cost, …)
  • Fuzzed combat parity on seeds covering every card (base and upgraded), every card against every arena, pairwise hook interactions and 30-turn fights; the full tier runs 5,000 seeds. In the last full sweeps Ironclad was clean on all 6,104 fights (June 2026) and the other four characters on 99.4–99.8% of about 5,750 each (July 2026), with a known tail still open.
  • Whole-run parity 1,232 of 1,250 runs clean (July 2026; five characters at Ascensions 0, 2, 5, 8 and 10): map generation, event pools, rewards, shops and the run state carried between acts. The runs use a random policy, so most end in Act 1.
  • No full sweep has run since July 2026, and the engine has changed since. Checks against fights recorded from the real game, with the game's own checksums, are planned but not done.
  • Freshness gates refuse to compare against a stale engine build or a stale oracle: a source hash is compiled into the Python extension and checked at load.
  • The browser build is held to the same standard: 46 recorded scenarios, 8,454 requests, zero divergences between the WASM workbench and the Python one.

Details: parity-suite.md.

The AI

The project's AI is Instinct, a single network that plays whole runs without search. Read more: How the AI plays (what it sees and decides, hidden information, the network) and How it's trained (PPO over whole runs, compute, the campaign, evaluation).

Instinct: one network, no search

Instinct is a transformer (4 blocks, width 256, about 6 million parameters) that makes every decision of a run: card plays, potions and targets in a fight, and paths, card rewards, shops, events and rest sites between fights. Each decision is one forward pass. It sees only what the game shows a player, never the draw order or a monster's next roll. It was trained end to end with PPO by self-play over full runs in the simulator; after a short warm start from the earlier nets there is no teacher, no human data and no search in the loop. One net plays Ironclad, Silent, Defect, Regent and Necrobinder on game build v0.111.0; The Fool, new in v0.113.0, has its own net trained on that build. Instinct is the mod's brain; where its nets don't cover a run, the search answers instead. In the workbench you can pick either brain.

Instinct: simulator win rate at Ascension 10, greedy play, no search
CharacterWin rate
Ironclad79.9%
799 / 1,000
Defect71.8%
359 / 500
Regent65.8%
329 / 500
Silent60.8%
304 / 500
Necrobinder52.8%
264 / 500
The Fool (v0.113.0, own net, 850 M)59.4%
297 / 500

The shipped five-character net is its training lane's 4.5-billion-decision milestone (shipped 23 November 2026); the lane is still training. The Fool's net is its own lane's 850-million milestone, trained mostly on Fool runs. Greedy play means the net always takes its top choice. Each lane measured its net with its own evaluation on its DEV seed panel (seeds from 160,000,000, Act 1 rolled between Overgrowth and Underdocks) in the engine it trained on; a cell's 95% interval is about ±4.4 pp (±2.5 pp for Ironclad). The nets are trained with an out-of-combat potion menu that the shipped hosts leave off. Records: sts2-pycli/data/e2e/*.provenance.md.

Instinct against the search agent: Ironclad, Ascension 10, the same 4,000 sealed test seeds
AgentWinsWin rate
Instinct, Ironclad-only net (9.0 B decisions), no search3,255 / 4,00081.4%
Search agent: run policy cont300_it1150 + MCTS, 1,000 simulations (4,000 at bosses)846 / 4,00021.2%

The pre-registered, single read of the first Instinct training campaign (4–17 November 2026, 313 hours on one machine with four RTX 3090s, 9.0 billion decisions, game build v0.111.0): 81.38% against 21.15%, +60.2 pp paired (95% interval +58.5 to +61.8). The search played at the promotion gates' budget, not the advisor's larger one. An earlier checkpoint of that campaign was the starting point of the five-character lane above. Write-up: docs/experiments/2026-11-17-ironclad-e2e-campaign-report.md.

On the game's own code. An earlier milestone of the five-character net (2.5 B) also played 300 Ironclad A10 seeds twice: in the Rust engine and through the game's real assembly run headless, with the game's own RNG. It won 79.7% in the engine and 78.7% on the real game code (31 seeds differed, 17 against 14, p = 0.72), so the simulator's numbers carry over. Write-up: docs/experiments/2026-11-21-spire-bench-paired.md.

Version 1: search plus a run policy

Until November 2026 the project's AI was a different design: a chance-node Monte-Carlo tree search played every fight, and a transformer trained with PPO, one per character, made the choices in between. It won 21% of Ironclad runs at Ascension 10 on the seeds where Instinct's first net won 81%. The search is still part of the workbench and the mod: it draws the search tree and the principal line, gives win estimates, powers the reviews and SimLab, and answers where Instinct cannot.

Its documentation is kept as it stood: the version 1 site, with the win rates of its champions by ascension level, the real-game runs through the mod, how the search works and how the run policies were trained and promoted.

Browser workbench

The engine compiled to WebAssembly, running in a Web Worker behind a React UI styled after the game. No server: saves live in IndexedDB and the site installs as an offline app. Without the game it runs with the real card text and placeholder art; just import-game fills in the real art and sound from your copy.

What you can do

  • Play any character, seed and ascension yourself, or let the AI play a whole run while you watch, then take over at any point. You pick the brain: Instinct, or the version 1 search agent.
  • Rewind and branch any decision; the run tree keeps every fork, with named saves.
  • Ask the AI: a hint for the current move, rankings for card rewards, shops, events and rest sites, "play best", from Instinct or from the search. With the search you also get the full search tree, and the live coach flags a weak move the moment you make it.
  • Autobattle: play Slay the Spire 2 as an autobattler. You make the run-level decisions (paths, cards, shops, events) and the AI fights every combat; each stop shows what changed since the last one.
  • Review a finished run to find its biggest blunders: regret per decision and win-probability-added over the whole run.
  • SimLab: a "what if" lab for a single fight. Set up any combat (character, deck, HP, relics, potions, enemies, ascension) and see the legal moves and what the search thinks of each. Replay the fight many times to see the spread of outcomes, so you can test a card, a relic or a line of play without reaching that spot in a real run.
  • Lab tools: replay viewer, MCTS-runs browser, deck analysis, and state import: paste a position copied from the live game and analyse it in the browser.

Run it: just workbench-local builds the site into sts2-pycli/web/dist and serves it on http://127.0.0.1:4173. With real art the build contains the game's images and sound, extracted from your copy for your own use, so please run it locally and don't host it publicly. Architecture: browser-workbench.md.

Spire Mentor: the AI inside the real game

A C# mod for Slay the Spire 2 that connects the running game to the AI stack over a local TCP socket. Installed but idle, it leaves the game vanilla. The advisor backend is launched by the mod and ships as a self-contained executable.

Play with it: subscribe on the Steam Workshop (Windows; Steam installs BaseLib with it). The workbench comes bundled and follows your run in the browser.

The real game with the Spire Mentor advisor panel: Taunt on Haunted Ship ranked first at +0.85 with 87% of 1,000 simulations, estimated win 92%
Combat advice in the real game, here from the search: MCTS ranks every legal move, shows the principal line and estimates the chance to win the fight.
The real game's map with the advisor panel recommending the right-hand unknown room at 73% over a monster room at 27%
Route advice on the map: the run policy prefers the unknown room (73%) and the route is drawn over the map.
The AI beating Ironclad at Ascension 9 in the real game, through the Spire Mentor mod. The advisor panel at the top left shows the search's ranking of each move.

Advisor

You play. Instinct ranks the moves, card rewards, shop items and map routes. Pick the search in the workbench for MCTS statistics, the principal line and a win estimate.

AI turns & autopilot

Let the AI take one decision or play until you stop it; autopilot plays whole runs unattended and never falls back to random play.

Rewind

Every room is snapshotted with its RNG state. Undo a turn, restart a room, or go back to any earlier room, bit-exact.

Workbench link

Open the current state in the workbench, browse the live game's tree, and rewind the real game from the page.

Controls
KeyAction
F1Help panel: mode, keys, file locations
F3Action log
F4Advisor overlay on/off
F6AI takes this one decision
F7AI plays until you stop it
F8Advisor mode on/off
F9 / F10Game speed − / +
Ctrl+ZUndo to the start of the combat turn
Ctrl+Shift+ZRestart the room

Every key is also on the in-game toolbar, and the settings live on a mod-configuration page in the main menu.

Install

Players: subscribe on the Steam Workshop. To build it yourself: Windows, the game at v0.111.1 (stable) or the v0.113.0 beta, the .NET 9 SDK and BaseLib in the game's mods/ folder. Then cd spire-mentor-mod && dotnet build builds the mod and installs it into mods/SpireMentor/. Configuration, the console commands and the wire protocol are in spire-mentor-mod/README.md and PROTOCOL.md.

Getting started

Three tiers; each needs a little more than the last.

1 · Engine only

No game needed. Rust 1.96, cargo-nextest, just 1.38+.

just rs-check
just rs-test        # cargo nextest run --workspace
just rs-doc-test

2 · Parity oracle

Adds your game install, the .NET 9 SDK and uv.

just import-game "/path/to/Slay the Spire 2" --tier oracle
cd sts2-pycli && uv sync --dev
just build-cs && uv run pytest tests

3 · Workbench with real art

Adds ilspycmd, Node 20+, the wasm32-unknown-unknown target and wasm-bindgen-cli 0.2.120.

just import-game "/path/to/Slay the Spire 2"
just workbench-local   # → http://127.0.0.1:4173

Use cargo nextest, never bare cargo test: tests rely on per-process isolation. Full prerequisites: bring-your-own-game.md; Windows: the engine tier runs from PowerShell, the rest under WSL2 (BUILDING-WINDOWS.md).

Repository map

PathWhat it is
sts2-rs/Rust: engine, content, Instinct inference (sts2-e2e), MCTS, run-AI, CLI, PyO3 bindings, workbench engine (WASM)
sts2-pycli/Python, C# and TypeScript: the headless C# oracle, parity suite, PPO training, the workbench web app, the real-game advisor, an MCP server so an LLM can play
spire-mentor-mod/C#: the Spire Mentor mod
sts2-wiki/Python / Astro: decompile, extract, generate a static wiki
scripts/import_game.pyjust import-game: every game-derived input from your install
docs/Reference docs, ADRs, this site (docs/site/)

Start with ARCHITECTURE.md, then CONTRIBUTING.md. Training a run policy? Read the champion training playbook first.

Game content & legal

Slay the Spire 2 is © Mega Crit. This project is not affiliated with or endorsed by Mega Crit. The repository carries the game's text and extracted data so the engine, the AI and the workbench work out of the box, but no art, audio, game assemblies or decompiled code. The tooling extracts those from a copy of the game you own, into git-ignored paths. The screenshots on this page show the game's art.

The original work is MIT-licensed. sts2-pycli began as a fork of wuhao21/sts2-cli. Spire Mentor started as a port of zhiyue's STS2BridgeMod from zhiyue/sts2-rl-agent. The engine's early combat-loop scaffolding followed the Python simulator in the same repository; it has since been rewritten against the decompiled C#. See NOTICE and PROVENANCE.md.