Show HN: Fireplace, a Hearthstone Simulator
github.com
github.com
This turned into a full-blown reimplementation of the game logic pretty fast.
As it turns out, working on this has been the most enlightening and rewarding experience I've ever had in programming. Hearthstone is a very well designed game with very few hacks (much unlike other Blizzard games) and extremely logical rules it has a lot of respect for.
Working on this, more than anything else, has been the most fun I've ever had working on a project. While it is still incomplete, I'm hoping it is of interest to someone as I would love to welcome others to the project. I'm available to answer any questions about it or the Hearthstone's internal design.
Edit: For those looking for an entry point to what this all looks like, since this is very much programmer-oriented for now, the docs I wrote on the wiki (https://github.com/jleclanche/fireplace/wiki) and the tests (https://github.com/jleclanche/fireplace/blob/master/tests/te...) are the best ones.
Blizzard doesn't make it clear. I was going to embark on a simulator just like this, except I had a hard time figuring out the weird interactions and edge cases.
For instance, I just played a game last night where there was an enemy mad scientist on the board. I play a madder bomber and it kills it, playing a secret for the mage, which turned out to be mirror entity, proccing that secret, and the board was left with me and him having a madder bomber.
I wanted to make AI for hearthstone to test and simulate things, but these weird interactions was preventing me from making a simulator like this.
There's a decent amount of noted rules on it, but you get some strange things like Kel'Thuzad ( which was completely borked on release, not sure about it now). I think the general rule is "the code is the spec"
So basically, battlecries in this case have precendence over secrets so to say. But the minion is already on the field. This is important because, say you had a Cult Master that ALSO had a "deal 1 damage" battlecry and you played it, killing one of your own minions with it: it would see the death, as it is already on the field.
Regarding Kel Thuzad, we're again talking about ordering issues. What could have happened is something such as the aura/internal tag it was setting disappearing a tad too late after its death as during end of turn, if killed by an END_TURN effect, the aura would trigger before it disappears. But all of this is extremely internal. If the designers believe it's a bug, then it's a bug. That's why I'm not touching Warsong Commander yet. :)
Fireplace itself has some documentation on the wiki. The thing is, black-box testing gives me room to actually test my own interactions and see how well they match up with the original game. Documenting the rules of the game proves itself very hard because the game's rules are extremely abstract: what you're talking about here is a series of events and I believe it looks something like this:
Player 1 plays Madder Bomber
Madder Bomber moves to the field
MadderBomber.action triggers
1 damage to Mad Scientist
1 damage to Mad Scientist
Mad Scientist TO_BE_DESTROYED
(4 more damage...)
Mad Scientist moved to GRAVEYARD
Mad Scientist triggers own deathrattle
Secret moves to PLAY Zone
CARD_PLAYED (Player1, Madder Bomber)
Mirror Entity triggers CARD_PLAYED hook and summons Madder Bomber
MINION_SUMMONED (Player1, Madder Bomber)
MINION_SUMMONED (Player2, Madder Bomber copy)
Game mechanics are almost never copyrightable, so you could come up with aliases for the cards and be 100% in the clear.
In this case, it would be relatively easy to implement a server on top of Fireplace which would communicate with a slightly modified Hearthstone client. This would be a huge no-no for Blizzard and they would try their best to shut it down, so I'm not doing that.
You'll also note that the game files I am reusing in fireplace are actually in a separate repo (hearthstone-data submodule) so that I can take it down separately, should Blizzard request it.
Edit: Part of me also hopes that Team 5, the team behind Hearthstone, is a bit different. They have been incredibly close to the community, much closer than Blizzard has with other games, and I'm hoping that if issues arise, we can work them out peacefully.
Besides doing something like this, how else would you go about testing this kind of thing?
https://github.com/jleclanche/fireplace/blob/master/tests/te...
Also, the game has excellent debug logs which I could always generate in Fireplace and compare the two or some such. And if all else fails, I can always peek at the Hearthstone protocol.
On the other hand, it has zero other dependency than python (with an optional dependency on pytest for better test output).