spire-mentor

How the AI is trained

Instinct is one transformer trained end to end with PPO. It plays whole runs in the simulator, fights included, and learns from the outcome. The first campaign took an Ironclad net from 12% to 81% wins at Ascension 10 in 13 days on one machine, over 9 billion of its own decisions, with no search and no human data.

What the network looks like and how it is used at play time is on How the AI plays. The training code is in sts2-pycli/python/ppo/e2e/; every shipped net has a provenance file next to it in sts2-pycli/data/e2e/. The earlier recipe, a run policy per character trained while a tree search played the fights, is in the V1 archive.

The idea

Version 1 taught a network the choices between fights and left the fights to a tree search. That caps what can be learned: the network never finds out what its deck is like to play, and the search plays every fight without knowing what the run needs afterwards. Two attempts to replace the search with a separately trained combat network, with no search at all, reached 9% and 12% at Ascension 10.

Instinct's training removes the split. One network makes every decision, and the outcome of the run is credited to all of them: the card pick on floor 3, the potion kept on floor 20 and the last card played against the final boss are updated by the same signal. What makes this affordable is the simulator. A run of about 650 decisions costs about a second of CPU, so billions of decisions fit in days.

PPO in plain words

PPO (Proximal Policy Optimization) is a reinforcement-learning method: the network learns by playing, not by copying labelled examples. Nobody tells it which card was the right play or the right pick. It finds out only at the end of a run how far it got, and has to work out for itself which of its choices were responsible. This section explains the idea without the maths; the rest of the page assumes it.

The policy

The network being trained is a policy: shown a situation (the hand, the enemies, the deck, relics, HP, the map, and the options on offer) it gives each option a probability. At a card reward it might say 55% Inflame, 30% Pommel Strike, 15% skip; in a fight, 70% Bash, 20% Defend, 10% end the turn. Learning means shifting those probabilities towards choices that lead to better runs.

Play, then learn

Training alternates two phases:

  1. Play. The current net plays full runs, many at once. During training it samples from its probabilities instead of always taking the favourite, so it keeps trying options it is unsure about. Every decision is recorded: what it saw, what it chose, and how likely that choice was.
  2. Learn. Once the batch is in, the net is updated so that choices which turned out well become more likely and choices which turned out badly become less likely. Then the updated net plays the next batch.

One batch teaches very little on its own. Instinct's first campaign repeated this loop tens of thousands of times, over 11.6 million runs.

Which choice deserves the credit?

A run has hundreds of decisions and one outcome. A win does not mean every pick in it was good, and a death does not mean every pick was bad: the run may have been lost to one unlucky elite. PPO handles this with a second output, the critic (the value head): from any situation it predicts how well the run will go from here.

The credit for a choice, its advantage, is how much better things went than the critic expected at the moment of choosing. Suppose the critic expects a return of 0.40 at a card reward, the net takes Inflame, and the critic's estimate one decision later is 0.46: the pick gets an advantage of about +0.06. A choice that leaves the run worse off than expected gets a negative advantage. Any single advantage is noisy, because the fights and draws in between are random, but over thousands of runs the luck averages out and the real effect of the choice remains. The critic is trained at the same time, to predict returns ever more accurately.

"GAE" in the settings below is how the advantage blends the critic's next estimate with what actually happened afterwards; a λ near 1 leans mostly on what actually happened.

Small steps: the "proximal" part

The obvious rule, raise every probability in proportion to its advantage, is unstable: one batch of lucky runs can push a probability from 30% to 95%, and a policy that has lurched that far is playing a different game from the one the batch measured. PPO limits each update. For every recorded decision it compares the new probability of the choice with the old one, and once that ratio leaves the band 0.8–1.2 the choice earns no further credit. The net can still change a lot over many iterations, but only a little per batch, which keeps learning stable even though the runs in a batch were played by slightly older versions of the net.

Choice turned out welladvantage > 0: make it more likely0.811.2no more credit past 1.2×new probability ÷ old probabilityChoice turned out badlyadvantage < 0: make it less likely0.811.2no more credit below 0.8×new probability ÷ old probability
What one recorded decision contributes to PPO's objective as the update moves the probability of the choice (higher is better for the net). The shaded band is ±20% around the probability it had when the batch was played; the dashed line is the unclipped rule, whose incentive never stops.

Keeping it curious

Left alone, a policy tends to become certain too early, always taking the same option and never learning what the others are worth. A small entropy bonus rewards keeping some probability spread across the options. It shrinks as training goes on and the net settles.

Training versus playing

Sampling and the entropy bonus exist only to learn. When the trained net plays for real, in the published win rates, the mod and the workbench, it takes its highest-probability option every time. The critic chooses nothing and is not shipped.

