Author Topic: Cheat sheet to evaluate battle outcomes  (Read 221 times)

0 Members and 1 Guest are viewing this topic.

Fluffhead

  • Newbie
  • *
  • Posts: 4
    • View Profile
Cheat sheet to evaluate battle outcomes
« on: May 11, 2017, 10:38:07 PM »
I made this table as a cheat sheet when deciding whether to attack another player or bane.


It tells you the average damage you will take (rounded) during a battle given the dice count of you and your opponent.  Look at your equipment and theirs and add (their additional swords)-(your additional shields) to account for most equipment effects.  Also don't forget to count the additional dice given to a bane by your rot or given by equipment to players.  Also account for extra dice due to affinity.

Obviously this can also be used to evaluate the damage your opponent would take by switching your/their dice and instead adding (your additional swords)-(their additional shields).

EDIT:  To be clear: this does take into account the infinite scenarios represented by exploding dice and the many scenarios where 0 damage is taken due to all attacks being blocked.

Enjoy!
« Last Edit: May 16, 2017, 02:58:09 AM by Fluffhead »

Darcy Smith

  • League of Geeks | Developer
  • Member
  • *****
  • Posts: 711
    • View Profile
Re: Cheat sheet to evaluate battle outcomes
« Reply #1 on: May 15, 2017, 05:29:59 PM »
THIS IS SO AWESOME! Sharing with the team, thanks for hitting us up with this!!!


<3 Darcy

Fluffhead

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Cheat sheet to evaluate battle outcomes
« Reply #2 on: May 16, 2017, 02:39:58 AM »
I'm glad you appreciate this Darcy.  I noticed a typo in my code and replaced my table with an updated one so please disregard the old numbers, they were slightly off.  The current table should be correct.

The development team could confirm my numbers by just simulating fights using the game logic thousands of times and averaging damage taken (maybe 100,000 times for my dice=4, their dice=6 just to confirm, 2.83 is the value at more precision).  I did not compute them this way so this would be a good exercise if these numbers were being used for development decisions.

In case you have some knowledge of probability theory, I will describe my own approach to producing these numbers which involves identifying the probability distributions for attacks and blocks.  This is much more useful than just having an average because it allows computing probabilities of anything.  For instance, perhaps it is more useful to know your probability of surviving than the average damage you will take. 

Shields
Let's start with the number of shields your character will get.  The first step is determining the chance of a particular starting die resulting in a shield.  It is not 1/6 because that is only the chance of initially rolling a shield.  We can roll any number of explosions and then a shield.  In other words, the probability of rolling a shield = rolling a shield or rolling an explosion and then a shield or rolling an explosion, another explosion and then a shield or ... (infinite possibilities) =


So looking at a single die we have a 1/5 probability of getting a shield (easier to see simply by considering that every initial die must eventually land on a non-explosion and this is the only time you can get a shield... and shields represent 1/5 of possibilities among non-explosion rolls).

Okay so assuming we have n dice, what is the probability distribution of # of shields rolled?  This is called a binomial distribution n=# dice, p=1/5.  We have n dice and each has 1/5 chance of resulting in a shield, so # of shields is a binomial distribution.  In probability theory we have a shortcut for calculating the average for this: np.  So in this case that's (#dice)*1/5.  This is the average number of shields rolled with n dice.

Refer to this for an explanation of the Binomial Distribution and notice on the right it says "mean=np".  This is what we're using.

Attacks
This is a much harder problem, but becomes manageable if you break it down the right way.  Suns are attacks during the day and moons at night so either way we have two possible non-explosion attack values: sword or the relevant day/night roll.  Using the logic above, this makes the distribution for # of non-explosion attack rolls binomial with n=# dice and p=2/5.  Hence the average non-explosion attacks is np=dice*2/5

What about explosions?  We need to count those too.  Luckily the non-explosion attack rolls are limited to the number of initial dice at the start of the battle and are completely independent of how many explosion rolls you get.  Therefore it is okay to count these separately and add them. 

First we need to look at a single initial die and identify the distribution of # of explosions resulting from that die.  This is the same as counting the number of failures before the first success having a 5/6 probability (failure = rolling an explosion, success = a non-explosion).  This is called a geometric distribution with p=5/6. 

However, that's just the distribution for one initial die.  We have n dice and so we're adding n of these distributions.  Since the outcomes for each die is independent of the others, we can use a very convenient result: that the sum of n independent and identically distributed geometric random variables is a Negative Binomial Distribution with r=# dice, p=1/6 (following the wiki convention).  Notice on the side it says the mean is pr/(1-p).  For us that's dice*(1/6)/(1-1/6)=dice/5

So the average total attacks = average non-explosion attacks + average explosion attacks = dice*2/5+dice/5=dice*3/5.  (linearity of the expected value is what allows adding the two averages)

Conclusions
So you might think that the average damage taken (ignoring anything but dice count) is just
but that would only be the average if you count over-blocking as taking negative damage.  For instance if your opponent rolls 1 attack and you roll 5 shields that would be averaged in at -4 damage with that calculation. 
So the true distribution is: max(0,(opponent's # non-explosion attacks)+(opponent's # explosions)-(my # shields)) to count those 0 damage battles correctly.

That is the distribution used to calculate the numbers in the table.  Unfortunately the formula for the average of this distribution is a lengthy mess so I calculated the table by running some code.  Now that we know the distributions for everything, any probabilities involving battles can be computed. 

Note, however, that if you wanted to simultaneously calculate your own attacks and blocks you would have to account for the fact that your number of blocks and attacks are not independent (if you have 5 dice and roll 3 non-explosion attacks, you could have at most 2 shields for instance).  The above table is calculating your shields against your opponent's attacks so this is not an issue.

Darcy: I hope that the dev team can benefit from this analysis.  Let me know if the team ever confirms any of my numbers.

« Last Edit: May 16, 2017, 03:41:53 AM by Fluffhead »

Blake Mizzi

  • League of Geeks | Director
  • Administrator
  • Member
  • *****
  • Posts: 100
    • View Profile
Re: Cheat sheet to evaluate battle outcomes
« Reply #3 on: May 16, 2017, 06:10:43 PM »
This is the best :)

Fluffhead

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Cheat sheet to evaluate battle outcomes
« Reply #4 on: May 18, 2017, 03:10:15 AM »
The table is a good shortcut for making decisions, but it is not nearly as useful as seeing the entire distribution.

For instance if you look under my dice = 5, opponent's dice = 10, it says the average damage taken is 5 damage.  That one value is just a summary of the graph showing the amounts of damage you could take and the probability of each amount.

That graph for my dice=5 and opponent's dice=10 looks like this:


So you can see here that over 70% of cases are represented by damage taken in the range between 3 and 7 damage.  However, taking 4 damage is nearly as likely as taking the average amount, 5.