Git Product home page Git Product logo

hs-predictor's Introduction

TC-130 Random Damage Predictor

The TC-130 Random Damage Predictor will calculate the odds of different spreads of damage from random spells like Arcane Missiles, Avenging Wrath, or Mad Bomber.

Use it live here: http://pindia.github.io/hs-predictor

On the top row, input the amount of random damage coming from sources that target enemies only (e.g. Arcane Missiles> on the left and the amount that target all characters (e.g. Mad Bomber) on the right. Input the enemy board state on the middle row and your board state on the bottom.

Under each characters its probability distribution will appear. The number is an amount of damage it might receive, and the percent is the probability of exactly that amount being received.

The page URL automatically updates as you change the inputs. This means you can bookmark a particular setup or post a link to it to show a cool situation or Prove Someone Wrong on the Internet (tm).

How does it work?

Unlike similar tools, which run a large number of simulated trials to get results, TC-130 is able to calculate results exactly in most cases. It's the difference between calculating the odds of getting ten heads in a row is (1/2)^10 = 1/1024 = .09765625% and actually flipping the coin 10,000 times, getting 9 heads, and saying the odds are 9/10000 = .09%.

Internally it uses a recursive algorithm that is conceptually similar to drawing a probability tree. Combined with a super-optimized undo system, it's able to multiply and sum the odds of all the possiblities very fast.

For simple scenarios this is actually faster than simulation. However for situations with many minions or lots of damage it slows down very quickly. For these complex situations TC-130 will automatically switch to the simulation method. (For you techies out there, the problem is that calculation is O(2^n) while simulation is O(n*m) where n is the amount of damage and m is the number of trials to simulate.)

You can see the core implementation (only 100 lines) here: https://github.com/pindia/hs-predictor/blob/master/core.coffee

hs-predictor's People

Contributors

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