The environment

  • The simulator. The Rust engine, at game build v0.111.0 and Ascension 10, with Act 1 rolled between Overgrowth and Underdocks. Each training run gets a fresh seed. Partway through the first campaign the whole rollout loop (stepping the game, building the tokens, recording the rows) moved into Rust as well.
  • Every decision is a step. A card play, a potion, a map move, a card reward, a shop purchase: one row each, with the tokens the network saw, the option it sampled and that option's probability. Steps with a single legal option are skipped.
  • Identical options are merged before the network sees them, so the probability of "play a Strike at the left enemy" is not split over the copies in hand.
  • Limits. A fight is cut off at 100 turns or 1,000 decisions and a run at 6,000 decisions, counted as a loss. On the 4,000 test runs this happened once.
  • Practice fights. Besides full runs, the trainer takes snapshots of the agent's own runs just before elites and bosses, reseeds them and plays them again. The schedule gives about a quarter of the training slots to this practice, three quarters of it to bosses and most of that to the double boss that ends an Ascension 10 run. Practice positions always come from the current agent's own decks, so they stay representative of the decks it really reaches bosses with.
  • Invariant checks. On 1% of steps the trainer checks game invariants (HP within its maximum, energy not negative, cards conserved across piles). A violation stops the training.

Reward

EventReward
Winning the run+1.0
Each boss beaten before the last+0.05
Each new floor reached+0.002
Dying, or hitting a limit0

There is no discounting, and no reward for HP, damage dealt or anything else inside a fight. The small boss and floor terms give an untrained net something to climb before it has ever won; a win outweighs all of them together several times over. Leaving HP out is deliberate: the agent is free to learn that finishing a fight on 10 HP is fine when the next room is a rest site.

A critic that sees more

The policy sees only what a player sees. The critic, which exists only to compute advantages during training, is also given the hidden state: the true order of the draw pile, the monsters' next moves, the rooms of the current act and the maps and bosses still to come. A better-informed critic separates luck from judgement more cleanly. When a good line fails because of a bad draw, the critic already expected the bad draw, and the policy is not blamed for it.

The critic has two outputs: the value of the current fight and the value of the run. Over the campaign the fight value explained about 92% of the variance of fight outcomes, and the run value about 40% of the variance of run outcomes, which says how much of a run is still undecided at any one moment. The critic's gradients also train the shared trunk.

Algorithm

ItemSetting
Objectiveasynchronous PPO with a decoupled clip: the probability ratio is clipped at ±0.2 against the policy as it stood at the start of the update, with a capped importance weight for rows played by older weights
AdvantagesGAE without discounting. Inside a fight λ = 0.95, and a fight's last step chains into the next stored decision of the same run, so a fight is credited with its effect on the run. Across the run-level decisions λ = 0.97. Normalised separately for each type of decision
Batch131,000 decisions per update at the start; doubled to 262,000, 524,000 and 1,049,000 during the campaign. One pass over each batch, in minibatches of 8,192
Entropy bonusper decision type, decaying geometrically over the first 4 billion decisions: 0.01 → 0.002 in fights, 0.0125 → 0.006 elsewhere
OptimiserAdamW, learning rate 1e-4 for the trunk and policy and 3e-4 for the critic, scaled by a factor that follows the measured policy change, gradient norm clipped at 1
Precisionbfloat16 autocast with 32-bit weights
Weight averagingrunning averages of the weights with decay 0.996 and 0.999 per update; the shipped nets are such averages
End of trainingthe learning rate annealed linearly to zero over the last 14% of the decisions

Warm start

A net with random weights dies within the first few floors of an Ascension 10 run, which makes for a slow beginning. The first campaign therefore started from the two earlier no-search networks (one for fights, one for the run), in three phases:

DecisionsWho playsWhat the new net learns from
0 to 80 millionthe old networks, handing over graduallyimitating their choices; the critic learns the outcomes
80 to 500 millionthe new netPPO, plus a pull towards the old networks' choices that fades to zero
500 million to 9 billionthe new netPPO alone

The teachers were weak (12% at Ascension 10 together) and were left behind early: the new net had passed them well before the first billion decisions. Before each restart of the trainer, a net with random weights and no teacher had to show it could learn, as a check that the algorithm was not leaning on the warm start.

Compute

ResourceFirst campaign (Ironclad)
Machineone server: AMD EPYC 7443P (24 cores, 48 threads), 247 GB RAM, four RTX 3090
Rollouts40 worker processes with 32 simulated games each
GPUsone serves the network to the workers, three run the update in parallel
Wall clock313 hours (4 to 17 November 2026)
Volume9.0 billion decisions, 11.6 million runs, 299 million fights
Throughput8,000 decisions a second on average, from 6,700 in the first billion to 10,300 at the end

The simulator is the reason this fits on one machine: the same volume on the shipped game's own code would take about 1,500 times the CPU (benchmarks). A watchdog restarts the trainer after a crash or a stall and pins a checkpoint every 250 million decisions; the campaign ran through 27 trainer processes. Every pinned checkpoint is kept.

The first campaign

