7 ms·
Show HN: HearthSim, an AI and game simulator for Hearthstone Heroes of Warcraft
- ntaso 12y agoHearthSim is a generic Hearthstone game simulator and AI, designed to run large numbers of simulated AI vs AI games in order to test and understand the values of various game mechanics and cards. Then I read an article about The Coin on OP's blog: http://buddypanda.com/?p=65 http://buddypanda.com/?p=65 and I don't think that the simulator is that useful. Maybe I'm too dumb to understand this, but my intuitive idea is that a card like The Coin gives you various advantages and no disadvantages, since it is an extra card that comes for free and gives you more flexibility. How come then, that the simulator says that the player actually wins more games without The Coin? Hearthstone isn't mainly about random encounters between AI opponents, but to gain advantage in material over your opponent over the course of the game. Sometimes, 1hp, 1 card, 1 round is sufficient to decide over victory or defeat. If the simulator neglects hero abilities (as in The Coin article), my guess would be that it's not too accurate. However, I thought that a simulator for Hearthstone would be a great idea. I think you're onto something here, but I'd like to see a few more use cases that match my intuition I gained from playing hundreds of games of Hearthstone.
- NickPollard 12y agoIn that article, he shows that giving the coin to p1 (the 2nd player, it's 0-based) gives a /disadvantage/ to p0 (the 1st player), so it is actually beneficial for the player who gets the coin.
- dtech 12y agoIn the simulator maybe, but according to Blizzard statistics going first has a small advantage (51%-53% winrate in feb 2014: http://www.hearthpwn.com/news/296-developer-interview-with-eric-dodds-and-ben-brode http://www.hearthpwn.com/news/296-developer-interview-with-e...). It was much greater before the extra card and coin was added.
- oyachai 12y agoThat might be true. The advantage that The Coin gives you is highly dependent on the deck that you have. In that particular deck that I used in the simulations, the advantage is rather large. For a deck consisting of stronger (higher mana) cards, the advantage is much smaller. I think it's basically due to the fact that a 2-mana drop vs 1-mana drop is much stronger than a 7-mana drop vs a 6-mana drop.
- NickPollard 12y agoYes, sorry I was referring to his numbers in the simulator rather than in the actual game. In the game it depends on the deck - for some decks, it's more useful than others, either due to particular mana curves, or to triggered effects (the coin counts as a spell, so can trigger cards like Gadgetzan Auctioneer or Wild Pyromancer)
- Kiro 12y agoI don't see anything about The Coin in that interview. Where did you get 51%-53% from?
- dtech 12y agoIt's right there > Ben: It's about three percent better to go first over second. The 51% was mentioned is in a previous Blizzcon QA
- deleted 12y ago[deleted]
- JoeAltmaier 12y agoAdding a 'pretty good' card to a deck means you might draw that card when you need a critical one. Even though 'The Coin' is good, it may not work (as well) with the rest of the cards. As you say, 1 card, 1 round can decide the game.
- arrogant 12y agoWhile this is true in the general case, The Coin is an extra card added to your hand at the beginning of the game and is never a part of your deck. It is purely beneficial.
- infiniteri 12y agoIt is. Additionally the person who gets the Coin also gets an extra card in their starting hand. You can "mulligan" this card, or swap it out of your starting hand for another draw. Although this might seem relatively trivial, having an extra chance to mulligan a card increases your chances significantly of getting a card that you want in a specific matchup.
- MattRL 12y agoIn Hearthstone the coin is an extra card that the second player is always given at the start of the game, so no such disadvantage in Hearthstone.
- epriest 12y ago> How come then, that the simulator says that the player actually wins more games without The Coin? This isn't what the results say. The win rate for the player who goes first ("Player 0") rose from 41% to 61% when the player who goes second ("Player 1") was not given The Coin. This is summarized in the text: > The Coin basically makes what used to be a first player advantage into a first player disadvantage. Not bad for a single card!
- ntaso 12y agoAh, misunderstanding from my side. Thanks for clarifying.
- Lockyy 12y agoAnd don't forget the further upside of going second, you get an extra card in your starting hand. I really do feel like going second is far superior to going first right now.
- ciaranm 12y agoAs far as I'm aware, official stats from Blizzard is that the player going first is wins a higher % of the time than going second, despite the coin. I'll try and find the source. User dtech already found the source for me (: -> https://news.ycombinator.com/item?id=8020232 https://news.ycombinator.com/item?id=8020232
- goldenkey 12y agoNot with all decks though apparently. Freeze mage can benefit from the coin immensely
- ohashi 12y agoMiracle rogue too (coin defias ringleader anyone?). Certain rush/zoo decks to get extra minions out faster can be overwhelming.
- ciaranm 12y agoI appreciate your point about coin being stronger in some decks than others - that doesn't change the fact that across _all_ of the games of hearthstone being played, if you go first you're more likely to win than if you go second.
- deleted 12y ago[deleted]
- king_jester 12y ago> Maybe I'm too dumb to understand this, but my intuitive idea is that a card like The Coin gives you various advantages and no disadvantages, since it is an extra card that comes for free and gives you more flexibility. The Coin does indeed give you advantages with no downside. However, the reason why you get the coin has to do with the mechanics of Hearthstone. In the case where The Coin didn't exist, you would be at a severe disadvantage if you didn't go first. In Hearthstone, since you can generally control where your minions attack, going first gives you tempo. If your opponent didn't have the coin, as the player going first you could permanently maintain your tempo and win with regularity (depending on what cards you draw). In card games it is important that tempo be something that can change in the course of the game in order to make things more fair.
- Vaskivo 12y agoIMO the Coin is a tricky thing. While you can argue that it balances the two player, the second player has the additional choice of when to use the Coin. The first player has the advantage of going first. That is a given advantage, with no choice involved. It is harder to "waste" that advantage. The Coin, on the other hand, is much more linked to choice (when to use) and therefore, easily wasted. It is also an additional "thing" for the second player to think about when playing, while the first player doesn't have this burden.
- rcthompson 12y agoPlayer 1 gets the coin, but the table is listing Player 0's win percentage. So when you give the coin to Player 1, Player 0's win percentage goes down. So yes, the coin is a massive advantage. In other words, the player wins more 20% games when the opponent doesn't get the coin, all else being equal. If you want some real-world stats about going first vs. second, try the stats from Arena Mastery[1], which more or less match what Bilzzard has said anecdotally: with the second player getting the coin, going first is still a slight advantage. [1] http://arenamastery.com/sitewide.php http://arenamastery.com/sitewide.php
- minimaxir 12y agoNote that the game only implements about 50 cards of the 382 cards available in the game: https://github.com/oyachai/HearthSim/tree/master/test/com/hearthsim/test/card https://github.com/oyachai/HearthSim/tree/master/test/com/he... BTW, if you haven't tried it yet, Hearthstone is a great CCG with a very fair progression system and very good polish/balance.
- oyachai 12y agoYep, I'm up to about 100 cards at this time, working on the basic cards first. Besides the cards, there needs to be more work on the AI modeling... currently, it won't handle any card with elements of randomness to it. I think I have an idea on how to treat it (without the AI cheating), so that implementation is coming up... soon.
- TheMakeA 12y agoAre you implementing each card by hand? I was going to make something like this and was just going to regex match all of the cards (from HearthPwn). It seemed like there were few enough variations to make something like that possible. Curious if you already tried automating it.
- oyachai 12y agoA lot of the cards are more or less automatically generated in the sense that they don't actually extend any functionality of the parent class. Variations in the special effects ("text" effects) are big enough that for those, I find implementing them one by one much easier.
- _halgari 12y agoI'm a bit against the code style: https://github.com/oyachai/HearthSim/blob/master/src/com/hearthsim/card/spellcard/concrete/ArcaneExplosion.java https://github.com/oyachai/HearthSim/blob/master/src/com/hea... So the card that does the damage has to do the removal check for the minions? Talk about duplication of code. Wouldn't something like this be better: engine.dealDamage(1).to(Category.EnemyMinions);
- _halgari 12y agoOr better yet, write the entire thing in a logic programming DSL.
- Kiro 12y agoDSL as in write your own language? That sounds complex.
- oyachai 12y agoGood suggestion, let me think about that.
- jdmichal 12y agoIf I may, I would suggest thinking about things in a way very similar to how Magic: The Gathering does, which is as a "state-based effect" or "triggered effect". This models very well into programming as event handlers watching state-changes and acting appropriately. For instance, the most common state-based effect in MTG is death from damage. This is perhaps even easier to model in Hearthstone, as damage is persistent. Simply register event handlers on minions which get called whenever the health of a minion changes; if it's <= 0, trigger death. Death will then cause any "triggered effects" to fire, such as a deathrattle tigger. This is also easy; just a listener on the death event.
- oyachai 12y agoThe event/listener paradigm is an interesting way of going about this, and I considered doing it that way at the beginning. But, after some thinking and experimenting, I found the "card use -> modify BoardState" way more straight forward, especially since it leads to a nice recursive tree structure for the game AI engine. The primary goal of this simulator is to do statistical analysis on deck performance, so I think it's a decent way of going about it. On the other hand, if my goal were to create an actual playable game clone, I probably would have taken the event/listener approach.
- z131 12y agoDear god thank you for not writing this in javascript.
- oyachai 12y agoSimulation speed is of primary concern here (though javascript isn't too shabby)! I actually have a C++ version too, but I thought Java might be more accessible to more people...
- z131 12y agoI completely understand the need for speed, which is why I'm happy you picked something like Java. It's just with the popularity of Javascript on HN, I was worried that it would be yet another JS project.
- slapresta 12y agoHow can simulation speed be a concern in a turn-based card game?
- oyachai 12y agoHearthSim is designed purely as a AI vs AI game simulation tool. It's not a "playable" Hearthstone clone. In the examples on my blog, I usually run 40,000 simulated games per data point, and each set of 40,000 games usually takes a few hours to run on a relatively modern PC.
- lambada 12y agoBecause this simulation is concerned with simulating as many games as possible. So overall speed matters.
- Kiro 12y agoI'm working on a version in JavaScript. I will send it to you when it's done.
- gavanwoolery 12y agoIn order to balance the game I am working on, I am planning to use a somewhat similar automated system (although its good to note, you can get a very interesting statistical analysis by ignoring the AI and just playing random cards/skills/whatever you are testing against each other). This of course works best if you are selecting two discrete subsets of one superset and playing with card variance (random decks, control decks with only one different card between them, etc). Off topic: I've played Heathstone enough to appreciate it. It is a good game (I'd give it maybe 4.5 stars), but not perfect; my critiques: - Chance of winning is based largely on luck - the same deck drawn two different ways can be almost a guaranteed win/fail, even if it is balanced. - Card starvation is way too common of a problem. Could not count how many times I ended up exhausting the deck, even with plenty of cards to counter it. When you only have one card to play at a time, the game becomes rather dull. - Classing leads to a certain lack of permutation and surprise - most decks have a few basic strategies. - Cards outside of the class decks tend to be fairly generic feeling for the most part. Many cards feel a bit mundane compared to other CCGs. - Free to play model hurts the game a bit - I don't mind paying money, but many aspects of the game feel too grindy (in order to get you to pay money).
- ciaranm 12y agoFYI - the way your comment is formatted caused text to be hidden in a horizontal scroll bar which wasn't visible on Chrome on OS X - took me a good minute to figure out what was going on.
- gavanwoolery 12y agothink I fixed it...
- ciaranm 12y agoI think you fixed it as I was replying - please ignore!
- deleted 12y ago[deleted]
- j2kun 12y agoJust curious: have you watched any of these games to see what kinds of mistakes the AI makes for various settings of the parameters in your scoring functions? Also, I'd be interested in doing offline learning. For example, if you have some formal way to record the actions taken in a game, you could ask pro players to submit their games. Of course, this would require Blizzard to allow a replay mechanism like it does for starcraft. But it would make the AI design process much more interesting than exploring game trees (without perfect information) or greedily picking the best single move.
- oyachai 12y agoI have informally looked at what the AI does. Turns out, as far as I can see, the AI does a pretty good job... with a BIG CAVEAT. The decks that I have used so far consist solely of minions and one other special card, so there really isn't any "mistakes" the AI can make. The decks are just so simplistic at this point. As more interesting cards are implemented, I'm sure there will be situations where the AI will make interesting mistakes that we can learn from. It is something I'm really looking forward to exploring.
- ionforce 12y agoYou have no idea how excited this project makes me. I have a total nerd boner for AI and Hearthstone, so... I'm hyperventilating right now. Hopefully I can grok your work and maybe I can contribute!
- oyachai 12y agoI'm a sucker for AI and Hearthstone too :) I'd love any contribution and collaboration!
- paulgerhardt 12y agoCan someone clarify if this is the same HearthStone AI/Machine Learning project being presented at DEF CON this year by Elie and Celine Bursztein[1]? [1] https://www.defcon.org/html/defcon-22/dc-22-speakers.html#Bursztein https://www.defcon.org/html/defcon-22/dc-22-speakers.html#Bu...
- oyachai 12y agoI'm not affiliated with those guys, but the project definitely looks interesting!
- faizshah 12y agoThere's another pretty good one that I found a few days ago on github, I don't think it's the same as the one you're talking about, but it seems to be more complete than the OP's. https://github.com/danielyule/hearthstone-simulator https://github.com/danielyule/hearthstone-simulator
- dsjoerg 12y agoVery cool! Isn't there some kind of copyright or terms-of-service violation involved in publishing this?
- mischanix 12y agoSeeing as it doesn't reproduce the functionality of the Hearthstone client or server in its entirety, I think it falls in the same category as fansites such as Hearthpwn. Blizzard could probably pursue a successful takedown, but I can't see a good reason to put resources there when there are things like WoW private servers that pose a legitimate business threat.
- oyachai 12y agoI think it's not a problem... This is not a playable clone of the game. It's purely for deck analysis, kind of like how SimulationCraft is a DPS simulation and analysis tool for World of Warcraft.
- anonymoushn 12y agoDoes this implement the many completely undocumented corners of the game correctly? Some examples: http://www.reddit.com/r/hearthstone/comments/24tvce/unwritten_effects/ http://www.reddit.com/r/hearthstone/comments/24tvce/unwritte... Some examples from personal experience: Ongoing effects last until a player could act, not until the minion causing them leaves the battlefield. So if you trade your 2/3 harvest golem for your opponent's 6/2 stormwind commander, they both die, you get a 2/1 damaged golem, and your knife juggler throws a knife at your opponent's wisp, the wisp will take 1 damage, go down to 2/1, then lose the buff from stormwind commander (who died a long time ago!) and go down to 1/1. If you have a young priestess and a 1/1 imp master, your imp master can kill itself and your young priestess can target your dead imp master with her buff. This will not bring the imp master back to life, you just miss out on your buff for the turn.
- oyachai 12y agoMost definitely... not. Well, since Harvest Golem is not yet implemented, the subtle nuances are beyond the scope anyways. It's something I will have to go through to get it right in due course. Having said that, the focus (of my curiosity) is in AI modeling at a broader (higher?) level, so I think will be concentrating on that aspect for now.
- esturk 12y agoI was confused for a moment on what you meant, but I believe you were referring to the 'Stormwind Champion'. In the future Naxx release, they will implement a queue to keep track of the timestamp that each creature enters the board. All effect that triggers/depletes from a 'mass death' will take place in the order of each card's timestamp, earliest first. So for the 2nd example, it depends on which creature came into play first. If Young Priestess, then Imp Master doesn't lose health and you get a 1/1 imp. If Imp Master first, then Imp is spawned and gets buffed but the master dies.
- anonymoushn 12y agoWhoops! I am not sure if this will fix young priestess thing - the issue is that the young priestess chooses its target before the imp master uses its ability, but uses its ability after the imp master does.
- dnesteruk 12y agoInteresting, I've written very much the same thing with the same name. Only difference is I've written it using C++.