Help with probabilities on a game I am making I asked over at the RPG stack exchange and they sent me here.
I am working on making a RPG and am trying to understand the statistics of the core mechanic so I can determine how effective leveling and bonuses will be.
Right now the core mechanic is a skill die based mechanic where you roll a d4, d6, d8 or d10 based on your skill opposed by either a DC set by the story teller (1-10) or the result of another die via an opposed roll.
I am experimenting with rolling two dice and picking the higher of the two, however I don't know how to make a statistical model for this. So if I rolled a 5 and a 4 on two six sided dice I would pick the 5 and ignore the 4. I don't know how this would change the probabilities.
I am finding this especially difficult due to the fact that I am planning on using exploding dice. (Exploding dice is a term for when you roll the highest number on a die and roll the die again, adding the number you previously rolled to the die. This can continue indefinitely.)
I would very much appreciate some help on coming up with a formula for this. I want to set up an excel sheet to compare different bonus methods so I would really like something where I can put the formula in and tweak it instead of just probabilities listed.
 A: Suppose $X$ and $Y$ are i.i.d. discrete random variables.  Then the probability that the maximum of $X$ and $Y$ is equal to $x$ is given by
$$
P[\max(X,Y)=x]=2P[X=x]P[X\le x] - P[X=x]^2.
$$
For ordinary $n$-sided dice, the probability of rolling $x \in \{1,2,...,n\}$ is $1/n$, and the probability of rolling no greater than $x$ is $x/n$.  So the distribution function for the maximum of two $n$-sided dice is
$$
P[\max(X,Y)=x]=\frac{2x-1}{n^2}.
$$
For "exploding" dice, as you've described them, the problem is a little more complicated.  From your description, the value of an exploding $n$-sided die is going to be $nk + x$, where $k$ is the length of your initial run of maximal rolls ($k\ge 0$), and $x \in \{1,2,...,n-1\}$ is your final (non-maximal) roll.  The probability of an initial run of length exactly $k$ is $\left(n^{-k} - n^{-(k+1)}\right)$; so the probability of an initial run of length no greater than $k$ is
$$
\sum_{j=0}^{k}\left(n^{-j}-n^{-(j+1)}\right)=1-n^{-(k+1)}.
$$
Also, the probability of a final roll of exactly $x$ is $1/(n-1)$, and the probability of a final roll no greater than $x$ is $x/(n-1)$.  Putting these together, the probability of a score of exactly $nk+x$ is
$$
P[X=nk+x]=\frac{n^{-k}-n^{-(k+1)}}{n-1}=n^{-(k+1)}.
$$
The probability of a score no greater than $nk+x$ is
$$
P[X\le nk+x]=P[X_k<k]+P[X_k=k \wedge X_x\le x]=1-n^{-k}+x n^{-(k+1)}.$$
Assembling these results, the distribution function for the maximum of two exploding $n$-sided dice is
$$
P[\max(X,Y)=nk+x]=2n^{-(k+1)}-2n^{-(2k+1)}+(2x-1)n^{-(2k+2)}.
$$
A: Well depending on how you are programming the game, you might just be able to use a command such as "if diceA > diceB = diceA" and so on. mjqxxxx gave you the mathematics, but I'm not entirely sure you'll need it?
