Exploding (a.k.a open-ended) dice pool

ETA: OK, I think I've fixed the problem. Off-by-one error...

I think this can be done with generating functions. The generating function for a single die is given by

$$ F(z) = \frac{t-1}{d} + \frac{(d-t)z}{d} + \frac{zF(z)}{d} $$

We can interpret this as follows: The probability that there are no hits on the one die is $\frac{t-1}{d}$, so $F(z)$ has that as the coefficient for $z^0 = 1$. The probability that there is one hit and the die doesn't "explode" (repeat) is $\frac{d-t}{d}$, so $F(z)$ has that as the coefficient for $z^1 = z$. In the remaining $\frac{1}{d}$ of the cases, the die explodes and the situation is exactly as it was at the start, except that there is one hit already to our credit, which is why we have $zF(z)$: the $F(z)$ takes us back to the beginning, so to speak, and the multiplication by $z$ takes care of the existing hit.

This expression can be solved for $F(z)$ via simple algebra to yield

$$ F(z) = \frac{t-1+(d-t)z}{d-z} $$

whose $z^h$ coefficient gives the probability for $h$ hits. For example, for the simple case $n = 1, d = 20, t = 11$:

\begin{align} F(z) & = \frac{10+9z}{20-z} \\ & = \frac{10+9z}{20} \left(1+\frac{z}{20}+\frac{z^2}{20^2}+\cdots\right) \\ & = \left( \frac{1}{2} + \frac{9}{20}z \right) \left(1+\frac{z}{20}+\frac{z^2}{20^2}+\cdots\right) \\ \end{align}

and then we obtain the probability that there are $h$ hits from the $z^h$ coefficient of $F(z)$ as

$$ P(H = h) = \frac{1}{2\cdot20^h}+\frac{9}{20^h} = \frac{19}{2\cdot20^h} \qquad h > 0 $$

with the special case

$$ P(H = 0) = \frac{1}{2} $$

In general, we can obtain the expectation of the number of hits $\overline{H}$ as

$$ \overline{H} = F'(1) = \frac{d(d-t)+t-1}{(d-1)^2} = \frac{d+1-t}{d-1} $$


Now, for $n$ dice, we have

$$ [F(z)]^n = \left[ \frac{t-1+(d-t)z}{d-z} \right]^n $$

We can write this as $N(z)M(z)$, where

\begin{align} N(z) & = [t-1+(d-t)z]^n \\ & = \sum_{k=0}^n \binom{n}{k} (t-1)^{n-k}(d-t)^kz^k \end{align}

and

\begin{align} M(z) & = \left(\frac{1}{d-z}\right)^n \\ & = \frac{1}{d^n} \left( 1+\frac{z}{d}+\frac{z^2}{d^2}+\cdots \right)^n \\ & = \sum_{j=0}^\infty \binom{n+j-1}{j} \frac{z^j}{d^{n+j}} \end{align}

so we can obtain a closed form for $P(H = h)$ from the $z^h$ coefficient of $[F(z)]^n = N(z)M(z)$ as

\begin{align} P(H = h) & = \sum_{k=0}^{\max\{h, n\}} \binom{n}{k} \binom{n+h-k-1}{h-k} \frac{(t-1)^{n-k}(d-t)^k}{d^{n+h-k}} \\ & = \frac{(t-1)^n}{d^{n+h}} \sum_{k=0}^{\max\{h, n\}} \binom{n}{k} \binom{n+h-k-1}{h-k} \left[ \frac{d(d-t)}{t-1} \right]^k \end{align}

For example, for $n = 1, d = 6, t = 5$ (the example in the OP), the above expression yields

$$ P(H = h) = \frac{5}{3 \cdot 6^h} \qquad h > 0 $$

with the special case

$$ P(H = 0) = \frac{2}{3} $$

which coincides with the conclusions drawn in the comments to the OP.

The expectation for the number of hits could be obtained by evaluating $\frac{d}{dz} [F(z)]^n$ at $z = 1$, but owing to the linearity of expectation, it is obtained more straightforwardly as $n$ times the expected number of hits for one die, namely

$$ \overline{H} = \frac{n(d+1-t)}{d-1} $$

I think this all checks out, but some independent verification (or disproof, as appropriate) would be nice.


Each die produces a certain number of hits independently from the other dies. Denote by $p_r$ $(r\geq0)$ the probability that a given die produces exactly $r$ hits. Then $$p_0={t-1\over d},\qquad p_1={d-t \over d}+{1\over d} p_0\ ,$$ since the bonus roll (after a $d$) should not result in a hit. For $r>1$ hits we need $r-1$ rolls of a $d$ and exactly one more hit. It follows that we have $$p_r={1\over d^{r-1}}p_1={1\over d^r}(d-t+p_0)\qquad(r\geq1)\ .$$ Consider the generating function $$f(x):=\sum_{r=0}^\infty p_r x^r=p_0+(d-t+p_0){x/d\over 1-x/d}=p_0{1+\alpha x \over 1-\beta x}$$ with $$\alpha:={d-t\over d p_0},\qquad \beta:={1\over d}\ .$$ The probability $p_r^{(n)}$ of obtaining a total of $r$ hits with $n\geq1$ dice is the coefficient of $x^r$ in the expansion of $\bigl(f(x)\bigr)^n$. Now $$\bigl(f(x)\bigr)^n=p_0^n \sum_{j=0}^n {n\choose j}(\alpha x)^j\sum_{k=0}^\infty {n+k-1\choose k}(\beta x)^k\ .$$ When you collect terms you obtain $$p_r^{(n)}=p_0^n\sum_{j=0}^r C_j\>\alpha^j\beta^{r-j}$$ with certain combinatorial coefficients $C_j$. I don't know whether a simplification is possible.

The expected number $E^{(n)}$ of hits can be found more simply as follows: Let $E$ be the expected number $E$ of hits that you can land with a single die. Then $$E={t-1\over d}\cdot 0+{d-t\over d}\cdot 1+{1\over d}(1+E)\ .$$ The reasoning behind this is the following: If the first roll results is one of $\{1,\ldots,t-1\}$ there is no hit, and the die is dead. If the first roll results in one of $\{t,\ldots, d-1\}$ there is one hit, and the die is dead. If the first roll results in $d$ there is one hit, and in addition we are given the opportunity to realize $E$ more hits with this die.

It follows that $$E={d-t+1\over d-1}\ ,$$ from which we obtain $$E^{(n)}=n \>{d-t+1\over d-1}$$ when there are $n$ dice in the game.