Deck Simulator for Hearthstone V1.2 Released on Apple App Store!

I’m very happy to announce Deck Simulator for Hearthstone‘s 3rd version (1.2) is now available on the Apple App store!

For this release I decided to take a break from adding new cards and focus on adding a few features that will make the tool easier to use and more productive.

For example, I’ve added a very cool feature that allows you to evaluate to what extent each card in a deck is contributing to it’s overall strength, and also added a rating system for decks to easily compare them (HELO = Hearthstone ELO).

For full details of the release please see the app’s page here:

https://itunes.apple.com/us/app/deck-simulator-for-hearthstone/id914214349?mt=8

The app is currently completely free, with no ads, though will only be this way for a limited time.

I’ll be writing some more posts in the feature highlighting some of these new features and discussing how to use them.

Advertisements

Deck Simulator for Hearthstone V1.1 released!

I’m very happy to announce V1.1 of Deck Simulator for Hearthstone has been approved by Apple and is currently available on iTunes as an iPad app.

The main purpose of this release was to address a few crashes that I discovered, and also reduce memory used by the simulator. This allows longer simulations to be run without them being stopped due to lack of memory.

One of the crashes occurred when attempting to play a simulation with a deck containing 29 or less cards. I fixed this so it doesn’t crash, but instead gives a warning so you know you are testing a non-legal deck. I decided to allow this because making decks with less than 30 cards can be fun, and even useful when doing deck construction. I’m sure some of you wondered what would happen if you could create a small deck with only a few cards, and now you can actually see how strong such decks would be.

Another bug I fixed was where the default simulation type was “All play all”, even though the button showed “All play first” selected.

I decided to add an extra bonus which is all the cards for the Warlock class (previously they were not in the database), as well as three sample Warlock decks to play around with.

I’m already working on the next release and hope to have that out in a few weeks, but in the meantime try out the latest version and enjoy!

Hearthstone Simulator: “Edit Decks” screen and features

The “Edit Decks” screen of Deck Simulator for Hearthstone, accessible via the button of the same name on the main menu, is where you go to view decks in the database, edit or create new ones, and get some information about decks including crafting cost.

There is a lot of buttons and controls jammed into this screen, and in this post I’ll go over each one in turn to talk about what it does.

Tables: there are three tables on the Edit Decks screen:

Decks (top left): This table shows a list of all the decks in the app’s database of cards, which is stored locally and doesn’t require a network connection to access. The total number of decks currently in the database is listed in parenthesis like this “Decks (17)”

Cards in selected Deck (bottom left): Once you click on a deck in the Decks table, you will see a list of all the cards in that deck here. You can scroll up or down through them. If you want to remove a card from this deck, click on the blue arrow pointing to the right.

Cards in database (bottom right): This shows a list of all the cards in the database after the filter is applied, in the specified sort order. If you want to add one of the cards to the currently selected deck, click on the blue arrow pointing to the left after selecting the card in this table.

Filter/Sort: These two selection controls are below the Cards in database table.

Filter: This determines what subset of cards is shown in the Cards in database table. The options are: All, Minions, Spells, or Weapons.

Sort: This determines what order both the Cards in selected deck and Cards in database are shown in. Options are: Alphabetical (A-Z), Cost, and Type (Minions, spells, weapons).

Card description: The description for the card which was selected last in the Cards in database or Cards in selected deck tables is shown here. Information includes: Type, Cost, Text, Rarity, and Attack and Defense stats (for a weapon, attack and durability will be shown instead).

Search field (top right): You can search through all the cards in the database by typing in a partial or complete name of the card here.

Deck management buttons (top right): These green buttons allow you create a new deck, copy, or delete the selected deck.

Classes (top right, next to management buttons): This vertical slider shows all the supported classes, and the class of the current deck will be highlighted. Also when you create a new deck it will have the class indicated by this slider at creation time. You cannot change the class of a deck once it is created.

Deck stats (left middle, below classes): This area shows the total crafting cost of the selected deck (assuming regular, not gold cards), as well as a “Cards per cost” table that shows how many of each card there is per cost. The first line of numbers (0 1 2 3 4…) have a blue font and represent the costs, and the second line (with turquoise background and black font) show the number of cards in the currently selected deck with that cost.

Rename deck (left middle, below Decks table): This field allows you to change the name of the currently selected deck.

Save to PB/Load from PB (top left): buttons used to save or load a deck to the pasteboard. I’ll discuss these in more detail in an upcoming post.

Save (bottom right): This button saves any changes made to existing decks or any new decks created. Normally leaving this screen via the “Back” button (top left) will automatically save changes, but to be safe you might want to click this button anyway.

 

