Teaching a machine to play Slay the Spire like a top streamer.
Slay the Spire is a deckbuilding roguelike with enormous branching: hundreds of cards and relics, random draws, hidden enemy intents, and a 50+ floor run where one bad fight ends everything. Spire Mind is a from-scratch AI that plays Ascension 20 Ironclad β the hardest difficulty β aiming to win as reliably as a skilled human. This page walks through how it's built: how the game is encoded, how the neural nets are constructed, how a tree search uses them, and how the whole thing trains itself.
This is a research system in active training, not a finished bot. On 450 matched fights against human replays it currently loses 20.4 HP per fight on average vs a human's 15.6, and matches-or-beats the human on 42% of them. It has one verified A20 win so far. The ~90% figure is the goal β roughly a skilled Twitch streamer β and every training cycle chips away at the gap. Watch it play, wins and deaths alike, on the live runs page.
Two brains, one run
A run splits cleanly into two decision problems, and the AI uses a dedicated model for each. They talk to each other: the map brain asks the combat brain "how much will this fight hurt?"
The Combat Brain
Inside a fight, every turn: which cards to play, in what order, on which target. It sees the literal battle state as a set of typed tokens and runs a Monte-Carlo tree search guided by a transformer that predicts the fight's outcome.
- Input tokenized battle state
- Model entity-token transformer
- Decision MCTS + CVaR risk selection
The Out-of-Combat Brain
Between fights: which path to take on the map, which cards to add or remove, what to buy, how to resolve events. It scores whole run states with a win-probability net that reasons over your owned set of cards and relics.
- Input deck + relics + run context
- Model owned-set attention net
- Decision path planner over win-prob
Encoding the battle as a set of tokens
The key design choice: a fight is not a flat vector of numbers. It's a set of typed entity tokens β like words in a sentence β so a transformer can attend over the relationships between them (this card vs that enemy's intent, this relic vs this status).
Each token carries up to 55 scalar features in a shared "union" layout (a slot is filled only when it applies to that token type). Cards separated by pile is what lets the net know the difference between "a Bash in my hand" (playable now) and "a Bash still in my draw pile."
The combat net: one trunk, many heads
The tokens flow through a transformer trunk, then split into several prediction "heads." One net answers every question the search needs.
self-attention over the token set
A distribution, not a number
The value head is categorical: instead of predicting a single "win chance," it predicts a distribution over how the fight ends (including the chance of dying). That distribution is what makes risk-awareness possible.
Speed-aware value
The training label grades wins by end-HP and speed β a clean 3-turn win scores above a sloppy 30-turn one β so the net learns to close fights, not just survive them.
The danger head
A dedicated head predicts a fight's HP-loss and death risk from the run state. This is the bridge to the map brain β and it's trained with each specialist so it always reflects how that exact model plays.
Search: look ahead, then choose safely
The net is fast but shallow. Wrapping it in a Monte-Carlo Tree Search lets the AI look many moves ahead β playing out lines, backing up the net's value estimates, and concentrating effort on promising branches.
Scoring a whole run: owned-set attention
Between fights the question is "how good is my run right now?" The win-probability net answers it by attending over everything you own β deck and relics in one shared space β so synergies are valued in context.
every card/relic attends to every other
Synergy is emergent
Dead Branch is mediocre alone but busted with an exhaust engine. Because the set self-attends, the net rates the combination higher than the sum β no hand-coded "combo" rules.
The path planner
A forward-simulating planner walks candidate map routes, pricing each room's HP cost and death risk with the danger head, and values the horizon with win-probability β then picks the survival-weighted best path.
Crediting the rewards
Elites are priced not just by their cost but by the relic they drop (valued against your actual deck), so the bot stops dodging elites when it's healthy β the way a strong human plays for relics.
A specialist for every fight
One shared net can't shift its play toward a hard boss without breaking its micro-decisions elsewhere. So each encounter gets its own fine-tuned specialist, routed by the encounter id β and each carries its own danger head.
Hexaghost
(HPΓ·12 + 1) Γ 6. The engine simulates this exactly, so the
specialist learns the counter-intuitive truth β sometimes you enter a fight low on
purpose.
The self-improvement flywheel
No human labels. The system generates its own training data by searching, then distills that search back into the net, then searches again with a stronger net β a loop that only ratchets upward.
Coverage augmentation
Human data never shows every card in every fight, so specialists went blind to rare cards. Training batteries are augmented so every Ironclad card, colorless card, curse, and relic appears at least three times per encounter β no blind spots.
The ratchet gate
A candidate must pass every tactical case a deployed model ever passed, and fix at least one new one. It's mathematically monotonic β the bot can only get better.
Closing the self-gap
The real headroom isn't "beat humans" β it's the gap between the net and its own search. On the hard bosses that gap is 10β18% win rate, and distillation is steadily closing it.
The live decision stack
A live game streams state to the AI, which routes each decision to the right brain and plays it back β with watchdogs that keep it running and hot-reload new models.
Every piece β the token encoding, the transformer heads, the CVaR search, the owned-set win-prob net, the per-encounter specialists and their danger heads, and the self-distilling flywheel β exists to answer one question well, thousands of times a run: what's the play that wins the most while dying the least?
Get your runs reviewed
Upload a run and the A20 bot reviews every decision: which card it would have drafted and why, how much HP each fight should have cost, and β for any fight β a step-through replay of the bot playing your exact spot. Join the waitlist and be first in when it opens.