It’s late, you’re tired, and maybe you’ve spent your evening getting crushed by a boss in a roguelike game. If that game was Slay the Spire 2 (STS2), take heart: a team of researchers has built an AI that is significantly better at the game than you are.
In their paper, "AlphaDefect: Expert-Level AI for Slay the Spire 2," Chen et al. introduce a system that doesn't just play the game—it dominates it, achieving win rates that would make even the most seasoned "Ascension 20" veterans weep.
TL;DR
AlphaDefect is the first AI to reach expert-level performance in Slay the Spire 2, winning up to 80% of runs at the highest available difficulty. It achieves this by combining deep reinforcement learning with a clever way of "reading" the game state as a collection of data records, proving that even in a world of brutal randomness, a well-trained Transformer can find a path to victory.
What Problem Does This Paper Address?
Games like Chess and Go were "solved" by AI because they are deterministic and symmetric—you can practice against yourself. Slay the Spire 2 is a different beast entirely. It’s a single-player deck-building roguelike characterized by:
- Heavy Randomness: Every card draw, enemy encounter, and treasure drop is a roll of the dice.
- Sparse Rewards: You might make a brilliant decision on Floor 2, but you won't know if it actually worked until you either win or die on Floor 50.
- Heterogeneous Decisions: The AI has to master two very different skills: tactical turn-based combat and long-term strategic planning (which cards to add to the deck, which path to take on the map).
Previous attempts at STS AI often struggled to get past the easiest difficulty levels. AlphaDefect tackles the highest difficulty (Ascension 10 in the early access versions) across six different characters.
Methods
The researchers didn't use a "god-eye" view of the game. Instead, they treated the game state as a set of Entity Records.
- The Architecture: They used a 6-layer Transformer encoder. Every card in your hand, every relic in your pocket, and every intent of the enemy is turned into a "record" with a learned embedding (a mathematical representation of its identity) and numerical attributes.
- The Algorithm: They used Proximal Policy Optimization (PPO), a standard reinforcement learning algorithm, but with a twist. They trained the network on two different timescales: one for the fast-paced combat decisions and another for the slow-burning "run-level" choices like picking rewards.
- Engine-Computed Consequences: Rather than forcing the AI to learn basic arithmetic from scratch, they let the game engine provide "consequences." For example, the engine tells the AI exactly how much damage a card will do after all the complex math of buffs and debuffs is applied.
- Combat Practice: To speed up learning, they didn't just play full runs. They used "practice episodes" where the AI would repeatedly replay difficult boss fights from saved states to learn how to survive the most lethal encounters.
Datasets
- The Game Itself: Training was done directly on the compiled code of Slay the Spire 2 (versions v0.111.0 and v0.113.1).
- Spire Codex: A community-driven dataset of human-played runs used to compare the AI's performance against real people.
- Test Seeds: A set of fixed game "seeds" (random number sequences) that the AI never saw during training, ensuring it wasn't just memorizing specific runs.
Key Insights and Ideas
- Identity is Everything: In one of their "ablation" studies (where they turn off parts of the AI to see what happens), they hid the identities of cards and relics. The result? The AI couldn't win a single run. It turns out that knowing "this is a Strike" vs "this is a Core Surge" is the bedrock of strategy.
- The Act-3 Bottleneck: The researchers found that nearly half of all losses occur at the very end of the game against the final bosses. This confirms what players have long felt: the game is a "test" that you either pass or fail at the finish line.
- Policy Churn: They noticed that different versions of the AI (checkpoints) might have the same average win rate but win on completely different game seeds. By averaging these versions together (using a technique called EMA), they created a more robust "expert" that could handle a wider variety of random situations.
Key Results
AlphaDefect's performance is, frankly, staggering compared to the average player:
- Win Rates: At Ascension 10, AlphaDefect won 62–77% of its runs using "greedy" play (just picking the best move it sees). When allowed to "think" using a test-time search, that win rate climbed to 68–80%.
- Human Comparison: Human players of all skill levels win only about 11–20% of the time at the same difficulty.
- Consistency: In a live-streamed test of 866 runs, the AI won 645 of them, proving its strength wasn't just a fluke of the lab environment.
Limitations and Future Work
Even an "expert" has blind spots. The authors noted:
- Strategy Narrowing: As the AI gets better, it tends to "forget" certain strategies. For the character "The Silent," the AI eventually stopped using "Shiv" builds entirely because it found other strategies more reliable. It optimized for winning, not for variety.
- The "Dread" Wall: A newer, even harder difficulty called "Dread mode" was introduced during the study. On this setting, AlphaDefect's win rate plummeted to about 17%, showing there is still a "ceiling" to its current logic.
- Value Estimation: The AI's ability to look ahead is only as good as its "gut feeling" (the value function) about how good a current state is. Improving this "gut feeling" for the final boss fights is a major goal for future versions.
So, the next time you're staring at a "Game Over" screen in Slay the Spire 2, just remember: it's not impossible. You just need to process the game as a series of entity records and calculate 6.7 billion decisions. Easy, right?
Summary updated