(“Deck Simulator for Hearthstone” is currently available on the Apple iTunes store for iPad)

 

 

 

 

 

Decks included in the simulator’s database and deck evolution

The Deck Simulator for Hearthstone app includes a database of decks that are intended to be used as comparison points against decks you make, with the goal of classifying their strength. These were mostly made by myself, my friends, or from decks I picked up online somewhere. However three of the decks included were designed with the help of an evolutionary algorithm that I created:

  • Evolved Paladin 205
  • Evolved Paladin 215
  • Evolved Warrior

Describing the entire algorithm in detail would be be quite lengthy, so for now I’ll just describe it briefly from a high level:

1) Create a bunch of decks with random cards

2) Play a single-elimanation tournament until the winner is decided, and rank the decks by their win rate

3) Get rid of the lower-ranking decks and replace them with mutated versions of the higher-ranking decks. For example I might remove or replace a random card or two

4) Go back to step #2

After going through the process through hundred of iterations (tournaments), if things went well the winning decks should be quite strong. It took a lot of trial and error and parameter tweaking, but eventually I ‘evolved’ a few decks that weren’t so bad. The above three are some of the better ones from that group.

I’m not going to give the full deck lists here, but if you are curious please consider downloading the app on iTunes . I will say that their crafting cost isn’t cheap (two of the decks are over 9000). Also it’s interesting that all three of them just happen to have Ragnaros the Firelord (one of my favorite cards).

I haven’t tried any of these decks in real games online, but if you happen to own the cards feel free to try them out and let me know how they perform.

 

 

Deck Simulator for Hearthstone: Practical usage example 1

The posts up to this point have mostly been about various features of the simulator, however there hasn’t been much talk about how to actually use it for a useful purpose.

In this post I’ll go over a practical example and give all the steps involved to help you understand how you can use the simulator to help your deck construction.

One of my decks contains a Ragnaros the Firelord card, and I have noticed many times that when I am able to play it I have a pretty good chance of winning. However, I’m not sure if this is really the case or if it’s my biased thinking. If Ragnaros is really not helping me as much as I think I could turn it to dust and use that dust to craft cards to buff up my decks.

Let’s use the simulator to see how much effect Ragnaros actually has on my win rate.

1) Download the app from the apple app store (iTunes)  and run it.

2) Click Edit Decks.

3) I included this specific deck in the database, it’s called “J’s mage deck”. Click on that deck and then on “Copy deck” on the top right side of the screen.

4) Click on the field next to “Rename deck:” (under the deck list) and change the name from “J’s Mage Deck (Copy 1)” to “J’s Mage Deck Var 1”

5) Do steps 3 and 4 again and create another copy called “J’s Mage Deck Var 2”

6) Click on “J’s Mage Deck Var 1” and then click on Ragnaros in the “Cards in Selected Deck” table. He’s near the bottom.

7) Now click on the right arrow (looks like a triangle pointing right) to remove the card.

8) Now find “Sunwalker” (4/5 Taunt, Divine shield for 6) card in the “Cards in database” list. It’s sorted by alphabetical order by default so scroll down to the S’s and you’ll find it easily.

9) Click on the left arrow (directly below the right one) to transfer the card to the deck.

10) Now do the same process for “J’s Mage Deck Var 2”, except this time choose “Goldshire Footman” (1/2 Taunt for 1)

11) Next click the black “Save” button on the bottom right to make sure both decks are saved in the database. Now even if you close the app or restart your device the decks will be saved.

12) Now leave the Edit Decks area by clicking Back (top left of the screen), and click on the “Simulate” button.

13) Click on “Evolved Planner (med)” on the left under “Players” and then “Evolved Paladin 215” on the right under “Decks”. This is one of the strongest combinations in the starting database and is used as a reference to judge the other deck’s strengths.

14) Now click the “Add to Simulation” button in the middle of the screen. This adds the combination of deck and AI player to the list of participants.

15) Now repeat the above steps for the following combinations:

(Note: You don’t need to click on “Evolved Planner (med)” each time since it should stay selected)

  • “Evolved Planned (med)” / “J’s Mage Deck”
  • “Evolved Planned (med)” / “J’s Mage Deck Var 1”
  • “Evolved Planned (med)” / “J’s Mage Deck Var 2”

16) Click on “All play all” under “simulation type” in the bottom left.

17) Set “Matches per pairing” to 100 (or something close) using the slider or clicking on the initial value (20) and using your virtual (or physical) keyboard.

18) Finally, click “Start simulation”!

19) Because of the planner AI type this simulation may take a little time. It depends on the device you have but it should be done in a few minutes at most. You can watch the game results updated live and guess how things will turn out.

