[Math] Probability of dice roll (board games)

diceprobability

Assume that we have $n$ six-sided dice. We will roll all $n$ dice. What is the probability of getting at least $r$ ones, $s$ twos, $t$ threes and $u$ fours? Number $6$ can be used instead of any of other values. Number $5$ is bad all the time.

Example: we roll $4$ dice. What is the probability of getting at least $2$ twos and $1$ ones? Six can be used as one or two so rolling:

$1, 2, 2, 3$ is ok,

$1, 2, 3, 6$ is ok,

$6, 6, 6, 4$ is ok

but $2, 2, 3, 4$ is bad.

Best Answer

UPDATE: Seeing again the same ugly counting problem we can try a different approach using a ordinary generating function.

Let $s:=\{s_1,s_2,s_3,s_4\}$ the setup that we want to count where $s_k$ is the number of $k$-valued sides in the throw (by example if $s_3=5$ it means that the throw must contain exactly five $3's$.)

Because we are throwing $n$ dices then for each valid setup $s$ there are $\ell:=n-\sum_k s_k$ dice who values are $5$ or $6$. Then there is a maximum number $\ell$ of "wildcards" (that is, of possible $6's$). Let define the order relation $s\ge t$ if and only if $s_k\ge t_k$ for $k=1,2,3,4$. Then if $s\ge t$ then it is enough to have a valid throw when $\ell\ge s_6\ge\sum_k(s_k-t_k)=:|s-t|_1$.

Then for some $s\ge t$ there are $\ell+1-|s-t|_1$ possible valid setups. Now the ordinary generating function defined by

$$g_s(x):=\prod_{k=1}^4\left(\sum_{j=0}^{s_k}x^j\right)$$

is counting all $s\ge t$ for each $|t|_1$, that is $[x^{|t|_1}]g_s(x)$ is the number of $t\le s$ with $|t|_1:=\sum_k t_k$. And because for every $|t|_1$ there are $\ell+1-|s-t|_1=n+1-2|s|_1+|t|_1$ valid setups to count them all it is enough to make the dot product $(v_s,r_s)$, where $r_s$ is the vector defined by the coefficients of the polynomial $g_s$, that is

$$r_s:=([x^0]g_s(x),[x^1]g_s(x),\ldots,[x^{|s|_1}]g_s(x))$$

and $v_s:=(n+1-|s|_1,\ldots,2,1,0,\ldots,0)$.

Then the probability $p_s$ that some setup equivalent to $s$ appear in this game will be $p_s=(v_s,r_s)/6^n$. From this notation it could be easier to write efficient programs that evaluate these probabilities.

However if $n$ is too big probably an approximation could be better, by example from some Montecarlo simulation. In any case I doubt that a "closed" formula can be found.