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, 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
Kind
Count
Notes
Characters
5
Ironclad, Silent, Defect, Regent, Necrobinder
Cards
580
card ids incl. colorless, status and curse cards
Relics
297
Potions
63
Powers
272
Monsters
121
with their intent state machines
Events
69
incl. the Ancients
Acts
3
4 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.
Measurement
Result
Random-play fights per second, one core
59,400
Engine actions per second, same fights, one core
1.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 throughput
1,500× per core 2,430× whole machine
Against the shipped game, CPU time per action
2,970× (2,250× its game thread)
Against the previous engine (12 Oct 2026), same fights
2.25×
Against two other simulators, same random-play fights, one core
3.13× faster than sansb sts2core 1.56× faster
Instinct's training, one machine with four RTX 3090
8,000 decisions/s on average 9.0 B decisions in 313 h
Instinct in the browser (WASM with SIMD), a whole run
8.6 ms per decision
The combat search behind the browser hint, 1,000 simulations
13.7 ms native 18.4 ms WASM in Chromium
The same search at the hint's default 2,000 simulations, WASM in Chromium
39.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:
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.
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
Character
Win rate
Ironclad
79.9% 799 / 1,000
Defect
71.8% 359 / 500
Regent
65.8% 329 / 500
Silent
60.8% 304 / 500
Necrobinder
52.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
Agent
Wins
Win rate
Instinct, Ironclad-only net (9.0 B decisions), no search
3,255 / 4,000
81.4%
Search agent: run policy cont300_it1150 + MCTS, 1,000 simulations (4,000 at bosses)
846 / 4,000
21.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.
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.
A hint 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 search tree for that position (a version 1 tool that is still included), as an outline: the most-visited line expanded through chance nodes (the possible draws), with visits, Q values and predicted outcomes.The live regret coach flags a move as you make it: Shrug It Off (87%) instead of drinking Beetle Juice (98%).The act-1 map with the planned route to the boss and the run policy ranking the next room.A card reward: each pick with its effect on the deck and a rollout act-win rate; the run policy's own pick probabilities below.The opening Neow event: act-win rate over rollouts for every option.The shop with an act-win estimate under every card, potion and relic.After a rewind: the run tree forks at a card reward, and both branches stay playable.Deck analysis: damage, block and velocity profile with warnings (“energy-limited”, “deck clogged with basics”).Watch the AI play a Silent run live, here at the act-1 boss (recorded with the version 1 agent).…and winning it: 48 floors (the screenshot shows 45: it predates the workbench adopting the game's count, which includes the Ancient that opens each act), 29 cards, 15 relics, with the replay one click away.The replay viewer: scrub any recorded run step by step and “play from here”.Post-combat regret review: every decision re-searched, the costliest plays listed first.Run review: the outlook-score curve over a whole run, with the turning points and a re-check for each.SimLab: build any combat position by hand, then search it in the browser.A SimLab study: damage-taken distributions of four strategies over 30 seeds each.Start a run: any character, seed and ascension, played yourself or by the AI.
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.
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.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
Key
Action
F1
Help panel: mode, keys, file locations
F3
Action log
F4
Advisor overlay on/off
F6
AI takes this one decision
F7
AI plays until you stop it
F8
Advisor mode on/off
F9 / F10
Game speed − / +
Ctrl+Z
Undo to the start of the combat turn
Ctrl+Shift+Z
Restart 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).
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.py
just import-game: every game-derived input from your install
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.