\chapter{Dice} \section{Distribution of Successes} \begin{multicols}{2} For further analysis it will be useful to have a distribution function for margins of success. To obtain such a distribution we start by observing that each roll can be divided into four groups: critical successes, successes, failures and critical failures, as shown in \cref{equ:dice_groups}. Further, this tuple has a multinomial distribution \begin{align} \left(C_s, S, F, C_f\right) \sim \text{MN}\left(d, 4, p\right)\label{equ:dice_groups} \\ p = \left[1/12,\frac{12-\stat{dt}-1}{12},\frac{\stat{dt}-1}{12},\frac{1}{12}\right] \end{align} We can easily map a tuple to a success margin: \begin{equation} M = 2C_s + S - F - 2C_f \end{equation} Therefore, our distribution for $M$ is a sum over all tuples that produce the correct $m$ \begin{equation} Pr(M = m) = \sum_{C_s,S,F,C_f; M = m} \text{MN}\left(d, 4, p\right) \end{equation} Instead of trying all combinations of variables and summing the correct ones, we can use a system of Diophantine equations to reduce the search space. We start with two equations \begin{align} 2c_s + s - f - 2c_f & = m \\ c_s + s + f + c_f & = d \end{align} which resolve into a two-dimensional system \begin{align} c_s & = m - d + 2f + 3c_f \\ s & = -m + 2d - 3f - 4c_f \end{align} Next, we use inequalities $c_s\geq0, s\geq0$ to constrain the space for $c_f$, based on $f$. An example plot in \cref{fig:candidates} graphically shows the area defined by these equations and inequalities for one combination of $d$ and $m$. \begin{align} \frac{m-d+2f}{-3} \leq c_f \leq \frac{-m+2d-3f}{4} \end{align} Because the lower bound is not necessarily greater than 0, we will also use $c_f\geq0$. We can now also constrain $f$ by observing that the lower bound for $c_f$ can cross $c_f=0$ before $f=d$. \begin{equation} 0 \leq f \leq \frac{2d-m}{3} \end{equation} Putting the sum together, and adding floors and ceilings to limit the sum to integers, we get: \begin{align} Pr(M=m) & = \sum_{f=0}^{\left\lfloor \frac{2d-m}{3} \right\rfloor}\sum_{c_f=\max(0,\left\lceil\frac{m-d+2f}{-3}\right\rceil)}^{\left\lfloor\frac{-m+2d-3f}{4}\right\rfloor} \\ &\quad\; \frac{d!}{c_s!s!f!c_f!} \frac{n_s^s n_f^f}{12^{d}} \\ n_f & = \stat{dt}-1 \\ n_s & = 12-n_s \end{align} While this equation is not very illuminating, it does allow us to efficiently compute the distribution and thus answer various questions regarding the results of dice rolls. \end{multicols} \begin{figure}[htb] \centering \includegraphics{images/dice_candidates_example.pdf} \caption{Example of candidate combinations of $f$ and $c_f$ with upper and lower bounds for $c_f$ shown. In this plot, $d=12$ and $m=8$.\label{fig:candidates}} \end{figure} \begin{figure}[htb] \centering \begin{tabular}{r | c c c c c c c c} & \multicolumn{8}{c}{Difficulty Threshold} \\ d & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \cline{2-9} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 \\ 2 & 2 & 2 & 1 & 1 & 1 & 1 & 0 & 0 \\ 3 & 3 & 3 & 2 & 2 & 1 & 1 & 1 & 1 \\ 4 & 4 & 3 & 3 & 2 & 2 & 1 & 1 & 0 \\ 5 & 5 & 4 & 3 & 3 & 2 & 1 & 1 & 1 \\ 6 & 6 & 5 & 4 & 3 & 2 & 2 & 1 & 1 \\ 7 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 1 \\ 8 & 8 & 7 & 5 & 4 & 3 & 2 & 1 & 1 \\ 9 & 9 & 8 & 6 & 5 & 3 & 2 & 1 & 1 \\ 10 & 10 & 8 & 7 & 5 & 4 & 2 & 1 & 1 \\ \end{tabular} \caption{Expected number of successes.\label{tab:exp_mos}} \end{figure} \section{Combat Pool Steady State} \begin{multicols}{2} The combat pool starts with the proficiency state, i.e., \stat{STR} or \stat{DEX}. However, after rolling, the change in pool size is determined by \stat{CON}. After a number of turns, the expected size of the pool should converge on a number $E[d]$. We start by assuming that $E[d]$ is a number such that \begin{equation} E[d_{n+1}] = E[d_{n}] \label{equ:dice_ss_a1} \end{equation} where $n$ is the turn after which the steady state is achieved. To compute $E[d_n]$ for any $n$ we can use \begin{equation} E[d_n] = E[d_{n-1}] - p_f \cdot E[d_{n-1}] + \stat{con} \label{equ:dice_ss_a2} \end{equation} where $p_f = \stat{dt}/12$ is the probability of failure. Using assumptions in \cref{equ:dice_ss_a1,equ:dice_ss_a2} we write the following equations: \begin{align} E[d] & = E[d] - p_f \cdot E[d] + \stat{con} \\ p_f\cdot E[d] & = \stat{con} \\ E[d] & = \frac{\stat{con}}{p_f} \end{align} As $p_f$ approaches 1, the steady state becomes just \stat{CON}, meaning the dice pool is entirely discarded and refreshed by \stat{con} on every turn. On the other hand, as $p_f$ approaches 0, the expected dice pool size increases. Specifically at 0, it shoots off toward infinity, as the dice pool loses no dice and \stat{con} dice get added toward it on every turn. \end{multicols}