Probability that a set of dice scores better than another

48 Views Asked by At

I read the fighting rules for a game, and would like to calculate the probability of winning a fight with diverse configurations. Here are the rules:

The attacker throws a number $m$ of dice (depending on his attack power). Each die between $4$ and $6$ counts for one hit. The defender throws $n$ dice (depending on his defense power). Each die between $4$ and $6$ cancels a hit.

How can I calculate the distribution of hits for given $m$ and $n$?

1

There are 1 best solutions below

0
On BEST ANSWER
  1. Here's a trick — if they're six-sided dice, we can actually treat each die like a fair two-sided coin: you fail if you get 1, 2, 3 or succeed if you get 4, 5, 6 — which means that you fail half the time and succeed half the time.

  2. If you roll $m$ dice, the probability of getting exactly $k$ out of $m$ successes is therefore: $$P(k) = 2^{-m}{m \choose k}$$

    according to the binomial distribution.

  3. If you roll $m$ dice and $n$ dice, then compute the difference between the number of succeeses, the net difference can range between $-n$ (attacker fails everything and defender succeeds on everything) to $m$ (attacker succeeds on everything and defender fails on everything), and everything in between.

  4. The net difference $d$ is related to the number of successful hits: if the difference is positive, it's the number of hits. If the difference is negative, the number of hits is zero (you can't score negative hits.)

    So to calculate the probability of a number of hits, we should calculate the probability of each difference $d$.

    $$\begin{align*}P(d) &= \sum_{i=0}^m \sum_{j=0}^n 2^{-m}2^{-n} {m \choose i}{n \choose j} [i-j =d]\\ &= 2^{-m}2^{-n} \sum_{i=0}^m {m \choose i}{n \choose i-d} \end{align*}$$


For small values of $m$ and $n$, these are easy enough to calculate and plot in advance using a computer:

Hit outcomes with 1 DEF Hit outcomes with 2 DEF Hit outcomes with 3 DEF Hit outcomes with 4 DEF Hit outcomes with 5 DEF Hit outcomes with 6 DEF Hit outcomes with 7 DEF Hit outcomes with 8 DEF