20) Here are the results I got:

  • Evolved Planner (med) > Evolved Paladin 215    Wins 85.3%
  • Evolved Planner (med) > J’s Mage Deck    Wins 43.1%
  • Evolved Planner (med) > J’s Mage Deck  Var 1   Wins 35.9%
  • Evolved Planner (med) > J’s Mage Deck   Var 2   Wins 35.6%

Here is what we can determine from the results:

1) My original deck is significantly weaker than “Evolved Paladin 215”

2) Removing Ragnarok and replacing him with another card seems to reduce my win rate vs roughly 8%.

3) Whether I swap Ragnaros with Sunwalker or Goldshire Footman doesn’t make much difference. The 0.3% difference between those two decks isn’t statistically significant

Thinking about this, I think the results are reasonable. I wasn’t expecting a major increase in wins (30% or more), but rather something a bit smaller which matches with that the simulator computed.

Of course we could run more tests, like including more decks to see how the modified decks play against other decks, or even run the same simulation again to see how statistically accurate the results are. If we get results that are very different from the first time we could consider running the test again with a much greater number of matches (say 200 or 300) for a more accurate result. I did this and ended up with “79.2% 46.9% 41.9% and 32.0%” for the winning percentages, with the decks in the same order as above. This shows us that the Var 1 deck might actually be a little stronger than Var 2 (again this seems logical), but regardless both variation decks are significantly weaker than the original deck with Ragnaros.

I was curious so I ran the same simulation again, this time with 300 matches per pairing. I ended up with results very similar to my first run, which increases my trust in them: “85.5% 45.0% 35.6% 33.9%”. Ragnaros is giving around 9% increase in wins, and the two variation decks are pretty similar in strength (win rates are within 2%).

Although it may seem like there was many steps involved here, once you try the process yourself you’ll quickly get the hang of it, and be running simulations of your own in no time. And don’t forget that getting the most out of Deck Simulator for Hearthstone will take some effort – the program is really intended as a research tool more than anything else, and that implies a bit of trial-and-error.

 

Disclaimer: Hearthstone is a trademark or registered trademark of Blizzard Entertainment, Inc., in the U.S. and/or other countries. 

 

Artificial Intelligence types in Deck Simulator for Hearthstone

The evaluation of deck strength done by the simulator is critically dependent on the brains behind the computer-controlled players which are making the decisions at each turn. The types of choices that have to be made include:

  • What cards should be redrawn at the beginning of the game?
  • What cards should I play?
  • What target(s) should I choose for spells and effects?
  • What minions should I attack with and whom should I target (other minions or the enemy player)?
  • For “choose-one” type spells, which spell should be used?

As of the current version of the game, there are 7 different types of AI players available when you configure a simulation. However, for the most part these can be divided into two types of play style, Heuristic and Planner.

Heuristic style is where I have handpicked a bunch of rules (around 30) to control different aspects of the game. For example, when there are no Taunt minions in play, should I attack the enemy player directly or try to kill his/her minions first? Should I only play minions when their battle cries have a valid target, or play them as soon as I can? There are a bunch of heuristics like this that I created one-by-one through many game replays and thinking about what a human would do.

The best example of the Heuristic style is the “Evolved AI (Strong)” player which is has the added benefit of a series of rules which I optimized via hundreds of iterations of a evolutionary algorithm. The process for ‘evolving’ a strong AI is not directly available in the game at present, but some day I hope to make it so.

“1st generation (weak)” is also a heuristic AI, but it is very simple with only a few rules, and is therefore very weak. I left it in mainly for historical reasons and so you can see the full effect of a good AI vs a bad one.

The other style, Planner, is significantly more advanced and involves looking at an entire turn instead of action by action. The planner looks for different possibilities in terms of the above choices (card playing, attacks, etc.) and then does a evaluation for the end result at the end of the turn after those actions are done. This allows finding multi-card combos, such as casting a spell to deal 1 damage to a enemy minions, then attacking that same minion to destroy it.

As you might guess, planner AI types are generally stronger than heuristic AI, however they take more time because of the many scenarios that have be evaluated each turn. “Evolved Planer (quick)” and “Evolved Planner (med)” are two examples of this AI type, where the first looks at a relatively limited number of possibilities and the second looks at many more possibilities.  The weighting factors used for these AIs were also optimized to use evolutionary algorithms, hence the “Evolved” portion of the name.

So which AI should you use in your simulations?

If you want a quick, rough estimate of decks’ relative strengths, use the “Evolved AI (strong)”, and if you want a better estimate which will take significantly more time, use “Evolved Planner (med)”. Another drawback of Planner-style AIs is they take up much more memory, so if you run a long simulation with many participants there is a chance your device will run out of memory and the simulation will be stopped automatically. In that case you can try with less participants, less matches per pairing, or without Planner-style AIs.

