Great question! Building an AI to beat humans at Slay the Spire — a roguelike deck-building game with high complexity, randomness, and long-term planning — is a challenging but fascinating problem. When comparing AlphaGo-style vs AlphaZero-style models, it's important to understand the differences and how they apply to Slay the Spire.
🔍 First: What’s the difference between AlphaGo and AlphaZero?
AlphaGo (2016)
Designed specifically for Go.
Used supervised learning from human games, plus reinforcement learning (RL), Monte Carlo Tree Search (MCTS), and deep neural networks.
Handcrafted features were used in early versions.
AlphaZero (2017)
Generalized version of AlphaGo Zero.
Learns entirely through self-play reinforcement learning, starting from random play.
No human data or domain-specific heuristics.
Combines deep neural networks with MCTS to evaluate positions and select moves.
Both use MCTS + deep neural networks, but AlphaZero is more general and learns purely from self-play.
🎮 So, Can These Work for Slay the Spire?
✅ Yes, AlphaZero-style models are more promising than classic AlphaGo-style approaches, especially because:
No large dataset of expert human games exists (or would be hard to collect), so supervised learning like original AlphaGo used isn't feasible.
Slay the Spire is a single-player game, which fits better with self-play training paradigms (unlike two-player zero-sum games like Go or Chess, but still trainable).
Perfect information is not always available — there's hidden state (e.g., cards in your draw pile, future enemies, RNG outcomes), making it partially observable. This adds complexity but doesn’t rule out MCTS-based methods.
⚠️ Challenges with Applying AlphaZero to Slay the Spire
Slay the Spire has several characteristics that make it harder than traditional board games:
Challenge
Description
Stochasticity
Random card draws, enemy behavior, and events mean the outcome isn't deterministic.
Imperfect Information
You don't know your full deck order or future enemies.
Long Episodes
Runs can last dozens of turns across many floors. Long-horizon planning is needed.
Complex Action Space
Each turn, you choose actions based on hand of cards, energy, buffs, enemy states, etc.
Sparse Rewards
Winning a run is rare; most runs end in failure. Learning from sparse rewards is tough.
💡 How to Adapt AlphaZero for Slight the Spire
You’d need to make key modifications to the standard AlphaZero framework:
1. Use a variant of MCTS that handles stochasticity and partial information
Expectimax / chance nodes: Handle randomness by modeling possible outcomes and expected values.
Information Set MCTS: For imperfect information (though this is computationally expensive).
2. Design a strong neural network policy/value head
Input: Game state (your HP, energy, cards in hand, current enemy stats, relics, etc.)
Output:
Policy head: Probability distribution over valid actions (play card A, defend, attack, etc.)
Value head: Estimate of winning probability from that state.
3. Efficient environment simulation
You’ll need a fast, accurate simulator of Slay the Spire (e.g., Slay the Spire API or ModTheSpire) to generate self-play data.
4. Reward shaping and curriculum learning
Use intermediate rewards (e.g., defeating bosses, surviving X floors) to help learning.
Start with simplified decks or scenarios, then increase complexity.
5. Use PPO or MuZero as alternatives
If MCTS is too slow or ineffective due to randomness, consider:
PPO (Proximal Policy Optimization) – model-free RL that can handle stochastic environments well.
MuZero – learns a model of the environment internally without relying on MCTS rollout simulations.
🧪 Existing Work
There are some research efforts and hobby projects exploring AI for Slay the Spire:
Deep Spire (by independent researchers): Uses imitation learning from human gameplay and basic RL.
SpireCrafter (by DeepMind-inspired group): Explores language-model-based agents for STS-like mechanics.
Modded tools: Some people use ModTheSpire to log game data for training AI.
✅ Summary: Which Model Works Better?
Model
Feasibility for Slay the Spire
AlphaGo (supervised + MCTS)
❌ Not ideal — lacks sufficient expert data.
AlphaZero (self-play + MCTS)
✅ Possible, with adaptations for partial info and randomness.
MuZero
✅ Even better — learns internal model, better for complex, stochastic environments.
PPO/A3C
✅ Also viable — model-free, works well with sparse rewards and complex action spaces.
🚀 Final Thoughts
An AlphaZero-style approach could work, but you’ll likely get better results using MuZero or PPO, especially given the stochastic nature of the game.
If you're interested in building such an AI, here’s a suggested roadmap:
Build or find a fast, controllable environment (e.g., via ModTheSpire).
Implement a basic RL agent (PPO is a good start).
Add MCTS with learned policy/value heads.
Introduce curriculum learning and reward shaping.
Scale up compute and explore MuZero if performance plateaus.
Let me know if you want code examples or specific frameworks (like RLlib, PyTorch, etc.)!
User
so given the game has two loops (combat) and meta (things outside combat), should they be handled almost separately?
Assistant
Yes — you're absolutely right to notice that Slay the Spire has two major types of decision-making:
Combat Loop: Tactical decisions during individual fights (e.g., which cards to play, when to use potions, how to manage energy and block).
Meta Loop: Strategic decisions outside of combat (e.g., choosing relics, selecting cards to keep/remove, resting at campfires, managing gold, and route planning).
These loops are distinct in nature, and it often makes sense to model them separately or semi-independently, both for training and architecture design.
🧠 Why Separate Them?
1. Different State Spaces
Combat involves detailed game state: HP, enemy stats, hand of cards, available energy, buffs/debuffs.
Meta involves broader strategic state: deck composition, relics, current floor, HP between combats, available choices at nodes.
2. Different Action Spaces
Combat actions are granular and fast-paced: playing specific cards, using abilities, targeting enemies.
Meta actions are high-level and infrequent: picking a new relic, deciding whether to rest or fight, choosing a card reward.
3. Different Time Horizons
Combat requires short-term tactical thinking (a few turns).
Meta requires long-term planning (multiple floors, full run strategy).
4. Different Reward Structures
Combat rewards are immediate: survive this fight, conserve HP, defeat an elite.
Meta rewards are delayed: better scaling late-game due to good relic choice, efficient deck building.
🛠️ How to Model This in AI
There are several ways you can model these loops depending on your goals and resources.
✅ Option 1: Two Separate Policies
Use two distinct models trained independently:
🔧 Combat Policy
Trained via self-play or RL within individual combat scenarios.
Input: Full combat state (player/enemy stats, hand, block, etc.)
Output: Action probabilities (play card A, defend, attack, etc.)
🔧 Meta Policy
Trained on runs or simulated meta decisions.
User
thinking about only combat loop, can tree searches find deep winning strategies such as an infinite (you get to play unlimited cards due to the setup)?
Assistant
Great question — and a very deep one, both literally (pun intended!) and figuratively.
You're asking whether tree search methods like MCTS (Monte Carlo Tree Search) can discover deep or infinite strategies in the combat loop of Slay the Spire, such as:
"Can tree search find an 'infinite energy' or 'infinite card play' combo?"
Let’s break this down carefully, because it touches on the core strengths and limitations of tree search algorithms, game mechanics, and AI planning in complex environments.
🔍 What Do We Mean by "Infinite" Strategy?
In Slay the Spire, "infinite" usually refers to:
Unbounded card plays per turn (e.g., via Fasting, Consecrate, Well Laid Plans + Study, etc.)
Infinite energy generation (e.g., via Hyper Beam, Loop, Dark Shackles).
Infinite block or damage scaling (via combos that feed into each other).
These are highly non-trivial strategies that often require precise timing, setup, and game knowledge. Humans may only discover them after many runs or watching speedruns.
So, could a tree search like MCTS find these?
🧠 Can Tree Search Find Infinite Strategies?
✅ Yes, in theory, but with big caveats.
Let’s explore what's needed for tree search to find infinite-like combos:
1. Sufficient Lookahead Depth
Tree search needs to explore deep enough to see the payoff from setting up the combo.
If the reward (infinite turns) is too far out, and the tree doesn't explore deeply enough, it won’t recognize the value.
You might need to tweak the search depth, exploration/exploitation balance, or even custom heuristics to guide the search toward promising paths.
2. Accurate Simulation Model
The internal simulator must:
Correctly model all card effects.
Allow branching over possible enemy actions (if applicable).
Track state changes accurately (energy, cards played, buffs, etc.).
If your environment simulation is incomplete or incorrect, the agent won’t be able to simulate the combo at all.
Input: Run state (current HP, relics, deck stats, node options)
Output: Choice probabilities (which path to take, which relic to pick)
✅ Pros:
Easier to train each policy individually.
Can use different algorithms/techniques per loop.
Simpler debugging and evaluation.
❌ Cons:
May miss synergies between combat and meta decisions.
Requires coordination logic between the two policies.
⚙️ Option 2: Single Unified Policy with Hierarchical Actions
Design a single neural network that outputs both combat and meta actions, but with a hierarchical structure.
Example:
Network outputs a "mode" (combat or meta) first.
Then, based on mode, outputs finer-grained action logits.
✅ Pros:
End-to-end learning from start to finish of a run.
Learns dependencies between combat performance and meta choices.
❌ Cons:
Harder to train due to large action space and sparse rewards.
Risk of poor convergence unless carefully structured.
This is a more formalized version of the above idea.
Use a high-level controller that selects goals or subtasks (e.g., “preserve HP”, “build synergy”, “choose relic X”).
Use a low-level controller that executes those goals within combat or meta contexts.
Example:
High-level agent decides: “Conserve HP until next shop.”
Low-level agent plays combat optimally under that constraint.
✅ Pros:
Mimics human reasoning; easier to scale and debug.
Can handle complex long-term dependencies.
❌ Cons:
Designing goal spaces and interfaces is non-trivial.
Still an active area of research.
🧪 Practical Tips for Implementation
If you’re starting out, here’s a suggested progression:
🟢 Phase 1: Focus on Combat Only
Train a combat-only agent (e.g., PPO or AlphaZero-style MCTS + policy/value net).
Use fixed meta choices or random ones.
Evaluate win rate per combat or survival over a set number of fights.
🟡 Phase 2: Add Meta Decisions as Heuristics
Use simple rules or hardcoded strategies for meta decisions.
Let combat agent improve through consistent environment.
🔵 Phase 3: Joint Training (Optional)
Once combat agent is strong, begin joint training:
Freeze combat policy slightly.
Train meta agent to choose relics/cards that help combat agent succeed.
🤖 Framework Suggestions
PPO / IMPALA / DQN – Good for discrete action spaces and sparse rewards.
AlphaZero / MuZero – If you want to simulate ahead and plan.
RLlib / Stable Baselines3 / CleanRL – Libraries to help with training.
SlayTheSpire modding tools – For interfacing with the game.
🎯 Final Takeaway
Yes, it's wise to treat the combat and meta loops almost separately, especially early in development.
Later, you can integrate them in a hierarchical or unified way once each component is working well on its own.
Would you like code examples or pseudocode showing how to implement this kind of dual-agent system?
3. Reward Shaping or Auxiliary Objectives
Standard MCTS rewards winning the fight. But infinite loops may not win immediately.
You can help by adding auxiliary rewards, such as:
Reward for increasing energy.
Reward for generating extra actions.
Penalizing redundant or inefficient moves.
This helps the AI prioritize exploring states that lead to powerful combos.
4. Handling Loops and State Repetition
MCTS can get stuck in cycles if you don’t detect repeated states.
To avoid this:
Use transposition tables to memoize visited states.
Add a step limit or loop detection heuristic.
Or use MuZero-style models that learn to predict future states and avoid infinite loops implicitly.
5. Stochasticity & Partial Observability
Combat in Slay the Spire has randomness:
Card draws.
Enemy behavior.
Random events.
This makes deterministic planning harder. You’ll need:
Chance nodes in your tree (like Expectimax).
Information Set MCTS variants.
Or switch to model-free RL with memory (e.g., LSTM-based agents).
📈 Real-World Example: Finding Infinite Combos
Imagine a deck with:
Fasting (gain 1 energy when you end turn with no cards)
Consecrate (playable for free, generates 1 energy when played)
Self-Forming Clay or similar card draw
This setup lets you:
Play Consecrate → gain energy
Draw more cards
End turn with cards left → trigger Fasting
Repeat forever
Could MCTS find this?
🧠 Only if:
It explores the path where you end the turn with cards left
It sees that doing so leads to more energy
The reward function values sustained energy generation
Otherwise, it might prune that branch early, thinking ending with leftover cards is bad.
🛠️ Tips to Help Tree Search Discover Deep/Infinite Combos
Strategy
Description
Deep Search Trees
Increase rollout depth or use iterative deepening.
Custom Heuristics
Add hand-crafted evaluation functions to guide the search.
Auxiliary Rewards
Encourage exploration of high-energy or high-card-play paths.
Action Pruning
Reduce branching factor by removing obviously bad actions.
Hybrid Planning
Combine MCTS with learned policy networks (AlphaZero style).
Simulated Perfect Knowledge
Assume perfect knowledge of upcoming cards during search.
🤖 Alternative: Use Reinforcement Learning Instead
If MCTS struggles to find these combos, consider model-free RL agents like:
PPO / IMPALA: Can learn long-horizon strategies through trial and error.
DQN with recurrence: Helps remember earlier decisions that led to combos.
MuZero: Learns an internal model of the game, possibly discovering combo setups without explicit lookahead.
These agents may stumble upon infinite combos through self-play, especially if reward shaping guides them toward efficiency and power.
🧪 Summary: Can Tree Search Find Infinite Combos?
Condition
Required for Success
✅ Sufficient lookahead depth
Yes
✅ Accurate environment simulation
Yes
✅ Smart reward shaping or heuristics
Highly recommended
✅ Loop/state repetition handling
Important
✅ Handling stochasticity
Challenging but manageable
✅ Exploration vs exploitation tuning
Critical
So yes, tree search can find infinite-type combos, but only if:
The environment is modeled well,
The reward structure encourages exploration of those paths,
And the search algorithm is tuned to look deep enough.
🚀 Want to Try This Out?
Would you like:
A code example of MCTS applied to a simplified combat scenario?
A mock-up of how to represent game state and actions for search?
Or a plan for training an agent to find specific combos?