1
$\begingroup$

I'm working on a (computer) game where some events will be resolved by dice rolls. Two players, A and B, will roll against each other, whomever rolls highest wins. In the case of a tie B always wins, because life is not fair.

I've reformulated the problem as follows:

  • Player A rolls $k$ number of dice, each numbered $1$ through $x_k$. The score of A is the sum of each roll plus a multiplier $m$. The score is strictly positive.
  • Player B does about the same, with $j$ dice, numbered $1$ through $x_j$, and multiplier $l$.
  • Player A wins a round if their roll is strictly higher than B's (a tie means B wins).
  • Player A wins the game if they win $n+1$ out of $2n+1$ rounds
  • $x_k$ and $x_j$ values don't vary between rounds.

I'm looking for the calculation for:

  1. The probability $p$ of A winning a single round, as a function of all the $x_k$ and $x_j$
  2. The probability $q$ of A winning a game, as a function of $x_k$ and $x_j$ and/or $n$ and/or $p$
$\endgroup$
4
  • $\begingroup$ This question is very broad and will likely get you somewhat vague and general answers, if any. Without more specifics about the dice and modifiers involved, there’s not much to be said about these probabilities. Also, there are very nice online die roll probability calculators that might be of help to you. $\endgroup$
    – amd
    Commented Sep 3, 2017 at 19:19
  • $\begingroup$ @amd Maybe it wasn't clear but I'm looking for formulae, not results. I don't know how I can be more specific because I can't know the value of variable in advance. You could abstract a dice toss as picking a random integer between x and y if that helps. $\endgroup$ Commented Sep 5, 2017 at 7:18
  • $\begingroup$ When you write "multiple dice with multipliers," do you mean something like a $100$-sided die that's implemented by one ten-sided die rolling the tens digit and another ten-sided die rolling the units digit? Unless you've arranged to have exactly one and only one way to roll each integer in the range $[w,x],$ abstracting to "one die" is an oversimplification. $\endgroup$
    – David K
    Commented Sep 5, 2017 at 11:33
  • $\begingroup$ @DavidK I did not think of that. I'll have to reformulate because yes, I will be rolling multiple dice and adding them up. $\endgroup$ Commented Sep 5, 2017 at 14:17

1 Answer 1

0
$\begingroup$

I don't think there's any reasonable closed-form function that will solve this problem, but there are algorithms that will calculate the probabilities for any number of dice of any number of sides.

For a single round, we can simplify the problem a little bit by reducing the results of all the rolls to just one variable. That is, starting from zero, add the dice rolled by A and the "multiplier" $m,$ then subtract the dice rolled by B and the "multiplier" $l.$ If the result is positive, A wins.

For example suppose A rolls four dice whose largest numbers are $4, 4, 6,$ and $13$ (where you get a fair $13$-sided die is another question, but let's suppose you can) with "multiplier" $6,$ and suppose B rolls three dice whose largest numbers are $4, 12,$ and $12,$ with "multiplier" $5.$ Then you can go to http://anydice.com/ and put this "program" in the input text window:

output 2d4+d6+d13+6-d4-2d12-5>0

Click "Calculate" and select View "Export" and Data "At Least". Look in the output window where you see the line

1,52.8669482283

That tells us that A has approximately a $52.8669482283\%$ chance of winning each round.

You can get a few more digits in the answer by omitting >0 from the "program." The output can get quite long in that case and you may have to scroll down to find the line that starts with $1.$ But the last few digits in that format are not quite correct, anyway; you can get an idea of how accurate this calculator is by selecting Data "At Most" and scrolling to the bottom of the output window. The probability there should be $100\%$ but it typically is not exactly $100$ for the examples I have tried.

If "multiplier" actually meant something to multiply the outcome by rather than something to add to it, the "program" is

output 6*(2d4+d6+d13)-5*(d4+2d12)>0

Another on-line calculator is http://topps.diku.dk/torbenm/troll.msp, but it works a little bit differently and I have not experimented as much with the programs there.

Once you have your probability for a single round, you can formulate the game as a binomial random variable $Y$ with parameters $2n+1$ and $p$ (where $p$ is the probability that A wins one round). For example, suppose there will be $25$ rounds ($n=12$). Then the probability that A wins is $P(Y \geq 13),$ which we can also calculate on-line:

https://www.wolframalpha.com/input/?i=prob+x%3E%3D13+for+x+binomial(25,0.528669482283)

Wolfram Alpha gives the answer $0.614021,$ that is, A has a $61.4021\%$ chance to win the game.

If you want to set up all these calculations yourself rather than use the on-line resources, a reasonably simple program will do it, or even a computer spreadsheet with appropriate formulas. I could go into more detail on that if that's desired.

$\endgroup$
1
  • $\begingroup$ So far I've elected to roll for a round 25000 times. It gives consistent results within 2%, but it also takes a second or two which in computer time is forever. I've solved the second part with the binomial thingy formula, which at least saves me a lot of rolls. $\endgroup$ Commented Sep 13, 2017 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .