spire-mentor

How the AI plays

The AI is Instinct: one small transformer, trained by reinforcement learning, that makes every decision of a run. It plays the cards in a fight and picks the path, the card rewards and the shop purchases between fights, each in a single forward pass, with no search. It never sees information a human player could not.

How it was trained is on its own page. This page describes what runs at decision time, as deployed. The agent it replaced, a tree search for the fights plus a learned run policy, is documented in the V1 archive.

One network

startfightrewardpathfightrewardeventpatheliterelicrestshoppathfightbossfight: one forward pass per actioneverything else: one forward pass of the same networkAct 1, schematically: who decides at each stop
Every stop of a run goes to the same network. Prompts with a single option are taken automatically.

Earlier versions of this project split the work: a Monte-Carlo tree search played each fight and a learned policy made the choices in between. Instinct replaces both. An Ironclad run at Ascension 10 has about 650 decisions, most of them card plays, and each one is the network's single answer to the state in front of it.

The difference in strength is large. On 4,000 held-out Ironclad runs at Ascension 10 the first Instinct net won 81.4%, and the search agent won 21.2% of the same seeds. Win rates for all six characters are in the main docs.

One reason is that a fight is no longer played for its own sake. A search over one combat optimises that combat. The network that picks the cards also carries the deck, the map and the boss ahead, and it was trained on the outcome of whole runs, so it spends HP and potions where the run can afford them. In an audit of potion use, Instinct drank potions the way winning human players at Ascension 10 do: seldom in ordinary fights, more in elites, most at bosses, and it rarely reached a boss with an empty belt. The earlier agents it was compared with drank in ordinary fights about three times as often and arrived at bosses empty in roughly four runs out of ten.

What it decides

  • In a fight: every card play with its target, every potion, choices a card asks for (which card to discard, exhaust or upgrade) and when to end the turn. One action at a time; there are no whole-turn plans.
  • On the map: which node to walk to next.
  • After a fight: the card reward, including skipping it, relic choices and boss relics.
  • In shops: what to buy and whether to remove a card.
  • At rest sites: rest, smith or the other options, and which card to upgrade.
  • In events and at the start of the run: every option, and every deck change the game asks for (remove, upgrade, transform, enchant).
  • With a full potion belt: which potion to give up.

A few rare screens are not modelled as decisions yet and are handled by fixed rules in the simulator and the mod (drinking a potion outside combat, for example, is trained but switched off in the shipped hosts).

What it sees

The state is turned into a set of tokens, one per thing on the table. A card in hand is a token; so is an enemy, a relic, a power, a potion, each legal action and each option on a reward screen. A typical decision has a few dozen tokens. There is no fixed layout and no position encoding: a hand of ten cards is ten card tokens in no particular order.

The observation
GroupWhenContent
Combatin a fightthe hand with each card's current cost and damage, the draw, discard and exhaust piles as unordered sets, player and enemy HP, block and powers, relics with their counters, potions
Intentsin a fighteach enemy's shown intent in full, plus a three-step forecast of its move pattern with how certain each step is
Tactical helpersin a fightper enemy, the most damage the current hand can deal this turn and whether that kills; the HP lost if the turn ended now
Run statealwaysHP, gold, act and floor, floors to the boss, the kind of decision being asked
Bossalwaysthe current act's boss, and at Ascension 10 the second one
Deck summaryalwayspooled views of the deck, the piles and the relics
Run bodybetween fightsthe deck card by card, relics, potions, and what is on offer: reward cards, shop stock with prices, event options, rest-site options, boss relics
Mapon the mapthe nodes reachable from here and a summary of the routes behind each next step

Every card, relic, power, potion, monster and event id indexes one shared embedding table. Each id also carries a fixed row of facts taken from the game's own data: type, rarity, cost, base numbers, keywords, targeting and what an upgrade changes. A card the network has rarely met is therefore not a blank: it starts from what the card says.

Numbers (HP, block, damage, gold, counters) enter through a small network after a symmetric log transform, so 7 and 700 are both readable without hand-set scales.