Ironclad, Ascension 10, greedy, no search: win rate on 2,000 development seeds
DecisionsWin rateWhat changed on the way
1.0 B49.5%
2.0 B57.0%
3.0 B61.6%
4.0 B66.3%learning rate halved at 4.08 B
5.0 B70.7%decisions per update doubled at 5.29 B
6.0 B74.5%doubled again at 6.09 B
7.0 B78.1%a third doubling at 7.27 B gained nothing
8.0 B79.3%learning rate annealing to zero from 7.77 B
9.0 B81.4%end of the anneal

Averaged weights (decay 0.999). The teachers the net started from won 12.3% on these seeds, and the version-1 search agent 24.6% on the first 1,000 of them. The steps up to 3 billion cross simulator updates, so they mix progress of the agent with changes of the engine. The plan written before the campaign forecast about 27% on the test panel.

Each late change was written down with a rule for reverting it before its data existed, and read on the same development seeds:

  • More decisions per update. The first two doublings each bought about 4 points within 400 million decisions after a plateau; the third bought nothing. A measurement of the gradient noise had put the useful batch size near 1.7 million decisions, far above the 131,000 the campaign started with.
  • Annealing the learning rate to zero over the last 1.2 billion decisions gave about 3 points with averaged weights and 8 with the raw ones. The gain arrived late, when the rate had already fallen by half.
  • Weight averaging was worth 6.7 points before the anneal and 1.9 after it: the anneal does most of what the averaging did.

Evaluation

Three seed panels, kept apart. Training runs draw fresh seeds. The development panel (seeds from 160,000,000) was read every 250 million decisions and steered the campaign. The test panel, 4,000 seeds from 161,000,000, was sealed until the end and read once.

The test read: Ironclad, Ascension 10, 4,000 seeds, one engine build for all agents
AgentWinsWin rate
Instinct, 9.0 B decisions, no search3,25581.38%
Version 1: run policy + MCTS (1,000 simulations, 4,000 at bosses)84621.15%
The two warm-start networks, no search47511.88%
Version 1's run policy with a separately trained combat net, no search3568.90%

The bars had been fixed beforehand: beat the best earlier no-search agent by at least 5 points (it did by 69.5), and not fall more than 3 points short of the search agent (it beat it by 60.2, 95% interval 58.5 to 61.8). Comparisons are paired on the seeds, with an exact McNemar test.

What a reader should know: the campaign had no fixed budget. It was extended while the development numbers were still rising, and the anneal was started by decision after looking at them, so the late development numbers carry some selection. The test panel does not: no test run existed before the final net was chosen. The search agent played at the budget of the old promotion gates, not the larger one the advisor used. Full record, with all 19 amendments to the pre-registration: docs/experiments/2026-11-17-ironclad-e2e-campaign-report.md.

The simulator's numbers were then checked against the game's own code. A five-character net played 300 Ironclad Ascension 10 seeds in the Rust engine and again through the game's real assembly, run headless with its own random numbers: 79.7% against 78.7%, 31 seeds differing, 17 one way and 14 the other.

All characters

The shipped net plays five characters. It continues from a checkpoint of the Ironclad campaign and trains on equal shares of Ironclad, Silent, Defect, Regent and Necrobinder runs, with the same algorithm and no teacher. The net in the mod and the workbench is that lane's 4.5-billion-decision milestone.

The five-character lane: win rate at Ascension 10, greedy, on its development seeds
Character2.5 B4.5 B (shipped)
Ironclad81.2%79.9%
Defect63.8%71.8%
Regent54.2%65.8%
Silent53.4%60.8%
Necrobinder43.8%52.8%

Ironclad, which the net inherited, has held at 79 to 81% since 2.5 billion; the four new characters are still climbing, and the lane is still training. The Fool exists only from game build v0.113.0, which has a different content vocabulary, so it has a lane of its own: 80% Fool runs and 4% each of the other five. Its net won 59.4% at 850 million decisions (12% at 200 million, 50% at 600 million) and plays only the Fool, because the other characters regressed on that mix.

What we learned

  • The forecast was wrong by 54 points. The plan expected about 27% and treated matching the search agent as the stretch goal. Nothing in the earlier results suggested that removing the search would help.
  • Training the fights with the run mattered more than anything inside the fights. A combat network trained on its own fights, with the best settings we found, stayed far below the search. The same kind of network trained on run outcomes passed it within the first billion decisions.
  • Volume, then noise. Over the first 5 billion decisions the curve rose 4 to 8 points per billion. After that, progress came from reducing the noise of each update: larger batches, a lower learning rate, averaged weights.
  • The last fight is the hard one. The final net wins 97% of its first Act 3 boss fights and about 91% of the second, and more than 40% of all its losses are in that one fight.
  • Sharing one net across characters has cost the first one little or nothing so far: Ironclad has stayed within a point or two of the Ironclad-only net while four other characters were added.
  • The simulator has to be right. An agent trained on billions of decisions will exploit whatever the simulator gets wrong. The check against the game's own code is what says the final number is about the game and not about the simulator.

The lessons of the earlier recipe (promotion gates, prioritised level replay, the combat surrogate) are in the V1 archive.