# Training a Superhuman Slay the Spire AI (97% win rate)

> Source: <https://sts-apotheosis.github.io/report-001.html>
> Published: 2026-12-04 21:06:39+00:00

**Recommendation:** For hidden-information games, clone the engine K times with re-rolled hidden state and average outcomes rather than conditioning on the true seed; this determinization drove the reported 97% win rate.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

Kevin Li · 2 December 2026 · `kli6891@gmail.com`

In this technical report, we describe the process for training a model for the Ironclad character<sup>[1](#fn1)</sup> in Slay the Spire. To the best of our knowledge, our AI system is the first to exceed top human performance:

All win rates refer to killing “The Heart” under Ascension 20, the hardest difficulty setting in the game. The greedy win rate is measured over 10M games, while the search win rate is measured over 2048 games.

Our model's weights, along with a mod that uses our model to play the game via CommunicationMod, are available to download from this GitHub repository<sup>[2](#fn2)</sup> (setup instructions are found therein).

The rest of this document describes our methodology, from network architecture to model training.

**States and Notation.** Game states in Slay the Spire may be partitioned into two kinds: in-combat states and macro states. We use:

The set $A(s)$ is the set of all legal actions at state $s$.

**Chance Nodes and Determinization.** To support training, we built a headless engine for Slay the Spire by porting the game's Java source code. In addition to implementing all game mechanics, the key functionality our engine supports is its treatment of *chance nodes*.

Specifically, given a state-action pair $(s,a)$, our engine is able to sample the next state $s'$ from among all potential outcomes, with probabilities consistent with the publicly available information at $s$.

Thus, we will often speak of “determinizing over $K$ worlds” at a state $s$. This means: at state $s$, the engine clones itself $K$ times, with hidden information re-rolled in each clone. By performing the same action $a$ in each clone, our engine observes $K$ potential next states $s'_1, \dots, s'_K$, each an unbiased draw of the hidden information. This ability is used heavily in training, as well as in search at play time.

Importantly, the network never uses the true seed in decision-making. Of course, without determinization, the engine emulates the original game with full fidelity according to its underlying seed; the win rates reported above are measured on games played under actual game seeds, i.e., with the “true” distribution of hidden information.

We use a transformer-based architecture as the backbone of our network. The game state is tokenized (described below) and passed through a transformer stack; final readout layers compute the action logits and values.

Our model has $d_{\text{model}}=256$ and 8 self-attention layers. Together with the embedding tables used to encode the game state and the final readout heads, the size of our model is approximately 14M parameters. The final model comprises *three* such networks<sup>[3](#fn3)</sup>, which we shall refer to as a $(\pi, V, W)$ triplet:

The combat value network $V$ evaluates combat nodes at the start of a turn: before any cards or potions are used, but after all beginning-of-turn effects are resolved.

For these nodes $x$, let $y = y(x; \pi)$ be the first map selection node or terminal node reached after the combat concludes, under greedy play following $\pi$. Note that $y(x; \pi)$ is a random variable, since it depends on hidden information not known at $x$. Then $V(x)$ is an estimate of $\operatorname{\mathbf{E}}[W(y)]$ (with $W(y)$ defined to be $0$ or $1$ at terminal nodes), so that $V(x)$ is an in-combat estimate of the win probability (more precisely, “an estimate of an estimate”).

In greedy play, only $\pi$ is required, with each decision being a single pass. For play-time search, $(\pi,W)$ is used in macro states and $(\pi, V)$ is used in combat states.

**Tokenization.** The game state is tokenized as a collection of $d_{\text{model}}$-dimensional vectors, with the embeddings learned during training. To do this, the game state is broken down into semantic pieces, with each piece a separate token. A full description of each piece and its embedding is beyond the scope of this technical report, so we will briefly mention two examples.

For a combat state $x$, the pieces include (this is not an exhaustive list):

Tokens are usually sums of various embeddings. For example, the card “Strike” is tokenized by summing the following list, each of which is a lookup in an embedding table:

Interested readers may contact me or inspect the model code for the exact details.

To train our model, we use a mix of actor-critic RL (inspired by AlphaZero) and supervised learning.

To start, we initialize **one** (not three) network (following the architecture above). This network carries three readout heads: $\pi$ (action logits), $V^0$, and $W^0$ (both scalars). We use the superscript ‘0’ to distinguish $V^0$ and $W^0$ from the $V$ and $W$ networks mentioned earlier (those will come later). For simplicity, let's call this network $\pi$.

We first train $\pi$ on “one-shot” combats: an episode starts at some combat (possibly in the middle of a run) and lasts until the end of the combat. Each combat action earns a step reward equal to 
$$
r_t^{\text{stage 1}} = \frac{\Delta \text{HP}}{80} + 3 \times \mathbf{1}_{\text{combat is won}}. \tag{1}
$$
 (Note that most actions carry zero reward, since most card actions do not change HP, and at most one combat action receives the balloon reward $3$ for winning the combat.) Thus, the policy is rewarded for winning combats and minimizing HP loss (and rewarded for HP gain); the factor of 3 implies that it is willing to trade 2.4 HP for an additional percentage point of probability of winning the combat.

Since training episodes are single combats, the reward function incentivizes the network to drink potions at any time to save HP or to win this combat. This is obviously suboptimal in a full run; potion timing will be learned in later stages.

Since the policy will need to extend to full runs, it is important that we train on combat scenarios that are “plausible” in some suitable sense. This rules out generating random decks and relic combinations. Moreover, since the network cannot play full runs, using scenarios generated during self-play is unlikely to yield a diverse set of scenarios. Therefore, we rely on game logs released by the Slay the Spire developers, where each log contains a summary of a game played by a human player. We reconstruct the combat scenarios in these games, and use these reconstructions as training episodes. The reconstructions are only approximate (the run logs do not contain enough information to fully reconstruct each combat), but they suffice to provide “plausible” scenarios.

Let the current network be $\pi_{\theta}$. For each state $s_t$ in a rollout, we determinize over $K=4$ worlds; for each world $k$ and action $a \in A(s_t)$ available at $s_t$, we play the action $a$ and follow $\pi_{\theta}$'s greedy actions to the next turn start (or to a terminal state where the combat is won or lost).

Each $(k,a)$ pair thus corresponds to a line of play, with actions $(a^{(k,a)}_t, \dots, a^{(k,a)}_T)$ and states $(s^{(k,a)}_{t+1}, \dots, s^{(k,a)}_{T+1})$, where $a^{(k,a)}_t = a$ and $a^{(k,a)}_{\tau} = \operatorname{arg\,max}_{a'} \pi_{\theta}(a' \mid s^{(k,a)}_{\tau})$ for $t < \tau \leq T$. Set 
$$
\begin{aligned} &Q(k,a) = \sum_{\tau=t}^T r_\tau^{\text{stage 1}} + V^0_{\theta}(s^{(k,a)}_{T+1})\\ &Q(a) = \frac{1}{K} \sum_k Q(k,a) \end{aligned} \tag{2}
$$
 where $V^0_{\theta}(s) := 0$ if $s$ is a terminal state. Thus, $Q(k,a)$ is the reward that action $a$ accumulates in world $k$ up to the next turn start, with the next turn start valued by the network $V^0_{\theta}$. The improved policy $\Delta(\cdot \mid s_t)$ is defined by 
$$
\Delta(a \mid s_t) \propto \pi_{\theta}(a \mid s_t)\, e^{\beta Q(a)}, \quad \beta=10. \tag{3}
$$
 Next, we sample $a_t \sim \Delta(\cdot \mid s_t)$ and move to $s_{t+1}$. In training, we play 8192 combats for 160 steps, and the network is updated to minimize the loss 
$$
\mathcal{L}(\theta') = \operatorname{KL}(\Delta \parallel \pi_{\theta'}) + \frac{1}{2} \text{PPO loss for } V^0_{\theta'}. \tag{4}
$$
 The PPO loss uses clipped squared error, with $\lambda=0.8$ GAE targets. The optimizer is Adam with learning rate $3 \cdot 10^{-4}$.

TODO - add plot of combat win percentage and HP loss over training steps.

At the end of Stage 1, we have a network whose policy function can play individual combats. In Stage 2, we start training the network towards playing full-length Ascension 20 runs, starting at Floor 0, with the goal of defeating The Heart (from this stage onwards, all improvements come from self-play).

Since defeating The Heart requires more than a hundred macro decisions over the course of a run, choosing randomly (i.e., what our current policy function does) will never result in a win. Some intermediate reward shaping is therefore necessary in order for the network to make progress. To this end, we define the following macro reward 
$$
R_t^{\text{stage 2}} = 5 \times \mathbf{1}_{\text{run is won}} + \frac{0.3}{17} \times \text{floors climbed}. \tag{5}
$$
 (We use “$R$” and “$r$” for macro and combat rewards, respectively.) Thus, each macro decision that advances the floor count receives a step reward of $0.3/17$, with a won run receiving a balloon reward of 5.

Since our objective in Stage 2 is completing full runs, we need to adjust our combat reward function to account for a combat's continuation value, i.e., to incentivize the policy to finish combat in states that are promising for the rest of the run.

The theoretically clean choice is to set the reward to be the continuation value itself; that is, the reward of a combat is $W^0(y)$ for the macro state $y$ following the combat. However, early in training, $W^0(\cdot)$ is not yet sharp enough to correctly value HP or potions. That is, for pairs $(y_1, y_2)$, the difference $W^0(y_1) - W^0(y_2)$ is often a poor judge of the relative advantage of one state over the other.

We take a middle ground: the combat reward function maintains a $\Delta\text{HP}$ term, but we add an *exit term* that incentivizes ending the combat in states with high $W^0$. More precisely, we set 
$$
r_t^{\text{stage 2}} = \frac{\Delta \text{HP}}{80} + \mathbf{1}_{\text{combat is won}} \times
\bigl(3 + W^0(y') - W^0(y^{\circ})\bigr),
\tag{6}
$$
 where $y'$ is the combat reward screen immediately following combat, and $y^\circ$ is a modification of $y'$ that sets its potions, gold and max HP to their values before the combat. Since we expect $W^0(y') < W^0(y^{\circ})$ if potions are used during combat (in which case $y'$ and $y^{\circ}$ are identical except on potions), the exit term $W^0(y') - W^0(y^{\circ})$ nudges the network to conserve potions. By the same reasoning, it also allows the network to value gold and max HP changes.

The training algorithm is similar to Stage 1's combat training. At a given state $s$:

Search lines use the reward functions ([6](#eq6)) and ([5](#eq5)) for combat and macro states, respectively, to form an average value $Q(a)$. The improved policy is given by ([3](#eq3)). To move to the next state, we sample from $\Delta$; at map selection nodes, card rewards, and campfires, the sampled action is then replaced, with probability $\epsilon$, by a uniformly random legal action ($\epsilon = 25\%$ at map selection nodes, $\epsilon = 10\%$ at card rewards and campfires). The loss function is 
$$
\mathcal{L}(\theta') = \operatorname{KL}(\Delta \parallel \pi_{\theta'})
+ \frac{1}{2}(\text{PPO loss for } V_{\theta'}^0 \text{ and } W_{\theta'}^0).
\tag{7}
$$

We observed that the win rate plateaus with the above algorithm, at around $64\%$. To make further progress, we make the following modifications:

In particular, the stronger search settings strengthen the improved policy $\Delta$ and lower its variance (allowing us to use a higher $\lambda$ for $W^0$). In addition, doubling the steps per training window allows each step to learn from more diversified experience.

By the end of the latter half of Stage 2's online training, our network achieves a win rate around $82\%$.

From Stage 3 onwards, we use supervised learning to further improve the network. Stage 2's online training faces a computational challenge: we need a large number of policy targets $\Delta=\Delta(s)$ to improve the policy, but generating the targets (via search) is too computationally expensive. Instead, our goal is now to generate training examples $\{ (s, \Delta(s)) \}$ and train the network via supervised learning.

Denote by $\pi_0$ the network at the end of Stage 2. We play 1M games greedily<sup>[4](#fn4)</sup> using $\pi_0$, and refit the $V^0$ and $W^0$ readout heads, keeping the policy weights frozen. From this collection of 1M games, we sample 4M combat states, with at most one state per (game, combat, turn) tuple, using a split of (25%, 20%, 25%, 30%) for (hallway, elite, boss, Act 4) combats, respectively.

For each selected state $x$, we search as in Stage 2 to compute the target policy $\Delta$. The search parameters are stronger: $K=(64,128,256)$ for (hallway, elite, boss and Act 4) combats, with a search horizon of two turns. This provides a sample of 4M $(x, \Delta(x))$ pairs.

We train the network via supervised learning, with the network initialized at $\pi_0$, on the loss 
$$
\mathcal{L}(\theta; x) = \operatorname{KL}(\Delta \parallel \pi_{\theta}) + \beta \lambda \sum_a \pi_{\theta}(a) [Q^{*} - Q(a)], \tag{8}
$$
 where $Q^{*} = \max_{a'}Q(a')$ and $\lambda$ is a tuning parameter (we find that $\lambda \approx 10$ works well).

The inclusion of the regret term in the loss outperforms these alternatives:

An underlying explanation for this phenomenon is under investigation.

Looping the recipe (policy network $\to$ label and fine-tune using regret loss) achieves a performance of $85.2\%$, a $3.4$ percentage point increase over Stage 2.

In Stage 4, we again use offline supervised learning to improve the network, this time focused on macro decisions. Here, we finally train the final $W$ network that predicts the win probability instead of the proxy ([5](#eq5)).

We use the network $\pi_0$ at the end of Stage 3 to play 25M greedy games. In each game, we sample macro nodes $y$, and pair each with the game's outcome (0 or 1); in this way, we obtain Monte Carlo labels $\{(y, \text{outcome})\}$. The sample consists of 8 random macro states $y$ from each of the four acts in the game. We play another 25M single-deviation greedy games, and augment the sample with macro states right after the single deviation.

We initialize a fresh network at the weights of $\pi_0$, and train it on our sample using binary cross-entropy loss. In this way, we obtain the $W$ network, where $W(y)$ is an estimate of the win probability of $\pi_0$'s greedy play.

Labeling macro nodes $y$ is similar to labeling combat nodes. From a greedy game, we sample a collection of macro states $y$; for each state $y$, we

Call the best action $a^{*}$, which may differ from the policy $\pi_0$'s greedy action $a^g$. We construct the dataset consisting of pairs $(y, \text{target}(y))$ where 
$$
\text{target}(y) = \begin{cases} \text{point mass on } a^{*} & \text{if } a^{*} \neq a^g \\ \pi_0(\cdot \mid y) & \text{if } a^{*} = a^g \end{cases}. \tag{9}
$$
 A new policy network is then fit using cross-entropy on this dataset. After a new policy is produced, we iterate to produce successively stronger policies.

With the $(\pi, W)$ result of Stage 4, we play greedy games using $\pi$, and train a new network (initialized at $\pi$) on combat states, using labels $(x, W(y(x;\pi)))$. (See Section 3 for the definition of $y(x;\pi)$: it is the first map selection node following $x$.) This gives rise to $V$, the final member of the triplet.

**About the Author.** I am a researcher in quantitative finance, based in NYC. Currently, I design and train deep learning models for systematic trading. Previously, I worked on optimization and portfolio management. To get in touch, please connect on LinkedIn<sup>[5](#fn5)</sup> or send an email.