I spent a good portion of my time optimizing these AIs to make them strong, although there are still cases where they will not always make the best plays. Fortunately, I noticed that the strength ranking of a few decks doesn’t seem to change too much regardless of which AI is used (excepting the “1st generation (weak)” one). I still may add the ability to tweak AI parameters in a future release just because it’s fun.

 

 

 

 

 

 

RNG, Hearthstone, and the simulator

The other day I was speaking with a friend and when I mentioned Hearthstone he immediately said “I don’t like Hearthstone very much because there is too much RNG”.

RNG, which stands for “Random Number Generation”, is defined by Hearthstone Wiki as “the unpredictable outcome of a situation featuring a significantly randomized element”. In other words, the more RNG there is, the more possibility that your win or loss was a result of random odds as opposed to purposeful strategy and good deck construction. Chess would be an example of a game with zero RNG since it’s completely non-random, and a slot machine would be an example of a game that is nearly 100% RNG. All card games that involve shuffling have RNG to a certain extent.

I would agree that there is a major element of randomness in Hearthstone. After all, every game you start with a hand that is random drawn from your 30-card deck, and many card effects have a major random element. For example, Arcane Missles, which deals 3 damage randomly split among characters. Or one of my favorite cards, Ragnaros the Firelord, which deals 8 damage to a random player or minion.

Surely, there are things which offset the randomness of the game, such as the redraw system, and a strategic player who calculates correctly can make choices where the outcome of random effects is most likely to benefit them – for example killing off certain minions and letting random effects take down the remaining ones.

Having said that, I would argue that the result of a single game between two decks in Hearthstone doesn’t say too much about either the strength of the decks or the ability of the players. I actually think in this case the number of turns before the game ended more accurately predicts how close the decks are in strength. The more turns the loser managed to stay alive, the closer the decks are.

The realization that Hearthstone contains a good amount of RNG is another thing that motivated me to create Deck Simulator for Hearthstone. Surely playing a handful of matches with a real opponent gives you some idea of the strengths of each deck and player, but what if you could to run 100, even 1000 games in a matter of seconds or minutes?

That is exactly what the simulator allows, and even if the AI players are not exactly ‘ideal’ in terms of playing the perfect move in all situations, as long as they play reasonably good moves the win/loss ratio between two decks should give a good indication of which deck is stronger.

As I mentioned in the last post, the number of games played between each to pairings during a simulation is determined by the “Matches per pairing” slider, which defaults to 20. The reason I set 20 as the default is I felt it was the lowest value that gave some a good estimate of the relative deck strengths. Any less than that and RNG takes over and the result isn’t too statistically meaningful.

The maximum matches per pairing which permitted in the simulator is 1000, which should give a very accurate idea of deck’s relative strengths. However, depending on the  AI players you have chosen and the speed of your device, this could take quite some time (an hour or more).

Therefore, effective use of the simulator requires picking a good number of matches per pairing. Here are my general recommendations:

 

20: Use this if you want a very, very rough estimation of the decks’ strengths

100: Use this for a rough estimate that carries more weight

200-300: A good middle ground for simulation accuracy vs wait time. This is the most you’ll need for most situations.

1000: Only needed when you really want to be sure the relative strengths of decks, such as when you decide to craft new cards to make a new deck or improve an old one. I recommend limiting the number of participants to 2 only a small handful to avoid long simulation wait times.

 

While there are several different ways to measure statistical reliability and I may add some of these in upcoming releases, there is a very simple way to check how accurate your results are. Do a full simulation run then take a screenshot to capture the top of the results table. Then re-run the simulation (via the green “Restart simulation” button on the top right part of the simulation screen) and take another snapshot. You can do the same thing again two or three more times if you like.

Then compare the results of each simulation run. The less number of matches you use, the more variation you will see between simulation results. If you see one run where a certain deck is #1 (highest on the results list) and another where it is #5, you know you need to increase your number of runs and try again. You should aim for a number of matches where the general ranking and order is mostly consistent, but the win ratios can be a few percentages different between simulation runs.

I’m curious to hear about your experiences using the simulator and what sorts of parameters and simulation types you’re using, so please feel free to comment to this post!

(Just for the record, I don’t think Hearthstone has too much RNG, but rather a reasonable amount of it given it is a card game)

References

http://hearthstone.gamepedia.com/RNG

http://hearthstone.gamepedia.com/Random_effect

(Featured image of Hearthstone card “Ragnaros the Fireload”, taken from Hearthstone wiki (http://hearthstone.gamepedia.com/Ragnaros_the_Firelord) but is trademarked and copyrighted by Blizzard Entertainment)