Hidden information

Instinct gets what the game shows a player and nothing else. It does not see the order of the draw pile, the random rolls a monster will make, the rooms it has not reached, or the bosses and maps of later acts. Cards the game has openly placed on top of the draw pile are the exception, because a player knows those too.

This is tested, not assumed. A check that ran before training and at every change of the serving code shuffles everything hidden (the draw order, the combat random-number state, the unvisited rooms, the future maps and bosses) and requires the network's output to stay bit-identical. The hidden state is not masked out of the policy's input; it is absent from it.

During training a second module, the critic, is given the hidden state to judge positions more accurately (see the training page). It is not part of the shipped file.

The network

PartSpecification
Id embeddingone table of 4,096 rows × 256, shared by every kind of game object
Input stemsembeddings for the token's group, type and slot; a small network for its numbers
Trunk4 transformer blocks, width 256, 4 attention heads, pre-norm with RMSNorm, SwiGLU feed-forward of width 704, no positional encoding
Policy headsone for fights and one for everything else: each scores a legal option from that option's token, the state token and the kind of decision; a softmax over the options gives the probabilities
Size6.1 million parameters in training, including the critic; the shipped file holds the policy path only, about 21 MB in 32-bit floats

The same trunk serves every decision type. A card play and a map choice differ only in which tokens are present and which head reads the result. 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 of the same shape, because that build has a different content vocabulary.

Choosing

  • Greedy. When it plays for real (in the published win rates, the mod and the workbench) the network takes its highest-probability option every time. Sampling exists only in training.
  • Identical options are one choice. Two plain Strikes aimed at the same enemy are merged into a single option. An enchanted Strike, or a card whose damage has grown during the fight, stays separate.
  • Forced moves are free. A step with one legal option gets no forward pass. That is about one combat step in six.
  • Deterministic. The same state always produces the same move, so a run replays exactly from its seed.

Where it wins and loses

The first Instinct net (Ironclad only, 9 billion training decisions) on 2,000 development seeds at Ascension 10: 1,628 wins and 372 losses.

Boss fights of those 2,000 runs
Boss slotFights wonHP at entryPotions at entry
Act 196.8–99.0%72–84%1.6–1.8
Act 297.1–98.4%77–85%2.2–2.3
Act 3, first boss97.3–97.7%96%2.8
Act 3, second boss (Ascension 10)89.7–92.2%74–76%2.2–2.4

Of the 372 losses, 80 came in Act 1, 77 in Act 2 and 215 in Act 3, and 157 of those 215 were at the second of the two final bosses. That fight starts with whatever HP and potions the first one left, and it ends the run. Only 80 losses in all happened outside a boss fight.

Ranges are over the bosses that can appear in the slot. Source: docs/experiments/2026-11-17-ironclad-e2e-campaign-report.md. The shipped five-character net has not been broken down this way.

The numbers on screen

  • Percentages next to Instinct's advice are the network's probabilities for each option: how strongly it prefers one move over the others. They are not chances of winning.
  • "est. win" in the mod and win badges on cards in the workbench come from the search: of the simulations that started with this move, the fraction that reached a won fight. It is a fight-level number and not calibrated.
  • The mod's evaluation bar shows the search's mean value for its recommended move.

Where it runs

HostHow Instinct runs there
Simulator and evaluationits own inference code in pure Rust (sts2-rs/crates/sts2-e2e) on the CPU, or the PyTorch model during training
Browser workbenchthe same Rust crate compiled to WebAssembly with SIMD, in a Web Worker; the ~21 MB net is fetched when the brain is first chosen and cached
Spire Mentor modthe mod reads the game and draws the HUD; a separate advisor process bundles the Rust engine and the nets, mirrors the live state into the engine and answers over a local socket

The Rust tokenizer and network are checked against the Python training code on recorded runs: the tokens must match bit for bit, and on 23,132 recorded decisions of the shipped net the largest difference in any output was 1.3e-4, with no change of the chosen move. Inference speed is on the benchmarks page.