Recreating HearthArena Card Ranking Algorithm with Tensorflow

In this article, I will be sharing my journey recreating the deckbuilding tool offered by HearthArena for the virtual card game Hearthstone.

What is Hearthstone and HearthArena?

Hearthstone — a virtual card game
The “Arena” game mode
  1. Value — when you run out of cards it’s hard to win, so it’s important to have cards that draw/generate more cards or pack a lot of value themselves
  2. Tempo — cards with high tempo that impact the game faster when played are generally better as they can change a losing into a winning situation
  3. Synergies — some cards work better with other cards, and some cards are anti-synergistic!

How does the HearthArena Algorithm work?

The HearthArena algorithm has both human and machine computations built into it. First, people work to assign normalized scores by assessing how good a card is using some of the criteria stated above. Data of decks and winrates is also collected from players drafting decks every day. This data is then used to train a machine learning model, which is applied to make micro-adjustments to card scores.

HearthArena tool in action

My Journey Recreating the HearthArena Algorithm

I started out with the goal of mimicking what HearthArena does — given information about the cards picked so far and the current 3 choices, assign scores for each of the choices. However, in working towards that, I also ended up creating a model which assigns a score for any given deck of 30 cards. Thus, I’ll touch on that a little as well.

Part 1: Web Scraping
Cards and their winrates
Decklist and overall score
+------------------+-----+-----+-----+-----+-----+
| Card Name | A | B | C | ... | Z |
+------------------+-----+-----+-----+-----+-----+
| Deck #1 Counts | 1 | 2 | 0 | ... | 1 |
| Deck #2 Counts | 0 | 1 | 0 | ... | 0 |
| ... | ... | ... | ... | ... | ... |
| Deck #100 Counts | 1 | 0 | 3 | ... | 1 |
+------------------+-----+-----+-----+-----+-----+
#Counts refers to the number of that card in the deck
#Sum of counts across all cards for each deck = 30
Linear Regression Model Training
#Evaluation Metrics
{'average_loss': 8.609376,
'label/mean': 75.03246,
'loss': 86.09376,
'prediction/mean': 74.83777,
'global_step': 5000}
#Prediction by Linear Regressor
array([[71.079025]], dtype=float32)
#Actual score
array([73.3])
DNN Regression Model Training
#Evaluation Metrics
{'average_loss': 3.021388e-05,
'label/mean': 75.03246,
'loss': 0.0003021388,
'prediction/mean': 75.031525,
'global_step': 1000}
#Prediction by DNN Regressor (much better performance!)
[{'predictions': array([73.30318], dtype=float32)}]
#Actual score
array([73.3])

Back to the Main Goal

But I wasn’t satisfied with just predicting a score for a given deck. So after poking around on HearthArena more, I found to my surprise this data for different decks.

Card choices, previous picks, and individual scores!
Linear Regression Model Training
#Evaluation Metrics
{'average_loss': 1083.2366,
'label/mean': 61.46461,
'loss': 10832.366,
'prediction/mean': 45.357845,
'global_step': 2000}
#Prediction by Linear Regressor (rather poor performance)
[{'predictions': array([79.04803], dtype=float32)},
{'predictions': array([82.29574], dtype=float32)},
{'predictions': array([77.59356], dtype=float32)}]
#Actual scores
['Air Raid', 'Guardian Augmerchant', 'Holy Light']
[64.56, 64.69, 15.85]
DNN Regression Model Training
#Evaluation Metrics
{'average_loss': 315.33557,
'label/mean': 61.46461,
'loss': 3153.3557,
'prediction/mean': 57.02432,
'global_step': 1000}
#Prediction by DNN Regressor (much better performance!)
[{'predictions': array([67.01109], dtype=float32)},
{'predictions': array([82.476265], dtype=float32)},
{'predictions': array([17.470245], dtype=float32)}]
#Actual scores
['Air Raid', 'Guardian Augmerchant', 'Holy Light']
[64.56, 64.69, 15.85]

Reflecting on the Journey

The Ultimate Toolkit for Deep Learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store