r/hearthstone • u/Smaguy • 14h ago
Competitive I built a Hearthstone AI and reached Legend with a 91% winrate.
First, an apology. I played ranked with my bot's advice on screen. That is cheating, and I'm sorry to everyone I faced. The bot never clicked anything (I played every move by hand, following an overlay), but that doesn't change much: the decisions were its own. I did it because I had no other real benchmark. Self-play against my own older versions tells me if a version is better than the previous one, not if it can beat humans. The ladder was the only test I had.
Results
97 ranked games with C'Thun Warlock, Nov 2-29, all played with the overlay: 73-24 (75%).
The last version (PPO policy at iteration 12,250, plus search) went 32-3 (91%) from Nov 27 to Nov 29, including a 17-game win streak, and reached Legend (#10,344) from Plat3.

| Period | Advisor | Record | Win rate |
|---|---|---|---|
| Nov 2-15 | Turn search (hand-tuned, then learned value net) | 26-14 | 65% |
| Nov 19-22 | PPO policy (~400k params) + search E | 15-7 | 68% |
| Nov 27-29 | PPO policy (1.2M params) + search E | 32-3 | 91% |
The Legend game (1.5x speed, names blurred; the overlay is the box top left):
https://www.youtube.com/watch?v=eFugLLiASDQ
The deck
Only C'Thun Warlock, because I couldn't afford another deck. The last policy was also fine-tuned on this exact list.
AAECAf0GBK3ZB9vgB6D2B/OJCA2PnwTnoASEmQfd1wew2Qex2Qe32QeN3AfX6Qfp+Qf6iQj7iQinkggAAA==
- 2x Cursed Catacombs (0)
- 2x Ritual of C'Thun (1)
- 2x Drain Soul (2)
- 1x Godfather Kazakus (3)
- 2x Hellfire (3)
- 2x Imp Gang Stooge (3)
- 2x Caged Cranium (3)
- 2x Ritual of Excess (3)
- 1x Godfrey the Betrayer (4)
- 2x Spawn of C'Thun (4)
- 2x Crystalline Golem (4)
- 2x Spire of Solitude (5)
- 1x Kith'ix (6)
- 2x Gargantuan Slitherer (6)
- 2x Annihilation (8)
- 1x C'Thun, Eye of the Empire (10)
- 2x The Unseen Atlas (10)
How it works
Simulator. A C# engine that reimplements the current Standard cards. The overlay reads Hearthstone's Power.log, rebuilds the game state in the engine and asks the bot for the next action, after every action. To check the engine, every game (mine and 1,000 public Legend games) is replayed action by action through it: 96.4% of checkable actions in the Legend games reproduce the real result exactly.
Hidden information. The opponent's deck archetype is guessed from the cards seen so far, weighted by real Legend frequencies. The search then samples "worlds": a full opponent hand and deck drawn from that archetype's list (minus cards already shown), my own deck shuffled, random effects fixed.
Step 1: hand-made search, then a learned value net (Oct 25 - Nov 16)
The first bot was a turn search with a hand-tuned evaluation. I then replaced the evaluation with a value net (~180k params) trained on Legend replays and self-play, and tuned the search a lot (exhaustive turn search, then a beam search: 40 lines over 2 worlds). Each tweak gave 1-4 points in self-play, then it plateaued. Not much success: ~65% on ladder.
Step 2: PPO self-play from zero (Nov 17 - 27)
No imitation of humans or of the old bot: the network starts random and only plays against itself.
- Input: what the player sees. Global features (health, mana, mana left this turn, C'Thun powers used, Rituals completed, etc.) and entity slots (7 + 7 board, 10 hand, secrets), each with a learned card embedding. From r2 on, the last 60 cards played by each player.
- Network: set encoders over the slots, a shared trunk, a value head, and a policy head that scores each legal action from the trunk plus the encodings of its source and target. Mulligan is learned too (keep or replace, card by card).
- Training: clipped PPO, GAE, reward 1 / ½ / 0, 2 epochs per batch, fp16 on an RTX 3060. The C# engine plays ~1,000 games/s on 12 threads.
| Run | Params | Result |
|---|---|---|
| r1 | 198,594 | 15.4M games; 45% vs the beam search bot |
| r2 | 398,722 | bigger card embeddings + played cards; 52% vs the beam bot, with ~350x less compute per game |
| r3 / r5 | 398,722 / 472,418 | fine-tuned on my list; r5 adds mana left, C'Thun counters, Rituals; 76% vs the beam bot (my list vs meta decks) |
| r7-1M | 1,205,458 | inference moved to the GPU (C# engine ↔ Python by batches), ~770 games learned/s; trained general, then fine-tuned on my list for 29.6M games until it plateaued; it 12,250: 55% vs r5 |
(All matches: 1,000 to 5,000 games, played in pairs with the same shuffle and swapped sides.)
Step 3: E, a small search on top of the policy
The policy alone is strong but sometimes sure of a bad move. E fixes some of that:
- If the policy gives one action more than 99%, play it.
- Otherwise take its 4 most likely actions and play each one in the same 64 sampled worlds.
- In each world, the policy plays both sides until the start of my next turn; the value head scores that position.
- Keep the policy's favorite unless another candidate beats it by more than 2 standard errors of the paired differences.
Stopping at my next turn was better than playing to the end (+4 points, 3x faster): the value head is reliable at the start of a turn, and 20 simulated turns add noise. E with r2 beat r2 alone 63.8% and the beam bot 66.3%. E with r7-1M beats E with r5 53.5%. It takes ~0.3-0.6 s when it searches.
Step 4: lethal and "free" attacks (added on the last day, Nov 29)
- Lethal module. Before E, a depth-first search of my turn computes the best probability to kill this turn (random effects weighted, 3 s budget; a quick upper bound on damage skips 80% of decisions in 8 ms). Certain lethal: play the whole line. Probable lethal: add the line as an E candidate and judge it by expected outcome. On my 123 archived games, turns where the advice missed a ≥50% kill went from 15 to 1.
- Free attacks. A hard rule: if the advised action destroys my own minions (Annihilation, for example) and they can still attack the face, attack first. The policy almost never needed it in self-play, but it did against humans.
What would you improve?
Weak points I know of:
- It sometimes plays a random-target card before attacks that would have cleared the targets.
- It doesn't read the opponent's hand from their plays (I tried weighting the sampled worlds by the opponent's likely hand: worse in matches).
- One deck only. Fine-tuning on my list didn't hurt its play with other decks in self-play, but they were never tested on ladder.
- It sucks at temporary cards - especially playing Catacombs
What do you think it should learn next, as a player or as an ML person? And what would be a fair way to benchmark it against humans without ladder?