Coder Social home page Coder Social logo

hearthsim's Introduction

#HearthSim

Build Status

HearthSim 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.

The code has two main components: the game mechanics and the AI.

##Game Mechanics

The game mechanics include the implementation of individual cards as well as the turn based draw card, use card, and attack mechanisms.

The state of the game is represented in with the BoardState class. The BoardState is the combined states of: hero state, friendly minions, enemy hero state, enemy minions, the cards in the hero's hand, and how many cards have been drawn from the deck. All actions in the game are represented as changes to the given BoardState.

Each card and minion is modeled as a derivative of the Card class. The job of each card is to manipulate the BoardState upon its use, either from the hero's hand or from the board as a minion.

Finally, there is the BoardStateFactory class, whose job is to recursively generate all possible BoardStates resulting from taking all possibles actions from a single starting BoardState.

##AI Model

Detailed AI model descrition can be found here.

Addendum I: Divine Shield modeling
Addendum II: Random effects modeling

The essence of the AI model is the score function, which is a function of BoardState. For each BoardState generated by the BoardStateFactory, the AI determines the score and picks the chain of BoardStates resulting in the highest score as its play. The difference in AI really just comes down to the difference in the scoring function it uses.

##Running Simulations

###Pre-compiled GUI

Pre-compiled versions can be downloaded from HearthSim downloads page.

HearthSim GUI

###Command line

There is an example simulation setup in the example directory. You can run the project easily by executing:

./gradlew runSim

and configure the simulation parameter file within gradle.properties.

The GUI can be run via

./gradlew runGui

##Some Results

You can find some simulation results HearthSim board or on my blog.

Effect of The Coin
Effect of direct damage spells
Effect of taunts
Effect of divine shield
Effect of additional card draw

##Some Benchmarks

Simulations have been run on Digital Ocean machines for some performance benchmarks. Currently the simulations have been run once, with no variation in decks/ai/etc. Eventually we would like to keep track of performance with each release, and perform more varied testing with different BoardStateFactories etc. Decks were always deck0.hsdeck and deck1.hsdeck from example1.

Machine 1

DigitalOcean 1 CPU, 512MB Ram

  • CPU op-mode(s): 32-bit, 64-bit
  • CPU(s): 1
  • Thread(s) per core: 1
  • Vendor ID: GenuineIntel
  • CPU MHz: 2399.998
  • L1d cache: 32K
  • L1i cache: 32K
  • L2 cache: 256K
  • L3 cache: 15360K
Test 1
  • num_simulations: 1000
  • num_threads: 4
  • average time per game: 4.14 seconds
Test 2
  • num_simulations: 1000
  • num_threads: 1
  • average time per game: 5.73 seconds
Machine 2

DigitalOcean 4 CPU, 8GB Ram

  • Architecture: x86_64
  • CPU op-mode(s): 32-bit, 64-bit
  • CPU(s): 4
  • Thread(s) per core: 1
  • Vendor ID: GenuineIntel
  • CPU MHz: 2399.998
  • L1d cache: 32K
  • L1i cache: 32K
  • L2 cache: 256K
  • L3 cache: 15360K
Test 1
  • num_simulations: 100
  • num_threads: 4
  • average time per game: 1.58 seconds
Test 2
  • num_simulations: 10
  • num_threads: 1
  • average time per game: 5.58 seconds

##Contributing

To contribute, follow the usual procedure: fork, make changes, and submit a pull request.

##Acknowledgements YourKit supports the HearthSim project with its full-featured Java Profiler.

YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.

yourkit

hearthsim's People

Contributors

clayjacobs avatar future87 avatar kallin avatar mrhen avatar oyachai avatar rutnar avatar slaymaker1907 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.