Rolling Dice or Cumulative Binomial Distribution with a Twist

668 Views Asked by At

I am making a game where players can win or lose based on dice they throw.

  • Player throws $M$ number of dice.

  • By default a success is considered when a die rolls $5$ or $6$.

  • Player needs to get $N$ successful dice to win.

The basic formula to calculate the probability of the player winning looks like this (Cumulative Binomial Distribution):

$$1 - \sum_{k=0}^{N-1} \binom{M}{k} p^k (1-p)^{M-k} $$

Then $p = 2 / 6$ (probability of success where $5$ & $6$ are considered as success)

The player can also have different effects during the game that increase their chances:

  • Blessed - Dice sides that count as success: $4 ,5 ,6$

  • Cursed - Dice sides that count as success: $6$

In these cases I just change the $p$ to $3 / 6$ in case of Blessed and to $1 / 6$ in cased of Cursed.

Now I have the problem calculating the probability in the following case:

"Each $6$ your roll counts as $2$ successes" - I guess this is self explanatory. So now each dice that rolls a $6$ will be considered as $2$ successes.

How can I adapt my formula to take this effect into consideration?

Let me know if something is not clear.


Edit: By default when you throw a die you can get the following results:

$$\matrix{1 &\text{fail}\\ 2 &\text{fail}\\ 3 &\text{fail}\\ 4 &\text{fail}\\ 5 &\text{success}\\ 6 &\text{success}}$$

When player is Blessed it changes to: $$\matrix{1 &\text{fail}\\ 2 &\text{fail}\\ 3 &\text{fail}\\ 4 &\text{success}\\ 5 &\text{success}\\ 6 &\text{success}}$$

When player is Cursed, you get: $$\matrix{1 &\text{fail}\\ 2 &\text{fail}\\ 3 &\text{fail}\\ 4 &\text{fail}\\ 5 &\text{fail}\\ 6 &\text{success}}$$


Edit2: Let's forget about dice for a second. Seems like I won't be able to reuse the old formula.

Let's say that each turn for $M$ turns, I get a value with the following probability:

$$\matrix{Value &Normal&Blessed&Cursed\\ 0 &4/6 & 3/6 & 5/6\\ 1 &1/6 & 2/6 & 0/6\\ 2 &1/6 & 1/6 & 1/6\\ }$$

How do I calculate the probability that the sum of the values is at least $N$ or bigger?

2

There are 2 best solutions below

4
On BEST ANSWER

A different way to do (maybe easier, computationally speaking) is just using a generating function of the kind

$$g(x)=(q+p_1x+p_2x^2)^M\tag{1}$$

that represents the act of throwing $M$ dice, where sides of dice with probability $q$ add zero points, sides of dice with probability $p_1$ add one point and sides of dice with probability $p_2$ add two points.

When we expand $g$ we have that each monomial $c_kx^k$ represent the probability $c_k$ to have $k$ successes in the throw. Hence using the multinomial theorem (with multi-index notation) we have that

$$g(x)=\sum_{|\alpha|=M}\binom{M}{\alpha}q^{\alpha_1}(p_1x)^{\alpha_2}(p_2x^2)^{\alpha_3},\quad \alpha\in\Bbb N^3_{\ge 0}\tag{2}$$

Using a program we can easily choose the coefficients that we are interested on. By example using the Wolfram language we can use the code

g[x_, p1_, p2_, M_] := ((1 - p1 - p2) + p1 x + p2 x^2)^M
p[p1_, p2_, S_, M_] := Sum[Coefficient[g[x, p1, p2, M], x, n], {n, S, 2 M}] // Interpreter["Percent"][N[#]*100] &

After we can call the function defined above, by example

p[1/6,1/6,5,10]

gives the result $\approx 55\%$. This means that the probability of victory, for $N=5$, when you throw ten dice ($M=10$), when a six give two points ($p_2=1/6$) and a five give one point ($p_1=1/6$), is approximately of $55\%$.

Obviously when we set $N=0$ we get a $100\%$ probability of victory!


The above will not be too hard to adapt to other programming languages, by example other major CAS as Sage, R, etc...


The charts in this image give some idea about how the game works. In the chart the term "double" in each title means when the $6$ give two points instead of just one. I added too the mechanic that there is a side of the dice that subtract one success and I named it as "cancellation".

For each chart the y-axis represent the probability (in %) to win when you need the number of success labeled in the x-axis.

P.S.: if you need the notebook is here.

3
On

Doing the case in which you get 2 pts for a six and 1 pt for a five ...

The probability that you roll $a$ fives and $b$ sixes when you throw $M$ dice is given by ...

$$ P(a,b) = \binom Ma \binom {M-a}b \left(\frac 16\right)^a \left(\frac 16\right)^b\left(\frac 46\right)^{M-a-b} $$

$$ =\left(\frac 23\right)^M \binom Ma \binom {M-a}b \left(\frac 14\right)^{a+b} $$

Assuming $N \le M$ you can win with any number of sixes ($b\in [0,M]$) but must have at least $a=a_{min}\equiv \max(0,N-2b)$ fives, and at most $M-b$ fives.

So

$$ P_{win} = \sum_{b=0}^M \sum _{a=a_{min}}^{M-b}P(a,b) $$

***** EDIT ******

Let $x_k$ represent the probability of scoring $k$ points, so $x_0+x_1+x_2=1$.

Then $$P(a,b)= \binom Ma \binom {M-a}b \left(x_1\right)^a \left(x_2\right)^b\left(x_0\right)^{M-a-b} $$

where $a$ is the number of 1-pointers and $b$ the number of 2-pointers.

Taking into account the possibility that $N>M$ ,

in which case we must have at least $(N-M)$ 2-pointers.

so define

$$ b_{min} \equiv max(0,N-M)$$

The final formula would be... $$ P_{win} = \sum_{b=b_{min}}^M \sum _{a=a_{min}}^{M-b} \binom Ma \binom {M-a}b \left(x_1\right)^a \left(x_2\right)^b\left(x_0\right)^{M-a-b} $$