tag:blogger.com,1999:blog-91704133237503518652024-04-04T18:23:35.073-07:00Quantifying StrategyThe Mathematics of Tabletop GamesUnknownnoreply@blogger.comBlogger41125tag:blogger.com,1999:blog-9170413323750351865.post-69630423463936760832023-08-08T20:30:00.064-07:002023-08-09T12:28:07.460-07:00Will I draw an epidemic card in Pandemic? (and more)<p style="margin: 0px;">When an epidemic card is drawn in the cooperative game Pandemic, it ramps up the difficulty of the game. Knowing when this occurs, or when it could occur, is useful to players to achieve victory. Here, one question ends up leading to additional questions. As we know more about a problem, the horizon of our ignorance often expands, rather than contracts. However, by taking what we learn in answering one question we're often better positioned to answer the next one.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">Pandemic setup and epidemic cards</h2>
<p style="margin: 0px;">Pandemic has an unusual setup procedure for the player deck. For standard difficulty with 4 players there are 48 city cards, 5 event cards, and 5 epidemic cards summing to 58 total cards. However, $2\cdot 4=8$ of these cards are dealt initially to the players, 2 cards to each of the 4 players. This results in there being $48+5+5-2\cdot 4=50$ cards in the player deck at the start of the game. However, these are not all shuffled together. Each of the 5 epidemic cards are separated with an equal number of other cards to form 5 piles of 10 cards per pile ($50/5=10$). Each pile is shuffled separately and then stacked on top of each other. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There is a separate infection deck containing 48 city cards that will come to our attention later. Cards are drawn from the infection deck each turn to determine where disease spreads in the game.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">When an epidemic card is drawn three things occur. First, the number of cards drawn from the infection deck each turn may increase. Second, a new city is infected by drawing from the bottom of the infection deck (guaranteeing it has not been drawn before) with three cubes. Third, the infection deck discard pile is shuffled together and put on top of the deck. This means currently and previously infected cities get drawn again. The next step in the game is to draw from the infection deck, where any cards drawn for a city already containing three disease cubes triggers an outbreak. This causes more disease cubes to be placed in neighboring cities. Among other loss conditions, players lose if there are too many cubes placed or too many outbreaks.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">Will I draw an epidemic card in Pandemic?</h2>
<p style="margin: 0px;">On each turn, 2 player cards are drawn. The probability of drawing an epidemic card on any particular turn, without knowing anything else is $1/5=0.2$. There are at least two ways to think about it and it's instructive to consider both. The probability that any single card drawn being an epidemic card is $1/10=0.1$, see Fig. 1.</p><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4CTt9Hno4AddYKtKJQ2Q4yOJJXU35FI8z1lmp8zi0MixEDIUNPY4Oz7T6xWPHT4DH1RzsnkCr9-MPNoi72JqX8xAJg1V7Qg8FgFULsptKeCOT66AY1y06e0HIIsXWr7GuJaXKtpab0NGjdHHKGbC7RF2ixBYuqmMEwb27FsF1MK_xUg_vlPtqgTbA2Kyd/s464/pandemic_cards.PNG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="88" data-original-width="464" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4CTt9Hno4AddYKtKJQ2Q4yOJJXU35FI8z1lmp8zi0MixEDIUNPY4Oz7T6xWPHT4DH1RzsnkCr9-MPNoi72JqX8xAJg1V7Qg8FgFULsptKeCOT66AY1y06e0HIIsXWr7GuJaXKtpab0NGjdHHKGbC7RF2ixBYuqmMEwb27FsF1MK_xUg_vlPtqgTbA2Kyd/w400-h76/pandemic_cards.PNG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: 10 cards from one pile</td></tr></tbody></table><p style="margin: 0px;"><br /></p><p style="margin: 0px;">This would be the same even if we didn't make special preparations to the deck, though perhaps we'd think of the calculation as $5/50=0.1$ as 5 of the 50 card in the initial deck are epidemic cards. Since players draw 2 cards per turn, each initial pile of 10 cards is drawn across exactly 5 turns, as depicted in Fig. 2. (While the piles are combined at the beginning of the game, I'll refer to the current pile as the set of cards that were in a pile before they were stacked to make the whole deck.)</p><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkV14OpANshMFzUmhwbEaE-LJXBcykrvcutzt7uQvFWv1a-tTA0-d4HezqDxfaQQCTlK2majpgJ80o5t_XgAX55_taUf5kj29SPh41FKj2CpGPTkgbkGDhA9al_c_OGy-AHH5ue42l_M5Zl3HxSeQxxzs8oc5VpVMUL9JITUk-_i4QP3l6qEtC9iLX6Bxp/s320/pandemic_cards_2.PNG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="96" data-original-width="320" height="120" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkV14OpANshMFzUmhwbEaE-LJXBcykrvcutzt7uQvFWv1a-tTA0-d4HezqDxfaQQCTlK2majpgJ80o5t_XgAX55_taUf5kj29SPh41FKj2CpGPTkgbkGDhA9al_c_OGy-AHH5ue42l_M5Zl3HxSeQxxzs8oc5VpVMUL9JITUk-_i4QP3l6qEtC9iLX6Bxp/w400-h120/pandemic_cards_2.PNG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Drawing each 10-card pile over 5 turns</td></tr></tbody></table><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Exactly 1 of those 5 pairs of cards contains an epidemic card. Thus, the probability is $1/5=0.2$. However, we should be careful about thinking this way. It's tempting to think of this probability as the sum of the probabilities of drawing an epidemic card for each of the two cards drawn on the turn. This only works here because drawing an epidemic card as the first card in a turn and drawing one as the second card are not independent events. The probability of drawing an epidemic card on a given turn is equal to the sum of the probability of drawing it as the first card plus the probability of drawing it as the second card, because these events are disjoint, or mutually exclusive, events. (Note that this is not always true in Pandemic. For some player counts and difficulty levels, there can be an uneven number of cards in some of the player deck piles at the beginning of the game. In such a case, if the last card of one pile and the first card of the next pile are both epidemic cards, then two epidemic cards can be drawn on a single turn.)</p>
\begin{align}
P(\text{E during turn}) = P(\text{E as first card}) + P(\text{E as second card})
\end{align}
<p style="margin: 0px;">(I've abbreviated "draw epidemic" as "E" to shorten the equations.)</p>
<p style="margin: 0px;">From here, we could complete the computation, as we know the probability of any card being an epidemic card in isolation is 0.1. However, we want to describe these events in a way that is easy to construct with probability that doesn't feel so hand wavy. Or, at least highlights the difference compared to when the events are not disjoint. The only way to draw an epidemic card as the second card is if we didn't draw it on the first, thus that event is equivalent to not drawing an epidemic card and then drawing an epidemic card. Similarly, the only way to draw an epidemic card as the first card is to draw an epidemic card and then not draw one.</p>
\begin{align}
P(\text{E during turn}) &= P(\text{E then not E}) + P(\text{not E then E})
\end{align}
<p style="margin: 0px;">Let's rewrite this in terms of a logical and, or the intersection of events.</p>
\begin{align}
P(\text{E then not E}) &= P(\text{first E} \cap \text{second no E}) \\
P(\text{not E then E}) &= P(\text{first no E} \cap \text{second E})
\end{align}
<p style="margin: 0px;">We can break this up into independent pieces using the multiplication rule, $P(A \cap B) = P(A|B) \cdot P(B)$, though we'll turn the order around a little bit in terms of $A$ and $B$ to write them in the order of occurrence. $P(A|B)$ is a conditional probability, the probability of $A$ given that $B$ occurs. This allows us to chain events together, as shown below.</p>
\begin{align}
P(\text{first E} \cap \text{second no E}) &= P(\text{first E}) \cdot P( \text{second no E}|\text{first E}) \\
P(\text{first no E} \cap \text{second E}) &= P(\text{first no E}) \cdot P( \text{second E}|\text{first no E})
\end{align}
<p style="margin: 0px;">Now, let's plug in the numbers. For the first draw, the probabilities are $1/10$ and $9/10$, as either 1 or 9 of the 10 cards are relevant. For the second draw under these conditions there are only 9 cards remaining, and either 9 or 1 of them are of interest.\begin{align}
P(\text{first E}) &= \frac{1}{10} \\
P( \text{second no E}|\text{first E}) &= \frac{9}{9} \\
P(\text{first no E}) &= \frac{9}{10} \\
P( \text{second E}|\text{first no E}) &= \frac{1}{9}
\end{align}</p><p style="margin: 0px;">We can combine our equations to get the following.</p>
\begin{multline}
P(\text{E during turn}) = P(\text{first E}) \cdot P( \text{second no E}|\text{first E}) \\
+ P(\text{first no E}) \cdot P( \text{second E}|\text{first no E})
\end{multline}
<p style="margin: 0px;">Now we plug in the numbers.</p>
\begin{align}
P(\text{E during turn}) &= \frac{1}{10} \cdot \frac{9}{9} + \frac{9}{10}\cdot\frac{1}{9}\\ &= \frac{1}{10} + \frac{1}{10}\\
&= 0.2
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can contrast this with rolling dice, to see the care we should take when adding probabilities. Consider the probability of rolling a 3 on 2d10. (Two 10-sided dice numbered 1 through 10 are here referred to as 2d10.) This could either be for exactly one 3 or at least one 3. The probability of getting a 3 on a single d10 is $1/10=0.1$, similar to our Pandemic question. However, since each roll is independent, the probability of one roll does not affect the next. Thus, the probability of getting exactly one 3 is $\frac{1}{10}\cdot\frac{9}{10} + \frac{9}{10}\cdot\frac{1}{10} = 0.18$, which is somewhat less than the 0.2 for the Pandemic scenario, using a similar calculation form. The probability of getting at least one 3 is computed as $1-P(\text{no 3s}) = 1 - \left (\frac{9}{10}\right )^2 = 0.19$, a higher probability, but still less than 0.2.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">It is close to 0.2, though. Note the equation we used above, we can generalize to $1 - (1-p)^2$, where $p$ is the probability of occurring in one of the two trials. This equations expands to,</p>
\begin{align}
1 - (1-p)^2 = 1 - (1 - 2p + p^2) = 2p - p^2. \end{align}
<p style="margin: 0px;">When $p$ is small, $p^2 \ll 2p$, so $2p$ is a good approximation.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The distinction here between the behavior observed with dice and cards is ripe for reflection. (It's not so much dice vs. cards, but rather independent vs. dependent. If drawing cards with replacement, the same probabilities hold as with dice.) For the probability of rolling at least one 3, note that the second roll only increases the probability if the first roll was not a 3. This means much of the time, indeed with probability $\frac{1}{10} \cdot \frac{1}{10} = 0.01$, the second roll does no good in terms of counting as rolling a 3. This is an additional case that does not show up for our Pandemic question. In the scenario considered, it is not possible for both cards drawn on one turn to be epidemic cards, but it is possible to get two 3s when rolling 2d10.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Note also that the piles of 10 cards is important to the calculation. If instead there were simply 5 epidemic cards somewhere in the 50 card deck, then the probability of drawing an epidemic card as the first card in a turn is unchanged, but the second card is different and depends on whether the first card is an epidemic card or not. Here we'll use E$_{50}$ to denote drawing an epidemic card with a fully shuffled player deck.</p>
\begin{align}
P(\text{first E}_{50}) &= \frac{5}{50} \\
P( \text{second no E}_{50}|\text{first E}_{50}) &= \frac{45}{49} \\
P(\text{first no E}_{50}) &= \frac{45}{50} \\
P( \text{second E}_{50}|\text{first no E}_{50}) &= \frac{5}{49}
\end{align}
<p style="margin: 0px;">Since here we can also get two epidemic cards, we have an additional probability of interest.</p>
\begin{align}
P( \text{second E}_{50}|\text{first E}_{50}) &= \frac{4}{49}
\end{align}
<p style="margin: 0px;">Putting this together, we get the following.</p>
\begin{multline}
P(\text{E$_{50}$ during turn}) = P(\text{first E}_{50}) \cdot P( \text{second no E}_{50}|\text{first E}_{50}) \\
+ P(\text{first E}_{50}) \cdot P( \text{second E}_{50}|\text{first E}_{50}) \\
+ P(\text{first no E}_{50}) \cdot P( \text{second E}_{50}|\text{first no E}_{50})
\end{multline}
<p style="margin: 0px;">This simplifies, as it doesn't matter what we draw as a second card if the first is an epidemic card. Put another way, </p>
\begin{align}
P( \text{second no E}_{50}|\text{first E}_{50})+ P( \text{second E}_{50}|\text{first E}_{50}) = 1.
\end{align}
<p style="margin: 0px;">Plugging that in, we get the following.</p>
\begin{align}
P(\text{E$_{50}$ during turn}) &= P(\text{first E}_{50}) + P(\text{first no E}_{50}) \cdot P( \text{second E}_{50}|\text{first no E}_{50}) \\
&=\frac{5}{50} + \frac{45}{50} \cdot \frac{5}{49} \\
&\approx 0.192
\end{align}<p style="margin: 0px;">An alternative way of thinking of the earliest computation is that we are separating the piles of 10 cards into two groups: the 2 cards we draw this turn and the 8 cards we draw on the other four turns. Thus the probability of drawing the one epidemic card is 2 cards out of 10 total, or 0.2. We can think of this construction as choosing where to place the epidemic card. There are $\binom{2}{1}=2$ ways to put it in the 2 cards of interest and $\binom{10}{1}=10$ total ways to put it in a particular pile.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">What if we're in the middle of the game?</h2>
<p style="margin: 0px;">The single probability that we calculated is limited, though, as it doesn't match the amount of information that we have for much of the game. Once we draw cards, we know more about some of the remaining turns. We can compute the conditional probabilities, the probabilities given the knowledge we have from either drawing or not drawing epidemic cards on previous turns. For example, after not drawing an epidemic card in the first turn, the probability of drawing an epidemic card on the second turn increases, as now there are only 8 cards in the current pile, or equivalently 4 turns until the current pile is exhausted. This is similar to when we looked at the <a href="https://www.quantifyingstrategy.com/2020/04/when-will-high-society-end.html">length of a game of High Society</a>, except here we repeat through multiple piles. The conditional probability can also drop to zero. If you draw an epidemic card on the first turn, you know that you won't for the next 4 turns.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The probability of drawing an epidemic card on the second turn given that we did not on the first turn is $2/8=0.25$. Of course, if the probability of drawing an epidemic card on the second turn given that we <i>did</i> draw one of the first turn is 0. We can extend this for the third turn ($2/6=1/3$ and $0$), fourth turn ($2/4=0.5$ and $0$) and fifth turn ($2/2=1$ and $0$). On the sixth turn we draw from the second pile, so the previous set of probabilities repeat. We can write the probability, $p_\text{not}[n]$, of drawing an epidemic card on turn $n$ given that we have not drawn one from the current piles as,</p>
\begin{align}
p_\text{not}[n] = \frac{2}{10 - 2\cdot ( (n-1)\mod 5 )},
\end{align}
<p style="margin: 0px;">where $a \mod b$, or $a$ modulo $b$, is the remainder after dividing $a$ by $b$. This forms the desired repeating pattern. The above equation could be rewritten in a simplified form, but it is based on the number of cards, which are the physical counts that give rise to the probabilities. The $(n-1) \mod 5$ term represents the number of turns where cards were already drawn from the current pile. These probabilities are plotted in Fig. 3 along with the probability given we already drew the current epidemic card (if possible) as well as the unconditional probability. (The probability is set to 0.2 for the first turn of each pile to emphasize that the probability here is always 0.2.)</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvDK7kHSTM9QaDai1QZWWj7m6N-yrelqdL1miVNT4afU6NxPYM2t_9vlUQJUWFOtiwMazabUIp4r6rxlaPJpJb9l1Vbfojgw7nhKZ0qanKjgPVWkVIrYp2_CI2CMorpXqbKVKeoWfok_w7MK7BN-SnUTWe8nt-iN2qyH3WN-5-bVoptl8IyCfo0vdN8Q2y/s700/pandemic_1.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvDK7kHSTM9QaDai1QZWWj7m6N-yrelqdL1miVNT4afU6NxPYM2t_9vlUQJUWFOtiwMazabUIp4r6rxlaPJpJb9l1Vbfojgw7nhKZ0qanKjgPVWkVIrYp2_CI2CMorpXqbKVKeoWfok_w7MK7BN-SnUTWe8nt-iN2qyH3WN-5-bVoptl8IyCfo0vdN8Q2y/w400-h258/pandemic_1.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: Probability of drawing an epidemic card in Pandemic conditioned on whether one was drawn from the current pile</td></tr></tbody></table><br /><p style="margin: 0px;">The plots make the periodic nature quite apparent, even aside from the logical necessity given the setup.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">How many turns are there between epidemic cards?</h2>
<p style="margin: 0px;">This leads us to question the distribution of the number of turns between epidemic cards, as this can impact the game in notable ways. Do we get new heavily infected cities back to back, or a long gap to take care of the current situation. To find the distribution, we construct five random variables, $X_1$ through $X_5$, for the five turns on which the epidemic cards are drawn, and then four additional random variables, $Y_2$ through $Y_5$, that represent the differences between the first five. $Y_k$ is the number of turns since the previous epidemic card after the $k$-th epidemic card.</p>
\begin{align}
Y_k = X_{k} - X_{k-1}
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The first five are uniform random variables, as each possible value occurs with equal probabilities. That is, we know the first epidemic card has a probability 0.2 of being drawn in each of the first five turns. Thus, we can write the probability mass function (pmf) of the random variable $X_1$, the turn in which the first epidemic card is drawn, as follows.</p>
\begin{align}
p_{X_1}(x) = \begin{cases}
0.2 & x \in \{1, 2, 3, 4, 5\} \\
0 & \text{else}
\end{cases}
\end{align}
<p style="margin: 0px;">The pmfs of the random variables for the other turns in which an epidemic card is drawn are similar.</p>
\begin{align}
p_{X_k}(x) = \begin{cases}
0.2 & x \in [5 (k-1)+1, 5 k] \\
0 & \text{else}
\end{cases}
\end{align}
<p style="margin: 0px;">These pmfs are plotted in Fig. 4.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXrHLQfvEGeHopS1jDDeWVbslrsSBu6iKSmhth2iHa52wkjpGscJO-mjsY5B-CcWtLxgGX8OTOaWenn0OoIeu_7ykX3rQyL0mVnzvZJrNJSKTt3d5OIgIpwMtNlHSO6sGklD7D1mYwtzVrQvbigT8LlMfx4N_Tfc4Ue5vRFMY8kvugIwgaP2VPIgq22ES1/s700/pandemic_2.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXrHLQfvEGeHopS1jDDeWVbslrsSBu6iKSmhth2iHa52wkjpGscJO-mjsY5B-CcWtLxgGX8OTOaWenn0OoIeu_7ykX3rQyL0mVnzvZJrNJSKTt3d5OIgIpwMtNlHSO6sGklD7D1mYwtzVrQvbigT8LlMfx4N_Tfc4Ue5vRFMY8kvugIwgaP2VPIgq22ES1/w400-h258/pandemic_2.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 4: Probability mass functions of the turn in which each epidemic card is drawn</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">When <a href="https://www.quantifyingstrategy.com/2020/06/rolling-ability-scores-in-d.html">discussing D&D ability scores</a>, we introduced convolution as a mathematical operation to determine the pmf of the sum of two random variables from their pmfs. (Convolutions have other uses as well.) We can use convolution here to find the pmfs of the differences $Y_k$. While $Y_k$ are equal to the difference of known random variables, rather than the sum, the same principle applies. We can see this by first transforming $X_k$ into negative versions, $X'_k = -X_k$. We know the pmfs.</p>
\begin{align}
p_{X'_k}(x) &= p_{X_k}(-x) \\
&=
\begin{cases}
0.2 & x \in [-5 k, -5 (k-1)-1] \\
0 & \text{else}
\end{cases}
\end{align}
<p style="margin: 0px;">With this, we can write $Y_k$ in terms of the sum of random variables with known pmfs.</p>
\begin{align}
Y_k = X_{k} + X'_{k-1}
\end{align}
<p style="margin: 0px;">And thus state the pmfs in terms of convolution.</p>
\begin{align}
p_{Y_k}(y) = p_{X_{k}}(y) * p_{X'_{k-1}}(y)
\end{align}
<p style="margin: 0px;">Since $X_k$ and $X'_k$ have uniform distributions that have a rectangular shape when considered over all $x \in \mathbb{Z}$ (the set of all integers), the differences $Y_k$ have a triangular distribution from convolution. This is the same as how the sum of 2d6 has a triangular distribution stemming from the rectangular pmfs of each individual d6. We could go through the motions, but this is a general truth when the rectangular pmfs have equal length. That is, when they are non-zero for a range of the same size. Otherwise, there is a flat portion in the middle. It is worth considering something like 1d6+1d8 to see this effect. If we take the shape as given, then we can find the relevant constants.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can argue from the situation the maximum and minimum possible values of $Y_k$. It has a minimum value of 1, which occurs when the epidemic card in one pile is drawn as late as possible, while the one in the next pile is drawn as early as possible. It has a maximum value equal to $10-1=9$. Here I'm looking at the latest possible turn the second epidemic card can be drawn (turn 10) and the earliest the first can be (turn 1). It is the same for all $Y_k$. If we're familiar with convolution, we'd also know that it has this property that the length of of the convolution of two finite sequences with lengths $n$ and $m$ is $n+m-1$, which in this case is $5+5-1=9$. This necessarily follows from the convolution definition.</p>
\begin{align}
p_{X_{k}}(y) * p_{X'_{k-1}}(y) &= \sum_{n=-\infty}^\infty p_{X_{k}}(y-n) \cdot p_{X'_{k-1}}(n) \\
&= \sum_{n=-\infty}^\infty p_{X_{k}}(n) \cdot p_{X'_{k-1}}(y-n) \label{eq:pandemic_convolve}
\end{align}
<p style="margin: 0px;">There is some symmetry in that the two random variables being added have equal values over the same range. Combined with the symmetry of convolution itself, that $f(x) * g(x) = g(x) * f(x)$, the resulting convolution must be symmetric about some point. This must be the mid-point between 1 and 9, which is 5. This makes a lot of sense, since each pile is five turns of card draws it is most likely that that is how far apart they are. We could find the probabilities by combining the known shape with the fact that the pmf must sum to 1 to be valid, but it's easier to just use a computer to convolve some vectors of copies of 0.2 or look at. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can use the visual method of computing convolutions, illustrated in Fig. 5 for $p_{Y_2}(y) = p_{X_{2}}(y) * p_{X'_{1}}(y)$. Following an earlier equation, we plot $p_{X_2}(n)$, a version of $p_{X'_1}(n)$ that is horizontally flipped and shifted by $y$, their product, and the running sum, across several values of $y$. To save space, not all values of $y$ are plotted.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgDhh-xme5LUgYBEwhuzRi6BMOAcCFT1VtsWQEOx_jGe-fzC-zQuV-yK_RQyvv_KkeGLoJKriad2OlqR0xINdHSbAkY5zHyomv_AfhluzmU8dO97ZPKiEvKe3whvTv2lWGRYH5E4X8D8IMoh__2wZkV-w5HrWzbbeh0W8hRCiSoVfQgDLe4EUaJoqn6LQl/s900/animated_pandemic_convolve.gif" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="900" data-original-width="700" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgDhh-xme5LUgYBEwhuzRi6BMOAcCFT1VtsWQEOx_jGe-fzC-zQuV-yK_RQyvv_KkeGLoJKriad2OlqR0xINdHSbAkY5zHyomv_AfhluzmU8dO97ZPKiEvKe3whvTv2lWGRYH5E4X8D8IMoh__2wZkV-w5HrWzbbeh0W8hRCiSoVfQgDLe4EUaJoqn6LQl/w311-h400/animated_pandemic_convolve.gif" width="311" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 5: Illustrating convolution to find pmf of $Y_k$</td></tr></tbody></table><br /><p style="margin: 0px;">More numerically, we can look at the peak value of $p_{Y_k}(y)$. This occurs at $y=5$ and corresponds to when the flipped and shifted $p_{X_{k}}(n)$ is exactly on top of $p_{X'_{k-1}}(n)$. Thus, the convolution yields $p_{Y_k}(5) = 5 \cdot 0.2^2 = 0.2$. This is enough to construct the pmf shown in Fig. 6 with the arguments made earlier.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg396F0rzD5oYfN1u4wCTFz4pyHYAKL9crnEIJIsfwm1wLHIVIFMGmqBsm5WB6u4A_Hp2zhxhhMNSaMHVftv0ybXJ34Ly1QHnFZzOo1McSjncxes27kR-vb4HQ2VxLTtu8NWhg-5fyeWTaCzgjDYDe_mShKx4L9vSsMtoMyoVwbtR9SSKh8W1OsPVyf3laY/s700/pandemic_3.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg396F0rzD5oYfN1u4wCTFz4pyHYAKL9crnEIJIsfwm1wLHIVIFMGmqBsm5WB6u4A_Hp2zhxhhMNSaMHVftv0ybXJ34Ly1QHnFZzOo1McSjncxes27kR-vb4HQ2VxLTtu8NWhg-5fyeWTaCzgjDYDe_mShKx4L9vSsMtoMyoVwbtR9SSKh8W1OsPVyf3laY/w400-h258/pandemic_3.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 6: Probability mass function of the number of turns from one epidemic card to the next</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">While $X_k$ are independent, as shuffling one pile does not affect the next, $Y_k$ are not independent. The dependence is quite clear as $Y_2 = X_2 - X_1$ and $Y_3 = X_3 - X_2$. Both depend on $X_2$. If the second epidemic card come early, that means the first interval is short while the second interval is long. We could capture this dependence by looking at the joint distribution of all $Y_k$. While some pairs are independent, for example the first interval, $Y_2$, and the last, $Y_5$, they all connect via other intervals. However, this looks to be a tedious and uninspiring calculation. We know the main gist of the dependence and leave it at that for now.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">What is the probability of drawing the newly infected city after an epidemic card?</h2>
<p style="margin: 0px;">One of the things that can happen after an epidemic card is drawn is that the newly infected city is drawn from the infection deck. The probability of this occurring is a function of how many cards are in the discard pile of the infection deck, which in turn depends on how many turns are between epidemic cards (or since the beginning of the game).</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">First let's ask an easier question, let's look at after just the first epidemic card. We start with 9 cards in the infection deck discard pile. Then we get 2 more per turn until the epidemic card is drawn. This means we get 0, 2, 4, 6, or 8 more infection cards (epidemic cards are in the player deck, which is drawn from before drawing from the infection deck). One more card is added from the epidemic card itself (from the bottom of the infection deck). All these cards get shuffled and placed atop the infection deck. Thus, there are 10 to 18 cards in which the newly infected city card is shuffled. After the first epidemic card, we're still drawing two infection cards per turn, so the probability of drawing the newly infected city is 2 divided by the number of cards that were shuffled and put on top. This repeats the same concept as we used to find the probability of drawing an epidemic card in the first place, that we're drawing from a deck without replacement. In the equations, I'll abbreviate "outbreak in newly infected city immediately after the first epidemic card" as "O from E1".</p>
\begin{align}
P(\text{O from E1} | \text{E on turn 1}) &= \frac{2}{10} \\
P(\text{O from E1} | \text{E on turn 2}) &= \frac{2}{12} \\
P(\text{O from E1} | \text{E on turn 3}) &= \frac{2}{14} \\
P(\text{O from E1} | \text{E on turn 4}) &= \frac{2}{16} \\
P(\text{O from E1} | \text{E on turn 5}) &= \frac{2}{18}
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">As we found before, the 5 possibilities are equally likely, so the total probability is as follows.</p>
\begin{align}
P(\text{O from E1}) &= \frac{1}{5}\cdot\frac{2}{10} +
\frac{1}{5}\cdot\frac{2}{12} +
\frac{1}{5}\cdot\frac{2}{14} +
\frac{1}{5}\cdot\frac{2}{16} +
\frac{1}{5}\cdot\frac{2}{18} \\
&\approx 0.149
\end{align}
<p style="margin: 0px;">This is the probability of this happening before we know anything about how the game goes. Obviously, once the epidemic card is actually drawn, then the probability is $\frac{1}{10}$ or $\frac{1}{14}$ or one of the other possibilities depending on how many cards are actually in the infection deck discard pile. This probability speaks to how likely it is that the deck is stacked against us.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Now, let's look at the probability of this happening after the second epidemic card. Here, we can use the distribution of the number of turns from one epidemic card to the next, in this case $Y_1$. Through this time, we're still drawing 2 infection cards per turn, so the number of cards in the infection deck discard pile is $1+2Y_2$, one from the epidemic card, and two for each turn since the last epidemic card. Using the same logic as above, we find the probability of drawing the newly infected city conditioned on the value of $Y_2$.</p>
\begin{align}
P(\text{O from E2} | Y_2 = y) &= \frac{2}{1+2y}
\end{align}
<p style="margin: 0px;">To get the total probability, we need to sum over all possible $Y_2$.</p>
\begin{align}
P(\text{O from E2}) &= \sum_{y=1}^9 \frac{2}{1+2y}\cdot p_{Y_2}(y) \\
&\approx 0.219
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Getting to the third epidemic card gets interesting, because now we start to draw more infection cards per turn. We'll define $r_k$ to be the rate of infection after the $k$-th epidemic card is drawn, with $r_0$ being the rate at the start of the game. These rates are shown in Table 1. </p><div style="text-align: center;">\begin{array}{ccccccc} r_0 & r_1 & r_2 & r_3 & r_4 & r_5 & r_6 \\ \hline
2 & 2 & 2 & 3 & 3 & 4 & 4
\end{array} Table 1: Infection rate, $r_k$, after the $k$-th epidemic card</div><div><div style="text-align: center;"><br /></div><p style="margin: 0px;">Note that this includes $r_6$, which is only relevant for the heroic difficulty level. In the third epidemic card case, we still were drawing 2 infection cards per turn until the epidemic card, so the three infection cards being drawn only affects the probability of drawing the newly infected city, not how many cards there are. </p>
\begin{align}
P(\text{O from E3}) &= \sum_{y=1}^9 \frac{3}{1+2y}\cdot p_{Y_3}(y) \\
&= \frac{3}{2} \cdot P(\text{O from E2})\\
&=0.329
\end{align}
<p style="margin: 0px;">Note that the pmfs of all four differences rare the same, so $p_{Y_2}(y) = p_{Y_3}(y)$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">For subsequent epidemic cards, though, the higher rate of infection card draw changes the number of cards in the infection card discard pile in which the newly infected city is shuffled. For example, for the fourth epidemic card, there are now $1+3Y_4$ cards, three for each of the $Y_4$ turns from the third epidemic card to the fourth. In general, there are $1+r_{k-1} \cdot Y_k$ cards in the infection deck discard pile after the $k$-th epidemic card. Thus, we can generalize our equation.</p>
\begin{align}
P(\text{O from E$k$}) &= \sum_{y=1}^9 \frac{r_k}{1+r_{k-1}\cdot y}\cdot p_{Y_k}(y) \qquad k \geq 2 \label{eq:p_outbreak_k}
\end{align}
<p style="margin: 0px;">One thing that's worth checking is that we don't create nonsensical probabilities. In this case, I'm concerned that our generalized formula could erroneously give probabilities above 1 in the $ \frac{r_k}{1+r_{k-1}\cdot y}$ term for small $y$. However, since $y \geq 1$ and $r_k \leq r_{k-1} + 1$, then this correctly gives a probability of 1 when epidemic cards are drawn back to back and the infection rate increases by one.</p>
<p style="margin: 0px;"><br /></p><div style="text-align: center;">\begin{array}{ccc} k & r_k & P(\text{O from E$k$}) \\ \hline
1 & 2 & 0.149 \\
2 & 2 & 0.219\\
3 & 3 & 0.329\\
4 & 3 & 0.230\\
5 & 4 & 0.307
\end{array} <span style="text-align: center;">Table 2: Probability of outbreaking in newly infected city, after the $k$-th epidemic card</span></div></div><div><p style="margin: 0px; text-align: center;"><br /></p>
<p style="margin: 0px;">The computed approximate probabilities are listed in Table 2. It is interesting to see how these probabilities change over the course of the game. The first we would expect to be lower, as the beginning of the game is seeded with an additional 9 cards, while after the later epidemic cards it is possible to have only a few cards. We also see the probabilities jump when the infection rate increases. This makes sense, as the number of cards drawn immediately after an epidemic card is relatively high. What may not be clear is why $P(\text{O from E$4$})$ is higher than $P(\text{O from E$2$})$ while $P(\text{O from E$5$})$ is lower than $P(\text{O from E$3$})$. The effect of more cards being drawn overall has a different effect when $r_k = r_{k-1}$ compared to when $r_k = r_{k-1}+1$. Looking at the denominator $1+r_{k-1}\cdot y$ again indicates that as $r_{k-1}$ increases, the constant 1 card from the epidemic card has a smaller effect, making the probability increase. That explains why $P(\text{O from E$4$})$ is higher than $P(\text{O from E$2$})$. In the other direction, as $r_{k-1}$ increases, having $r_k = r_{k-1} + 1$ in the numerator makes a smaller increase over $r_k = r_{k-1}$. In the limit there is no increase.</p>
\begin{align}
\lim_{r_{k-1} \to \infty} \frac{r_{k-1}+1}{1+r_{k-1} \cdot y} = \frac{1}{y}
\end{align}
<p style="margin: 0px;">That explains why $P(\text{O from E$5$})$ is lower than $P(\text{O from E$3$})$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Looking at the probabilities of getting an outbreak in the newly infected city after each epidemic card, $P(\text{O from E$k$})$, it is clear that the total probability is not just the sum, as that would be well above 1, which is the maximum valid value for any probability. This indicates that these probabilities are not independent. Indeed they are not, as they are based on the number of turns from one epidemic card to the next, which themselves are not independent. If we had the joint probability distribution then we could calculate the total probability. That is not simple to come by here, so we'll take two approaches to get what we want.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">One approach is to set aside the probability of getting such an outbreak and rather look at the expected number of such outbreaks. This simplifies our calculations, because when taking the expected value of the sum of some random variables it is equal to the sum of the expected values of those random variables, even if the random variables are dependent. To see why, let's just consider two of our random variables, $Y_2$ and $Y_3$.</p>
\begin{align}
\mathbb{E} (Y_2 + Y_3) &= \sum_{y_2=-\infty}^\infty\sum_{y_3=-\infty}^\infty (y_2 + y_3) \cdot p_{Y_2,Y_3}(y_2, y_3)
\end{align}
<p style="margin: 0px;">We can break this into two summations.</p>
\begin{align}
\mathbb{E} (Y_2 + Y_3) &= \sum_{y_2=-\infty}^\infty\sum_{y_3=-\infty}^\infty y_2 \cdot p_{Y_2,Y_3}(y_2, y_3) + \sum_{y_2=-\infty}^\infty\sum_{y_3=-\infty}^\infty y_3 \cdot p_{Y_2,Y_3}(y_2, y_3)
\end{align}
<p style="margin: 0px;">Now we reorder the second double summation and pull out $y_2$ in first and $y_3$ in the second.</p>
\begin{align}
\mathbb{E} (Y_2 + Y_3)&= \sum_{y_2=-\infty}^\infty y_2 \cdot \sum_{y_3=-\infty}^\infty p_{Y_2,Y_3}(y_2, y_3) + \sum_{y_3=-\infty}^\infty y_3 \cdot \sum_{y_2=-\infty}^\infty p_{Y_2,Y_3}(y_2, y_3)
\end{align}
<p style="margin: 0px;">The marginal pmfs, which are the individual pmfs, are useful here. These are obtained by summing the joint pmf over all possible values of one random variable, to get the distribution of a single one. For example,</p>
\begin{align}
p_{Y_2}(y_2) = \sum_{y_3=-\infty}^\infty p_{Y_2,Y_3}(y_2, y_3).
\end{align}
<p style="margin: 0px;">Now we replace our equation for $\mathbb{E} (Y_2 + Y_3)$ with the marginal pmfs.</p>
\begin{align}
\mathbb{E} (Y_2 + Y_3)&= \sum_{y_2=-\infty}^\infty y_2 \cdot p_{Y_2}(y_2) + \sum_{y_3=-\infty}^\infty y_3 \cdot p_{Y_3}(y_3)\\
\mathbb{E} (Y_2 + Y_3) &= \mathbb{E}(Y_2) + \mathbb{E}(Y_3)
\end{align}
<p style="margin: 0px;">This is not the expected value we're looking for, but it shows that it's valid to find the expected value of the sum of dependent random variables. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We need to define more random variables to get the expected number of outbreaks of newly infected cities. The total number of such outbreaks is $O$, while the number after the $k$-th epidemic card is $O_k$. These are related by,</p>
\begin{align}
O = \sum_{k=1}^5 O_k
\end{align}
<p style="margin: 0px;">Since after each epidemic card there can be either 0 or 1 outbreaks in the newly infected city, the expected number of outbreaks is equal to the probability of such an outbreak.</p>
\begin{align}
\mathbb{E}O_k &= 0 \cdot (1 - P(\text{O from E$k$})) + 1 \cdot P(\text{O from E$k$}) \\
\mathbb{E}O_k &=P(\text{O from E$k$})
\end{align}
<p style="margin: 0px;">Thus the total number of expected such outbreaks in an entire game is equal to the sum of these probabilities.</p>
\begin{align}
\mathbb{E}O&= \sum_{k=1}^5 P(\text{O from E$k$})\\
\mathbb{E}O&= 1.234
\end{align}
<p style="margin: 0px;">This sum seems surprisingly high. I feel I don't get this happening this often. What could explain the surprise? One possibility is that because it is apparent when this is more likely to happen, players choose to use event cards that can avoid such scenarios at the proper times. Another possibility is that I've made some computation error. We'll check this next.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Our second approach is to rewrite our probabilities in terms of $X_k$ instead of $Y_k$, because $X_k$ are independent. We'll use $Y_k = X_k - X_{k-1}$ to rewrite an earlier equation.</p>
\begin{align}
P(\text{O from E$k$}) &= \sum_{x_{k-1}} \sum_{x_{k}} \frac{r_k}{1+r_{k-1}\cdot (x_k-x_{k-1})}\cdot p_{X_k,X_{k-1}}(x_k,x_{k-1}) \qquad k \geq 2
\end{align}
<p style="margin: 0px;">Because $X_k$ are independent, the joint pmf is equal to the product of the pmfs.</p>
\begin{align}
p_{X_1,X_2,X_3,X_4,X_5}
(x_1,x_2,x_3,x_4,x_5) &= p_{X_1}(x_1) p_{X_2}(x_2) p_{X_3}(x_3) p_{X_4}(x_4) p_{X_5}(x_5)
\end{align}
<p style="margin: 0px;">This has a constant value when non-zero.</p>
\begin{align}
p_{X_1,X_2,X_3,X_4,X_5}&= \frac{1}{5} \cdot \frac{1}{5} \cdot \frac{1}{5} \cdot \frac{1}{5} \cdot \frac{1}{5} \\
&= \frac{1}{5^5} = \frac{1}{3125}\\
&=0.00032
\end{align}
<p style="margin: 0px;">The conditional probabilities are useful here.</p>
\begin{align}
P(\text{O from E$k$}|X_k=x_k,X_{k-1}=x_{k-1}) &= \frac{r_k}{1+r_{k-1}\cdot (x_k-x_{k-1})} \qquad k \geq 2
\end{align}
<p style="margin: 0px;">And the conditional pmfs of $O_k$.</p>
\begin{align}
p_{O_1|X_1=x_1}(o) &= \begin{cases}
1 - \cfrac{2}{8+2x_1} & o = 0\\
\cfrac{2}{8+2x_1} & o = 1
\end{cases}\\
p_{O_k|X_k=x_k,X_{k-1}=x_{k-1}}(o) &= \begin{cases}
1 - \cfrac{r_k}{1+r_{k-1}\cdot (x_k-x_{k-1})} & o = 0\\
\cfrac{r_k}{1+r_{k-1}\cdot (x_k-x_{k-1})} & o = 1
\end{cases}
\end{align}
<p style="margin: 0px;">We combine these to get the total number of such outbreaks, $O$, conditioned on $X_1$ through $X_5$ and use convolution to get the resulting conditional pmf.</p>
\begin{align}
p_{O|\underline{X}=\underline{x}}(o) = p_{O_1|\underline{X}=\underline{x}}(o) * p_{O_2|\underline{X}=\underline{x}}(o) * p_{O_3|\underline{X}=\underline{x}}(o) * p_{O_4|\underline{X}=\underline{x}}(o) * p_{O_5|\underline{X}=\underline{x}}(o)
\end{align}
<p style="margin: 0px;">Here $\underline{X}$ is a vector representing all $X_1$ through $X_5$, similarly with $\underline{x}$, both are used for brevity. Note that conditioning on $X_k$ that do not influence $O_k$ has no affect on the corresponding conditional pmf. Then we can use the law of total probability to sum across all $\underline{X}$.</p>
\begin{align}
p_O(o) &= \sum_{x_1=1}^5 \sum_{x_2=6}^{10} \sum_{x_3=11}^{15} \sum_{x_4=16}^{20} \sum_{x_5=21}^{25} p_{O|\underline{X}=\underline{x}}(o) \cdot p_{\underline{X}}
(\underline{x}) \\
&= \sum_{x_1=1}^5 \sum_{x_2=6}^{10} \sum_{x_3=11}^{15} \sum_{x_4=16}^{20} \sum_{x_5=21}^{25} p_{O|\underline{X}=\underline{x}}(o) \cdot 0.00032
\end{align}
<p style="margin: 0px;">This is sort halfway towards an exhaustive check, as we just sum over all $5^5=3125$ possible locations of the 5 epidemic cards. As such, this is obviously a calculation made to be done by a computer. Note also, though, that we are making use of the probability equations for drawing the newly infected city and don't have to count through all those cases too. The resulting distribution is plotted in Fig. 7. The expected value, $\mathbb{E}O \approx 1.234$, matches our earlier calculation, which adds to our confidence that we are correct.</p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAd-B9uqZ_ZxYxxcrjIIsrbQ0cW2qAWkZkNkILjuPB0uQjmDFDaAuPbcM94mJ96ditwekUahc6zlfWubl9vjo0pYqhKMoNs2FAVs1y82lQSC-knSVngIw1G-3RerSVjBT7Kx_K8pt8Hrt2XIR4FowWDxfGEgbMO19ApK6j8TNQbH0ojkvRc9n9M9pRK995/s700/pandemic_4.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAd-B9uqZ_ZxYxxcrjIIsrbQ0cW2qAWkZkNkILjuPB0uQjmDFDaAuPbcM94mJ96ditwekUahc6zlfWubl9vjo0pYqhKMoNs2FAVs1y82lQSC-knSVngIw1G-3RerSVjBT7Kx_K8pt8Hrt2XIR4FowWDxfGEgbMO19ApK6j8TNQbH0ojkvRc9n9M9pRK995/w400-h258/pandemic_4.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 7: Probability mass function of the number of outbreaks of newly infected cities immediately after an epidemic card</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">Further avenues for exploration</h2>
<p style="margin: 0px;">We started off with a relatively simple question with a relatively simple answer, that the probability of drawing an epidemic card on any particular turn is 0.2, but ended up looking at quite a bit more. We ended up with both an unexpected question and answer, that it is more likely than not that there is at least one outbreak that players cannot avoid. (Cannot avoid without special abilities or event cards, that is.) Before getting into the conditional case, I had thought that autocorrelation and power spectral density would be useful concepts, but they ended up not really fitting in because of the finite, and rather small, number of turns in Pandemic. We could go on to compute the joint distribution of $Y_k$, but it wasn't necessary for what we were interested in, and with so many variables it's not immediately apparent how to visualize. An interesting question I'll leave unanswered but is perhaps the next in a sequence to tackle is this: what is the distribution of the total number of cards drawn from the infection deck?</p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-49023575037084961692022-05-09T15:00:00.001-07:002022-05-09T15:00:00.192-07:00How long will a siege last in War of the Ring?
For simplicity, we'll assume that no combat cards are played, as that complicates things too much for an initial look. <div><br /></div><div>Our first step is to compute if there is a round of combat, how many units get removed
without leaders, this is pretty clear: it's a binomial distribution with n = # of units (max 5)
and $p = 2/6$ for defender (hit on 5 & 6), $p = 1/6$ for attacker (hit on only 6)
Let $X_n$ be a random variable equal to the number of hits generated by an attack with $n$ combat dice. <div>\begin{align}
P(X_n=x) = \binom{n}{x}\cdot (1-p)^x \cdot p^{(n-x)}
\end{align}
With as many leaders as units (or 5 leadership in the case of larger armies), we can use the same approach.
Because any die that misses the combat roll will get rerolled in the leader reroll, we can compute the combined probability, $p_l$, of hitting on either the combat roll or the leader reroll for each die
namely. </div><div>\begin{align}
p_l &= p + (1-p)\cdot p \\
&= 2\cdot p-p^2
\end{align}
It may be handy to look at the probability of a miss in this case also.
\begin{align}
1 - p_l &= 1 - 2\cdot p + p^2 \\
&= (1-p)^2
\end{align}
If we let $X_n'$ be a random variable equal to the number of hits generated by an attack with $n$ combat dice and at least $n$ leadership. This is the same idea as $X_n$, but with at least $n$ leadership.
\begin{align}
P(X_n' = x) &= \binom{n}{x}\cdot (1-p_l)^x \cdot {p_l}^{(n-x)} \\
&= \binom{n}{x}\cdot (1-p)^{2x} \cdot \left ( 2\cdot p-p^2 \right )^{(n-x)}
\end{align}
When the leadership and combat strength do no match, then it gets more tricky.
It's tempting to think that we can just add two cases. That is, it may seem that 5 combat strength with 3 leadership is equivalent to adding the hits generated by 3 combat strength with 3 leadership and 2 combat strength with 0 leadership. However, this is not the case, because that way if the 3 units with leadership hit and the 2 units without leadership miss, then there is no leadership reroll. However, in the case with 5 units with 3 leadership roll the same as before, if any two units miss then their dice get rerolled. Thus, we'd need to approach it differently. For simplicity, we'll set this case aside and focus on the extremes of no leadership and maximum leadership. </div><div><br /></div><div>Using the equations we derived, we can compute the probabilities of getting different numbers of hits for a variety of situations. There are three variables we'll consider: the number of combat dice rolled, whether leaders are present, and whether the units are attacking a fortified position, meaning either a stronghold or a city or fortification in the first round. The next several figures plot the probabilities in a couple different ways. </div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi872sJVPq_Zc3ZE0iRqvBslgZe8HD38qVxyl2RcgMz3HYDbeghTk7JJO7d_oR1OzRC1XRoenCoIkaNfKmCS8fd-dzGaWDyLhVw9fAZOk6t3M-o2a21c9ljBAjBJ90A8zvQ0q6L75WcIOD4_aiTSMuFUE__8E8lmxhAIZXDfkLmN0ltoRS6DBt9QQRPJA/s700/wotr_hits_by_sit.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi872sJVPq_Zc3ZE0iRqvBslgZe8HD38qVxyl2RcgMz3HYDbeghTk7JJO7d_oR1OzRC1XRoenCoIkaNfKmCS8fd-dzGaWDyLhVw9fAZOk6t3M-o2a21c9ljBAjBJ90A8zvQ0q6L75WcIOD4_aiTSMuFUE__8E8lmxhAIZXDfkLmN0ltoRS6DBt9QQRPJA/w400-h258/wotr_hits_by_sit.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: PMF of hits in War of the Ring when attacking with 5 units</td></tr></tbody></table><br /><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73vQJpI7S4A7iKBDDEqkh4FJalGIttjV14BZqsxx90av5znRh7KCnjg6yiOJhsfzfsHPbXoHNJbNT0SZwLdDIbo0r32A82MVlGsFbRDOGdkEaALSnyV12wX53uXrtUVAWzIzIKYzcL8KWEHUEYRseSaLF1RdCwHIDY5JQUYO1mcdJcQay4g-8I0au-A/s700/wotr_hits_6wL.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73vQJpI7S4A7iKBDDEqkh4FJalGIttjV14BZqsxx90av5znRh7KCnjg6yiOJhsfzfsHPbXoHNJbNT0SZwLdDIbo0r32A82MVlGsFbRDOGdkEaALSnyV12wX53uXrtUVAWzIzIKYzcL8KWEHUEYRseSaLF1RdCwHIDY5JQUYO1mcdJcQay4g-8I0au-A/w400-h258/wotr_hits_6wL.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: PMF of hits in War of the Ring when attacking a fortified position with leadership</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja9u4ARhAFVLhaOHbaxsyAWm8OXHHlMnfeLHvrSiYeM3qgB6e3_Yhpx6LdDRmrfSevknKsTZvqv1-B1jq8Jbk4TVg8Xv4-n5UYPWoujYD7noSun5duxOS6xYZg-7EaPkK0pVBJLYs5_tKF88n7jPdjTItUPc1_EGjcABkSwFfN1kHKJgKVE14XJEdYDQ/s700/wotr_hits_5wL.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja9u4ARhAFVLhaOHbaxsyAWm8OXHHlMnfeLHvrSiYeM3qgB6e3_Yhpx6LdDRmrfSevknKsTZvqv1-B1jq8Jbk4TVg8Xv4-n5UYPWoujYD7noSun5duxOS6xYZg-7EaPkK0pVBJLYs5_tKF88n7jPdjTItUPc1_EGjcABkSwFfN1kHKJgKVE14XJEdYDQ/w400-h258/wotr_hits_5wL.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: PMF of hits in War of the Ring when attacking an unfortified position with leadership</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1QSiimNZaFB0g6Wbgpu9SNmPmrwcYOArGWFWBkAyoO86lL2b9qjmHnhsleUEZsJeAM1LVn_X9jQBdOpfLwE6roC29TT5qsBfA1fkCJ0agY8NT2sxZEwNplZN-h7yG6zuXvbjSobPgsLRM7RHSISMDlTL4HZQEW9RnpyvRv17V8dmIUIU8X-AVH4MMyg/s700/wotr_hits_6noL.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1QSiimNZaFB0g6Wbgpu9SNmPmrwcYOArGWFWBkAyoO86lL2b9qjmHnhsleUEZsJeAM1LVn_X9jQBdOpfLwE6roC29TT5qsBfA1fkCJ0agY8NT2sxZEwNplZN-h7yG6zuXvbjSobPgsLRM7RHSISMDlTL4HZQEW9RnpyvRv17V8dmIUIU8X-AVH4MMyg/w400-h258/wotr_hits_6noL.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 4: PMF of hits in War of the Ring when attacking a fortified position without leadership</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQpZTBZj3tHVZWE59lNF5gHt7YRHPOj-RQX47NmGp-v3J9geHBFV-HuGfQIBv2yjK6424W1Iz9W91zTZYgLr6wtpXMZ45njukE_3St5i5ygDPnqrtOz4oyxE8iX99yKFuIIc0_Olk7nRPnmYpLo-kAwULajFK7sl1NeDUvMb5iucXar8HTI46rRRm58Q/s700/wotr_hits_5noL.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQpZTBZj3tHVZWE59lNF5gHt7YRHPOj-RQX47NmGp-v3J9geHBFV-HuGfQIBv2yjK6424W1Iz9W91zTZYgLr6wtpXMZ45njukE_3St5i5ygDPnqrtOz4oyxE8iX99yKFuIIc0_Olk7nRPnmYpLo-kAwULajFK7sl1NeDUvMb5iucXar8HTI46rRRm58Q/w400-h258/wotr_hits_5noL.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 5: PMF of hits in War of the Ring when attacking an unfortified position without leadership</td></tr></tbody></table><br /><div>Our next step is to find how many rounds of combat a siege is expected to last. We'll use three techniques to quantify this and compare. Throughout, we'll use a few common assumptions. While the number of defending units may vary, being able to take a total of $d$ hits, we fix the number of attack dice at five, either with or without leadership. We thus remove the possibility that the siege goes well enough for the defender that the attackers are whittled down or eliminated. </div><div><br /></div><div>First, we'll estimate it based on how many individual dice it takes to eliminate the defending units, similar to when we looked at <a href="https://www.quantifyingstrategy.com/2020/05/whats-toughest-unit-in-memoir-44.html">What's the toughest unit in Memoir '44?</a>. The limitation here is that when moving from rolling one die at a time to five dice at a time there's different quantization occurring. Needing to roll one through five dice is all just one round of combat, but moving from five dice to six dice means a second round even though it's only one die. The averaging that occurs over dice and rounds can have a notable impact. We'll see when we compare. Each die eliminates one hit point of defending units with probability $p$ (or $p_l$ with leadership). The expected number of dice to generate this one hit is $1/p$. Thus, to generate $d$ hits we can estimate $d/p$ dice on average. Since five dice are rolled each round, this means there should be about $d/(5p)$ rounds on average. </div><div><br /></div><div>For the next two methods, we'll make use of a Markov chain, as we did when checking if it was possible an event was never drawn in a previous problem. We'll start with an initial state column vector $\mathbf{s_d}$ that indicates the number, $d$, of hit points of the defenders in the siege. The vector is zero everywhere, except in index $d$, where it has a value of 1 to indicate that the initial probability of there being $d$ defending hit points is 1. (I'll use indexes starting at 0, instead of 1 as commonly done, as it lines up nicely with programming as well as the meaning in this problem.) For example, with 10 defending hit points,
\begin{align}
\mathbf{s_{10}}^T & =
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1
\end{bmatrix}
,
\end{align}
where $\mathbf{s_d}^T$ is the transpose of $\mathbf{s_d}$, shown to fit on the page more easily. Note the 1 would be in the bottom position of the column vector. Each position in the vector corresponds to the 11 total states: 0-10 defending hit points of units. </div><div><br /></div><div>We can multiply this by a transition matrix $\mathbf{P}$.
\begin{align}
\mathbf{P} =
\begin{bmatrix}
p_{0,0} & p_{0,1} & \dots & p_{0,10}\\
p_{1,0} & p_{1,1} \\
\vdots & & \ddots \\
p_{10,0} & p_{10,1} & \ldots & p_{10,10}
\end{bmatrix}
\end{align}
An element of $\mathbf{P}$, $p_{i,j}$ is the probability of transitioning from state $j$ to state $i$, in line with matrix multiplication. This is a left stochastic matrix, where each column adds to one. You may find this less common than right stochastic matrices, where each row sums to one. This means that the matrices and equations here may need to be transposed to compare to other sources. The core is whether $p_{i,j}$ is as used here or as the probability of transitioning from state $i$ to state $j$. The left and right names have to do with whether the stochastic matrix should multiply state probability vectors from the left or right. </div><div><br /></div><div>To fill in the values of this matrix, let's work with the probabilities of getting a certain number of hits by the attacker, which we assume always rolls 5 dice for simplicity. The probability $p_h$ is the probability of getting $h$ hits. Thus we have six probabilities of interest here: $p_0$, $p_1$, $p_2$, $p_3$, $p_4$, and $p_5$, where $p_h = P(X_5 = h)$ as found earlier. We construct $\mathbf{P}$ from these individual probabilities. Each column represents the probabilities of moving from one state to the others. Thus, the values of each column must sum to 1, as the probability of ending up in one of the states is 1 and all states are under consideration here. Further, since there is no way to add defending hit points during a battle, we know that many of the entries are zero.
\begin{align}
p_{i,j} = 0 \qquad i > j
\end{align}
We can't transition from state $j$, which has $j$ defending hit points, to a state $i$, which has $i$ defending hit points, where $i>j$. </div><div><br /></div><div>We'll go through the matrix one column at a time to build it up. The first column, representing what happens when there are already no defending units is fairly simple, as we must stay in that state. Thus, the transition probabilities are either 0 or 1.
\begin{align}
p_{i,0} =
\begin{cases}
1 &\qquad i = 0 \\
0 &\qquad i \neq 0
\end{cases}
\end{align}
Specifically, the probability of staying in state 0 is 1 and the probability of transitioning to any other state is 0. </div><div><br /></div><div>In the next column, we start with one defending hit point and there are two possibilities: if no hits are rolled, then stay in the same state, but if any hits are rolled, then move to state 0.
\begin{align}
p_{i,1} =
\begin{cases}
\sum_{h=1}^5 p_h = (1-p_0) &\qquad i = 0 \\
p_0 & \qquad i = 1\\
0 &\qquad i > 1
\end{cases}
\end{align}
The next several columns follow this pattern
\begin{align}
p_{i,2} =
\begin{cases}
\sum_{h=2}^5 p_h &\qquad i = 0 \\
p_1 & \qquad i = 1\\
p_0 & \qquad i = 2\\
0 &\qquad i > 2
\end{cases}
\end{align}
Eventually, no summation is necessary and next the probability of reaching state 0 in the single transition of one round of combat becomes 0, as it would require more than the maximum 5 hits.
\begin{align}
p_{i,6} =
\begin{cases}
0 &\qquad i = 0 \\
p_5 & \qquad i = 1\\
p_4 & \qquad i = 2\\
p_3 & \qquad i = 3\\
p_2 & \qquad i = 4\\
p_1 & \qquad i = 5\\
p_0 & \qquad i = 6\\
0 &\qquad i > 6
\end{cases}
\end{align}
We can also generalize this.
\begin{align}
p_{i,j} =
\begin{cases}
p_5 & \qquad i = j-5\\
p_4 & \qquad i = j-4\\
p_3 & \qquad i = j-3\\
p_2 & \qquad i = j-2\\
p_1 & \qquad i = j-1\\
p_0 & \qquad i = j\\
0 &\qquad i < j-5, i > j
\end{cases} \qquad j \geq 5
\end{align}
Multiplying some probability state vector, such as $\mathbf{s_d}$, by $\mathbf{P}$ gives the updated probabilities of being in each state after one round of combat.
\begin{align}
\mathbf{s_{new}} = \mathbf{P} \times \mathbf{s_{old}}
\end{align}
We can repeat this to get the probabilities after multiple rounds of combat.
\begin{align}
\mathbf{s_{r=2}} &= \mathbf{P} \times \mathbf{s_{n=1}}\\
\mathbf{s_{r=2}} &= \mathbf{P} \times \left ( \mathbf{P} \times \mathbf{s_{n=0}} \right ) \\
\mathbf{s_{r=2}} &= \mathbf{P}^2 \times \mathbf{s_{n=0}}
\end{align}
Here $\mathbf{s_{r=2}}$ indicates the state probability vector after two rounds of combat.
Matrix exponentiation is repeated matrix multiplication as exponentiation is repeated multiplication.
\begin{align}
\mathbf{P}^r &= \underbrace{\mathbf{P} \times \mathbf{P} \times \cdots \times \mathbf{P}}_{r \text{ times}}
\end{align}
Since it comes up later if you pay attention, so we'll note that just as $x^0 = 1$, $\mathbf{P}^0 = \mathbf{I}$. That is, if we multiply by $\mathbf{P}$ zero times, we should keep what we have, which is accomplished by multiplying by the identity matrix. </div><div><br /></div><div>The number of rounds, $R_{d}$, that it takes to remove all $d$ defending units has a probability mass function that can be extracted by grabbing the probability of being in state 0 beginning in round $r$, using a matrix $\mathbf{A}$.
\begin{align}
\mathbf{A} =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
\end{align}
The point of this matrix is to take the first entry of the state probability vector, which is the probability of there being no defending hit points remaining that we're interested in.
Combining $\mathbf{A}$, $\mathbf{P}$, and $\mathbf{s_{d}}$, we find the probability that there are no defending units in round $r$.
\begin{align}
P(0\text{ defenders in round } r) = \mathbf{A} \times \mathbf{P}^{r} \times \mathbf{s_{d}}
\end{align}
To get the pmf of $R_{d}$, we want to only see the probability that this came to be in round $r$.
\begin{align}
P(R_{d} = r) &= P(0\text{ defenders in round } r) - P(0\text{ defenders in round } r-1)\\
& = \mathbf{A} \times \mathbf{P}^{r} \times \mathbf{s_{d}} - \mathbf{A} \times \mathbf{P}^{r-1} \times \mathbf{s_{d}} \\
& = \mathbf{A} \times \left ( \mathbf{P}^{r} - \mathbf{P}^{r-1} \right ) \times \mathbf{s_{d}}
\end{align}
Here it's useful to make use of an identity matrix, $\mathbf{I}$, which is the matrix multiplication equivalent of multiplying by 1 in that multiplying by it leaves the same matrix.
\begin{align}
P(R_{d}=r) = \mathbf{A} \times \left(\mathbf{P}- \mathbf{I} \right) \times \mathbf{P}^{r-1} \times \mathbf{s_{d}}
\end{align}
For our second technique, let's take this and do enough of an infinite sum to estimate the expected value of $R$. Recall the definition of the expected value of a non-negative discrete random variable.
\begin{align}
\mathbb{E} R_d &= \sum_{r=0}^\infty r \cdot P(R_d = r) \\
&= \sum_{r=0}^\infty P(R_d > r)
\end{align}
We can turn these probability terms around by looking at their complements.
\begin{align}
P(R_d > r) &= 1 - P(R_d \leq r)
\end{align}
The probability that the combat ends in round $r$ or earlier, $P(R_d \leq r)$ is equivalent to there being no defenders in round $r$. They could have been removed in that round or an earlier one. We found this probability earlier.
\begin{align}
P(R_d \leq r) &= P(0\text{ defenders in round } r)\\
&= \mathbf{A} \times \mathbf{P}^{r} \times \mathbf{s_d}
\end{align}
Putting this together, we find the following infinite sum.
\begin{align}
\mathbb{E} R_d &= \sum_{r=0}^\infty \left ( 1 - \mathbf{A} \times \mathbf{P}^{r} \times \mathbf{s_d} \right )
\end{align}
By computing this running sum, as shown in Figure 6 for 10 initial hit points, we observe that it appears to be approaching an asymptote well before 50 rounds.
\begin{align}
\widehat{\mathbb{E} R_d} &= \sum_{r=0}^{50} \left ( 1 - \mathbf{A} \times \mathbf{P}^{r} \times \mathbf{s_d} \right )
\end{align}
The asymptote is approached faster with fewer hit points, which must require fewer rounds to eliminate with the same combat rolls. Thus, we can use the running sum after 50 rounds as a good estimate of the infinite sum. </div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJoFcD9InAu7EPpHkfBFkanry5WcJb-r8Tz6NYwxR9wJHQzZM1wF088MflIC4Fn0fLIZT2c1amfikd80oOXEpEUXXZgSBeIcURGgfPgAPCp21_oKzs10L2Kso2UZbAOfHQlaHgtPAUyOkpUMkKAV1BmPdBTlYH4BCQh_m4RTQJk7VK3LMNFKi00Q4N8Q/s700/wotr_siege_est_10.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJoFcD9InAu7EPpHkfBFkanry5WcJb-r8Tz6NYwxR9wJHQzZM1wF088MflIC4Fn0fLIZT2c1amfikd80oOXEpEUXXZgSBeIcURGgfPgAPCp21_oKzs10L2Kso2UZbAOfHQlaHgtPAUyOkpUMkKAV1BmPdBTlYH4BCQh_m4RTQJk7VK3LMNFKi00Q4N8Q/w400-h258/wotr_siege_est_10.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 6: Running estimate of expected number of combat rounds complete siege of 10 defending hit points</td></tr></tbody></table><br /><div>For our third technique, I think we can do better than an estimate this time. We can solve for the actual expected values.
We'll again look at the number of rounds $R_d$ based on starting with $d$ defending hit points. If we start with no defending units, the siege lasts 0 rounds.
\begin{align}
\mathbb{E}R_0 = 0
\end{align}
If we start with 1 hit point of defenders, then it's just a question of how long until the attacker rolls one hit. The probability of one or more hits if $1-p_0$ and we've previously found that the expected number of tries to get a result that occurs with probability $p$ is $1/p$, so we can find the expected value of $R_1$.
\begin{align}
\mathbb{E}R_1 &= \frac{1}{1-p_0}
\end{align}
We can also leverage the columns of $\mathbf{P}$ to find this result. We know the probabilities of transitioning to each other state. Expectation is linear, so we can write the expectation of the length of a siege in one state based on the expected durations of other states and the transition probabilities.
\begin{align}
\mathbb{E}R_i = \sum_{j=0}^{10} p_{i,j} \cdot (1 + \mathbb{E} R_j)
\end{align}
In particular for state 1, we find the following.
\begin{align}
\mathbb{E}R_1 &= p_0 \cdot \mathbb{E} (1 + R_1) + (1- p_0) \cdot (1 + \underbrace{\mathbb{E} R_0}_{0}) \\
\mathbb{E}R_1 \cdot (1 - p_0) &= p_0 + 1 - p_0 \\
&= 1 \\
\mathbb{E}R_1 &= \frac{1}{1-p_0}
\end{align}
This matches what we had from before and was thus to some extent not necessary to do, but it should help build confidence in this method. We can extent this and work up to each new state.
\begin{align}
\mathbb{E}R_2 &= p_0 \cdot (1 + \mathbb{E} R_2) + p_1 \cdot (1 + \mathbb{E}R_1) + \left ( \sum_{j=2}^5 p_j \right ) \cdot (1 + \mathbb{E} R_0 )
\end{align}
I'll let you go through the algebra to solve this yourself, but as you can imagine, it's not necessarily a very elegant equation.
\begin{align}
\mathbb{E}R_2 &= \frac{1 + \frac{p_1}{1-p_0}}{1-p_0}
\end{align}
This continues, with ever more fractions involving $1-p_0$ denominators. I think there's a way to look at things differently once we get past the bunching up and we're in the generic form that we came up with, but given how complicated this is getting we're not going to get any closed-form equation from which we can glean much meaning. Rather, the only advantage is that we've come up with a way through which we can calculate the result of interest without approximating anything (beyond the limits inherent in whatever computation tool we use). </div><div><br /></div><div>However, there is an alternate way of solving these equations using linear algebra. First, let's put these expected values into a row vector.
\begin{align}
\mathbf{R} &=
\begin{bmatrix}
\mathbb{E}R_0 &
\mathbb{E}R_1 &
\dots &
\mathbb{E}R_{10}
\end{bmatrix}
\end{align}
Now, we can express this in terms of the transition matrix $\mathbf{P}$. We're taking the previous equation for the expected number of rounds to reach state 0 from each other state,
\begin{align}
\mathbb{E}R_i = \sum_{j=0}^{10} p_{i,j} \cdot (1 + \mathbb{E} R_j),
\end{align}
and rewriting them all at once with matrices.
\begin{align}
\mathbf{R} &= \left ( \mathbf{J_{1\times 11}} + \mathbf{R} \right ) \times \mathbf{P}
\end{align}
Here $\mathbf{J_{1\times 11}}$ is an one by eleven matrix of all ones, a row vector of all ones. (Note that while my indexing starts at 0, the dimension subscripts here still refers to the size.) Next, we'll do some linear algebra to solve for $\mathbf{R}$.
\begin{align}
\mathbf{R} - \mathbf{R} \times \mathbf{P} &= \mathbf{J_{1\times 11}} \times \mathbf{P} \\
\mathbf{R} \times \left ( \mathbf{I} - \mathbf{P} \right ) &= \mathbf{J_{1\times 11}} \times \mathbf{P} \\
\mathbf{R} &= \mathbf{J_{1\times 11}} \times \mathbf{P} \times \left ( \mathbf{I} - \mathbf{P} \right )^{-1}
\end{align}
At this point we can simplify the equation. We do this because multiplying a row vector of ones by each column of $\mathbf{P}$ is equivalent to adding up each column of $\mathbf{P}$ and putting the results into a row vector. Since these columns represents the transition probabilities from a given state and we we're considering all the states, each column must sum to one, as the probability of transitioning to some state is 1 (staying in the same state is considered a transition for simplicity).
\begin{align}
\mathbf{J_{1\times 11}} \times \mathbf{P} &= \mathbf{J_{1\times 11}} \\
\mathbf{R} &= \mathbf{J_{1\times 11}} \times \left ( \mathbf{I} - \mathbf{P} \right )^{-1}
\end{align}
This equation looks like it should work, but doesn't because $\mathbf{I} - \mathbf{P} $ isn't invertible, as it has a column of zeros. The left column of $\mathbf{P}$ is a one followed by all zeros, which is exactly the same as the left column of the identity matrix $\mathbf{I}$. </div><div><br /></div><div>We can, however, look at a submatrix, because we know $\mathbb{E}R=0$, so we can just eliminate that part of our set of equations.
\begin{align}
\mathbf{R} &=
\begin{bmatrix}
0 &
\mathbb{E}R_1 &
\cdots &
\mathbb{E}R_{10}
\end{bmatrix}\\
&=
\begin{bmatrix}
0 & \mathbf{R_{1\text{-}10}}
\end{bmatrix}
\end{align}
We'll start by dividing $\mathbf{P}$ into submatrices.
\begin{align}
\mathbf{P} =
\begin{bmatrix}
1 & \mathbf{T} \\
\mathbf{0} & \mathbf{Q} \\
\end{bmatrix}
\end{align}
Here, 1 is a single 1, representing that once we get to state 0 we stay there. As a corollary, in state 0 we don't transition to any other states, so the column vector $\mathbf{0}$ represents a set of zeros for those transition probabilities. Next, $\mathbf{Q}$ represents the one-step transition probabilities amongst the transient states 1-10. (Transient meaning that the system is only in those states temporarily as it transitions, at least with probability 1. There is the pathological case where it could stay there forever which occurs with probability 0.) Finally, $\mathbf{T}$ represents the probabilities of transitioning in one step from the transient states 1-10 to the recurrent and absorbing state 0. (Recurrent states once reached, recur infinitely many times with probability 1. Absorbing states can never be left.) Note that $\mathbf{T}$ is often called $\mathbf{R}$, but we've already used that, so we had to go with a different letter here. I've often seen the matrix $\mathbf{P}$ organized a bit differently, with the recurrent states at the bottom. (The calculation we're doing is often referred to as the hitting time.) While convention is useful, we are not constrained by it. </div><div><br /></div><div>Next, we just plug in these divided $\mathbf{R}$ and $\mathbf{P}$.
\begin{align}
\begin{bmatrix}0 & \mathbf{R_{1\text{-}10}} \end{bmatrix}
&= \left ( \mathbf{J_{1\times 11}} + \mathbf{R} \right ) \times
\begin{bmatrix}
1 & \mathbf{T} \\
\mathbf{0} & \mathbf{Q} \\
\end{bmatrix}
\end{align}
Now we'll get rid of the left entry of both sides. Note that another way of looking at the issue with the full matrix $\mathbf{P}$ is that it yielded a nonsensical equation for $\mathbb{E}R_0$.
\begin{align}
\mathbb{E}R_0 &= 1 + \mathbb{E}R_0
\end{align}
We could fix this equation so that it's not wrong, but including $\mathbb{E}R_0 = \mathbb{E}R_0$ still doesn't let us solve for $\mathbb{E}R_0$, which we already know anyways. </div><div><br /></div><div>To remove the left entry of the right side of our matrix equation, we remove the left column of $\mathbf{P}$.
\begin{align}
\mathbf{R_{1\text{-}10}} &= \left ( \mathbf{J_{1\times 11}} + \mathbf{R} \right ) \times \begin{bmatrix} \mathbf{T} \\ \mathbf{Q} \end{bmatrix}
\end{align}
Now we'll break up $\mathbf{J_{1\times 11}}$ and $\mathbf{R}$ on the right side, so that we can multiply out with the remains of $\mathbf{P}$, using the rules of matrix multiplication.
\begin{align}
\mathbf{R_{1\text{-}10}} &= \left (
\begin{bmatrix} \mathbf{J_{1\times 1}} & \mathbf{J_{1\times 10}} \end{bmatrix}
+ \begin{bmatrix} 0 & \mathbf{R_{1\text{-}10}} \end{bmatrix} \right )
\times
\begin{bmatrix} \mathbf{T} \\ \mathbf{Q} \end{bmatrix} \\
&=\mathbf{J_{1\times 1}} \times \mathbf{T} + \left ( \mathbf{J_{1\times 10}} + \mathbf{R_{1\text{-}10}} \right ) \times \mathbf{Q}
\end{align}
Now we do some algebra so that we can solve for $\mathbf{R_{1\text{-}10}}$.
\begin{align}
\mathbf{R_{1\text{-}10}} \times \left ( \mathbf{I} - \mathbf{Q} \right ) &= \mathbf{J_{1\times 1}} \times \mathbf{T}+ \mathbf{J_{1\times 10}} \times \mathbf{Q} \\
\mathbf{R_{1\text{-}10}} &= \left ( \mathbf{J_{1\times 1}} \times \mathbf{T}+ \mathbf{J_{1\times 10}} \times \mathbf{Q} \right ) \times \left ( \mathbf{I} - \mathbf{Q} \right ) ^ {-1}
\end{align}
Recall our step earlier where we used the equation $\mathbf{J_{1\times 11}} \times \mathbf{P} = \mathbf{J_{1\times 11}}$ to simplify, as each column of $\mathbf{P}$ sums to one. This remains true of the submatrix.
\begin{align}
\begin{bmatrix} \mathbf{J_{1\times 1}} & \mathbf{J_{1\times 10}} \end{bmatrix} \times
\begin{bmatrix}\mathbf{T} \\ \mathbf{Q} \end{bmatrix} &= \mathbf{J_{1\times 1}} \times \mathbf{T} + \mathbf{J_{1\times 10}} \times \mathbf{Q}\\
&= \mathbf{J_{1\times 10}}
\end{align}
Recall that $\mathbf{T}$ and $\mathbf{Q}$ have 10 columns, hence the 10 columns in the last equation, which we can use to find $\mathbf{R_{1\text{-}10}}$.
\begin{align}
\mathbf{R_{1\text{-}10}} &= \mathbf{J_{1\times 10}} \times \left ( \mathbf{I} - \mathbf{Q} \right ) ^ {-1}
\end{align}
The result of this computation for 1-10 initial defending hit points is plotted in Figure 7. While a fair amount of computation is elided by including a matrix inversion, which is not always trivial, in this case standard algorithms seem to have no issue, numerical or otherwise. </div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivzjx3AnKsHJ_8sKSZuFsrToDNhmsO8IZylda1Td8yTw_jpVUnQdNYROiYt6FCB8duL3J36lNqAV4vYMjVqMr9MdH_uwFGMQ6XI1jwiKSVfjvmqdeb-7d_thY2PifJEjTIDlHxDYoL-sKJhgwt9u3jBw01An_5Y3cDgXTVSXPV0AFvylK0GREk5xS6DQ/s700/wotr_siege_la.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivzjx3AnKsHJ_8sKSZuFsrToDNhmsO8IZylda1Td8yTw_jpVUnQdNYROiYt6FCB8duL3J36lNqAV4vYMjVqMr9MdH_uwFGMQ6XI1jwiKSVfjvmqdeb-7d_thY2PifJEjTIDlHxDYoL-sKJhgwt9u3jBw01An_5Y3cDgXTVSXPV0AFvylK0GREk5xS6DQ/w400-h258/wotr_siege_la.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 7: Calculated expected length siege by number of defending hits points</td></tr></tbody></table><br /><div>The results from the three methods can be compared by inspecting the plots in Figures 8 and 9, which show the results with and without leadership/rerolls, respectively. The first rough estimate is somewhat lower than the two later techniques, which appear indistinguishable. Both provide the very similar trends, dominated by a linear factor between initial defending hit points and expected length of the siege. </div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggUYXMP6esflPvuqXH7bL4hCSbMXG4zeRHRmycnYyIbb0jSeHaPVuuFO_CMUGIk42N0fNtS0VymmYZrR6YAlKzbC0py66zIab9uF2Vg_-z-FFF8vRgBFxRnkTKO8WXvpOCXU9Tp1H_-Sx3vYdrR2EBZJps_bOWEYFi1SoGdcg-3a-k-f8pdV1o1kqJ-g/s700/wotr_siege_est_rr.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggUYXMP6esflPvuqXH7bL4hCSbMXG4zeRHRmycnYyIbb0jSeHaPVuuFO_CMUGIk42N0fNtS0VymmYZrR6YAlKzbC0py66zIab9uF2Vg_-z-FFF8vRgBFxRnkTKO8WXvpOCXU9Tp1H_-Sx3vYdrR2EBZJps_bOWEYFi1SoGdcg-3a-k-f8pdV1o1kqJ-g/w400-h258/wotr_siege_est_rr.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 8: Comparison of methods to find expected length of siege with rerolls</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0nObxAPW_0fj-GhNis6ieJMtIg7CF88DapuiMVD51UG2Jhh0aekI4PM90Uy-G1s2W2eF59gA7HDlvxo2IAUBgXPumAwMrNS6p4N7qmp6qz7jzw1fMPWdJBKXqEmlga4spqH7P4bCRsEh6WuM_1_cpMFw1OKjyurHAfnqTFQhtJojDRY9XkjluaUHAUw/s700/wotr_siege_est.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="450" data-original-width="700" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0nObxAPW_0fj-GhNis6ieJMtIg7CF88DapuiMVD51UG2Jhh0aekI4PM90Uy-G1s2W2eF59gA7HDlvxo2IAUBgXPumAwMrNS6p4N7qmp6qz7jzw1fMPWdJBKXqEmlga4spqH7P4bCRsEh6WuM_1_cpMFw1OKjyurHAfnqTFQhtJojDRY9XkjluaUHAUw/w400-h258/wotr_siege_est.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 9: Comparison of methods to find expected length of siege without rerolls</td></tr></tbody></table><br /><div>It may also be interesting to compare against the methods used when we addressed the question <a href="https://www.quantifyingstrategy.com/2020/07/what-is-best-weapon-in-d.html">What is the best weapon in D&D?</a>. There we used a different approach when dealing with similar issues.</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-58183432440493197802022-04-18T15:00:00.001-07:002022-04-18T15:00:00.202-07:00How many menus are there in Sushi Go Party!?<p>Sushi Go Party! includes a lot of options not available in the original Sushi Go. Players can select what on the menu\footnote{Unfortunately, there's also a menu item titled menu.} for each play. A valid menu has a set format: Nigiri is always included, as well as one of three types of roll, three out of eight types of appetizer, two out of eight types of specials, and one of three types of dessert. Each of these choices is independent, so we can multiply the number of ways to do each together to get the total number of combinations. For appetizers and specials where we're choosing more than one, we don't care about the order, what matters is what items are shuffled into the deck. Thus, we're looking for the number of combinations of each, where the number of combinations of selecting $k$ items from $n$ options, is</p>
\begin{align}
\binom{n}{k} = \frac{n!}{k! \cdot (n-k)!}.
\end{align}
<p style="margin: 0px;">If you want to be able to calculate this manually without a tool with a special function, it can be helpful to do some of the cancellation yourself. We can rewrite this while reducing the amount of common terms in the numerator and the denominator.</p>
\begin{align}
\frac{n!}{k! \cdot (n-k)!} = \frac{\prod_{i=n-k+1}^n i}{k!}
\end{align}
<p style="margin: 0px;">A concrete example may help.</p>
\begin{align}
\binom{8}{3} &= \frac{8!}{3! \cdot (8-3)!}\\
&= \require{cancel}\frac{8 \cdot 7 \cdot 6 \cdot \cancel{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}}{3 \cdot 2 \cdot 1 \cdot \cancel{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}} \\
&= 56
\end{align}
<p style="margin: 0px;">Applying this we get the number of combinations.</p>
\begin{align}
1 \cdot 3 \cdot \binom{8}{3} \cdot \binom{8}{2} \cdot 3 = 14112
\end{align}
<p style="margin: 0px;">There are a couple of wrinkles. First, is that a couple of the menu items score a little bit differently depending on how many players there are, but I don't consider that a different menu.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Second, the above only applies for player counts of 3--6. When there are 2, 7, or 8 players there are some restrictions to the items included. Spoon (a special) and edamame (an appetizer) may not be used in two-player games. Thus in such cases there are fewer menu combinations.</p>
\begin{align}
1 \cdot 3 \cdot \binom{7}{3} \cdot \binom{7}{2} \cdot 3 = 6615
\end{align}
<p style="margin: 0px;">Similarly, in seven- and eight-player games neither menu nor special order are allowed, both of which are specials.</p>
\begin{align}
1 \cdot 3 \cdot \binom{8}{3} \cdot \binom{6}{2} \cdot 3 = 7560
\end{align}Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-19906032612326770642022-04-11T15:00:00.004-07:002022-12-20T10:03:27.257-08:00Elchanan Mossel's Amazing Dice Paradox<p>I recently came across <a href="https://www.youtube.com/watch?v=vhp3d9XXDcQ">this old video</a> from the <a href="https://www.youtube.com/channel/UCHnj59g7jezwTy5GeL8EA_g">MindYourDecisions</a> Youtube channel by Presh Talwalkar (which I find to often be a good source for interesting problems). At first I was sure the video was wrong. Then I thought some more and realized he was right. Finally, I am convinced that he is wrong, but about something else. This post is me shaking my angry fist at the internet and since it's about rolling a die, I figured it was close enough to being about games to count.</p>
<p style="margin: 0px;">First, let's state the problem of the video:</p><p style="margin: 0px;"><br /></p>
<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p style="margin: 0px; text-align: left;"><i>You roll a fair dice until you get a 6. What is the expected number of rolls, including the roll of 6, conditioned on the event that all previous rolls were even numbers?</i></p></blockquote><p>There are two curious changes from the way the problem is stated in most other places that are linked in the video. First, most statements use the singular "die" and not "dice". This is perhaps leaning on the possible internet origin <a href="https://gilkalai.wordpress.com/2017/09/07/tyi-30-expected-number-of-dice-throws/">post</a> of the problem (it is attributed as originally coming from Elchanan Mossel given to undergrad students during a class at UPenn in 2014-5) which uses "dice" in the singular, though this is changed to "die" in the follow-up <a href="https://gilkalai.wordpress.com/2017/09/08/elchanan-mossels-amazing-dice-paradox-answers-to-tyi-30/">post</a>. I find this choice curious because while I do see some usage of dice in the singular (perhaps more in non-American contexts like Shut Up and Sit Down - though even they've corrected dice to die) I see no argument for discarding die as the singular. That is, I've never seen any assertion that the singular "die" is incorrect. Even the <a href="https://www.lexico.com/definition/dice">dictionary used in the video</a> says the following:</p>
<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p style="margin: 0px; text-align: left;"><i>Historically, dice is the plural of die, but in modern English dice can be both the singular and the plural: throw the dice could mean a reference to either one or more than one dice</i></p></blockquote><p>Note the word "can" is used, not "is". This is even more clear in the phrasing on <a href="https://www.lexico.com/en/definition/die">the US version</a> instead of the UK version of the same website:</p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p style="margin: 0px; text-align: left;"><i>Historically, dice is the plural of die, but in modern English dice is sometimes also used in the singular: throw the dice could mean a reference to either one or more than one dice</i></p></blockquote><p>This would leave me with little support for labeling the singular "dice" as wrong, but I still don't see why someone accustomed to the singular "die" would choose to abandon it and introduce ambiguity. I'm used to the singular "die", though, and anything else just sounds weird. If you learned "dice" and are used to it, I could see it being otherwise.</p>
<p style="margin: 0px;">Second, and perhaps more relevantly, most statements of the problem say that <i>all</i> rolls are even numbers instead of all <i>previous</i> rolls. The video makes a big distinction between these and claims them to give different answers. In fact, it claims that the answer to the "all rolls" version of the problem is the oft-given erroneous answer of 3. This is wrong, as I will try to demonstrate here. I will focus on how the two problems are the same. There are other good sources for how to approach the main problem, like the one <a href="http://www.yichijin.com/files/elchanan.pdf">here</a>.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The common wrong answer of 3 comes from the idea that if we condition on rolling even numbers then that is equivalent to rolling a three-sided die with faces labeled 2, 4, and 6. However, that is not true. Instead, we can look at the problem setup to construct all sequences that end in a 6 and exclude those that contain odd numbers. Since 6 is an even number, we will see that conditioning on rolling all even numbers is the same as rolling all even numbers before the 6.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">To quickly reference why the average number of rolls if we rolled a three-sided die until we got a particular side, we can look to our previous work with Memoir '44, where we found that the expected number of rolls needed to achieve a roll with probability $p$ is $1/p$. In this case the probability is $1/3$, so the expected number of rolls, $\mathbb{E}N_3$ is $1/(1/3)=3$. (The notation $N_3$ uses the subscript 3 because there are three sides to the die here.) We can find this by starting by the probability of getting a roll of length $n$,</p>
\begin{align}
P(N_3=n) = \left ( \frac{2}{3} \right ) ^{n-1} \cdot \frac{1}{3},
\end{align}
<p style="margin: 0px;">with an often-useful shortcut to computing the expected value for non-negative integer-valued random variables,</p>
\begin{align}
\mathbb{E} N = \sum_{n=0}^\infty P(N > n).
\end{align}
<p style="margin: 0px;">There are more details in the previous post on <a href="https://www.quantifyingstrategy.com/2021/05/errata-whats-toughest-unit-in-memoir-44.html">the toughest unit in Memoir '44</a>.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's start by looking at sequences of six-sided die rolls of length 1 that end in a 6. Actually, there's just one, as shown in Table 1. There I've annotated it with a * to indicate that it meets our conditioning criteria of containing only even numbers. All $1/1$ of the sequences are allowed.</p>
\begin{align*}
\begin{array}{c}
6 *
\end{array}
\end{align*} <div><div style="text-align: center;">Table 1: Sequences of length 1</div><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Now, let's look at sequences of length 2, where only $2/5$ are allowed.</p>
\begin{align*}
\begin{array}{ccccc}
16 \phantom{*} &
26 * &
36\phantom{*} &
46 * &
56\phantom{*}
\end{array}
\end{align*} </div><div><div style="text-align: center;">Table 2: Sequences of length 2</div><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Finally, let's look at sequences of length 3, where $4/25$ are allowed. We'll stop here lest the number of sequences gets too cumbersome.</p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{ccccc}
116 \phantom{*} & 216 \phantom{*} & 316 \phantom{*} & 416 \phantom{*} & 516 \phantom{*} \\
126 \phantom{*} & 226 * & 326 \phantom{*} & 426 * & 526 \phantom{*} \\
136 \phantom{*} & 236 \phantom{*} & 336 \phantom{*} & 436 \phantom{*} & 536 \phantom{*} \\
146 \phantom{*} & 246 * & 346 \phantom{*} & 446 * & 546 \phantom{*} \\
156 \phantom{*} & 256 \phantom{*} & 356 \phantom{*} & 456 \phantom{*} & 556 \phantom{*}
\end{array}
\end{align*} </div><div><div style="text-align: center;">Table 3: Sequences of length 3</div><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">It looks like for a sequence of length $n$, then $2^{n-1}$ of the $5^{n-1}$ sequences are allowed under the conditioning. This disproportionately removes long sequences, which is why the average is so short. You can think of it this way: the longer the sequence, the more likely it is to have at least one 1,3, or 5 before conditioning. The probability of a sequence being length $n$ is the probability that the first 6 was on roll $n$. Thus, all rolls before this must be something other than 6. The probability of this happening on each roll is $5/6$, while the probability of getting a 6 in round $n$ is $1/6$. Thus, if $N_6$ is a random variable equal to the length of the sequence of rolling a six-sided die, then</p>
\begin{align}
P(N_6=n) = \left ( \frac{5}{6} \right) ^{n-1} \cdot \frac{1}{6}.
\end{align}
<p style="margin: 0px;">However, if we only allow sequences with even numbers, then there are only two valid choices for each roll before the last, thus the individual roll probability changes from $5/6$ to $2/3$ and the sequence probability changes accordingly. With only even rolls allowed, there are three options instead of six and two of them instead of five continue the sequence to be longer. (Heads up for skimmers: this part is wrong and will be corrected later.)</p>
\begin{align}
P(N_6=n \, | \, \text{even rolls}) &= \left ( \frac{2}{3} \right) ^{n-1} \cdot \frac{1}{6} \qquad (1)
\end{align}
<p style="margin: 0px;">Note that this probability is half of the probability $P(N_3=n)$ from above.</p>
\begin{align}
P(N_6=n \, | \, \text{even rolls}) &= \frac{1}{2} P(N_3=n)
\end{align}
<p style="margin: 0px;">Using the definition of expected value for discrete-valued random variables,</p>
\begin{align}
\mathbb{E} N = \sum_n n \cdot P(N=n),
\end{align}
<p style="margin: 0px;">we can find the expected value of $N_6$ given all even rolls.</p>
\begin{align}
\mathbb{E} \left [ N_6 \, | \, \text{even rolls} \right ] &= \sum_{n=1}^\infty n \cdot P(N_6=n \, | \, \text{even rolls}) \\
&=\sum_{n=1}^\infty n \cdot \frac{1}{2} \cdot P(N_3=n) \\
&=\frac{1}{2} \cdot \underbrace{\left (\sum_{n=1}^\infty n \cdot P(N_3=n) \right )}_{\mathbb{E} N_3}\\
&= \frac{1}{2} \cdot 3 \\
&= 1.5
\end{align}
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">That's a little hand-wavy though, so let's take this step slower. We're interested in conditional expectation, and thus conditional probability.</p>
\begin{align}
\mathbb{E}\left [N \, | \, A \right ] = \sum_n n \cdot P(N=n \, | \, A)
\end{align}
<p style="margin: 0px;">Here $A$ is some generic event. Recall that conditional probability is given by the following,</p>
\begin{align}
P(N=n \, | \, A) = \frac{P( N=n \cap A)}{P(A)},
\end{align}
<p style="margin: 0px;">where $\cap$ means <i>and</i>, that is that both the thing on its left and its right are true. For an individual roll that continues the sequence (the roll doesn't equal 6), which we'll label as event $C$ for continuing, the conditional probability is as follows.</p>
\begin{align}
P(C \, | \, \text{even roll}) &= \frac{P(C \cap \text{even roll})}{P(\text{even roll})} \\
&=\frac{\;\cfrac{2}{6}\;}{\;\cfrac{3}{6}\;} \\
&=\frac{2}{3}
\end{align}
<p style="margin: 0px;">Now we apply this to the probability of the final roll. We'll say the probability of ending is $P(E)$.</p>
\begin{align}
P(E \, | \, \text{even roll}) &= \frac{P(E \cap \text{even roll})}{P(\text{even roll})} \\
&=\frac{\;\cfrac{1}{6}\;}{\;\cfrac{3}{6}\;} \\
&=\frac{1}{3}
\end{align}<p style="margin: 0px;">This is not what we want. I've brought us to the wrong answer of 3! (I haven't quite gotten there, but I think you can take the next few steps.)</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">At this point, I think it may be useful to acknowledge one of the commenters to the video for helping me to realize what was going on. I was convinced that the answer should be the same for the "previous" case as the all evens case and didn't believe that 1.5 was the correct answer. <a href="https://www.youtube.com/channel/UCk-0X26PrX-XE2-OGbEHY_Q">Marce Villarino</a> posted some python code that quickly convinced me that 1.5 must be right, but also helped me see that the two cases are actually the same. The code follows.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;"><span style="font-family: courier;">##### Record successive thows of a six sides die, untill a 6 is thrown.</span></p><p style="margin: 0px;"><span style="font-family: courier;">##### If the record does not contain even number, record it's length.</span></p><p style="margin: 0px;"><span style="font-family: courier;">import random</span></p><p style="margin: 0px;"><span style="font-family: courier;">import time</span></p><p style="margin: 0px;"><span style="font-family: courier;">def calcOnlySixStops(howManyTimes):</span></p><p style="margin: 0px;"><span style="font-family: courier;">result = list()</span></p><p style="margin: 0px;"><span style="font-family: courier;">start_time = time.time()</span></p><p style="margin: 0px;"><span style="font-family: courier;">for i in range(howManyTimes):</span></p><p style="margin: 0px;"><span style="font-family: courier;">a = list()</span></p><p style="margin: 0px;"><span style="font-family: courier;">a.append(random.randint(1,6))</span></p><p style="margin: 0px;"><span style="font-family: courier;">while a[-1] != 6:</span></p><p style="margin: 0px;"><span style="font-family: courier;">a.append(random.randint(1,6))</span></p><p style="margin: 0px;"><span style="font-family: courier;">if not((1 in a) or (3 in a) or (5 in a)):</span></p><p style="margin: 0px;"><span style="font-family: courier;">result.append(len(a))</span></p><p style="margin: 0px;"><span style="font-family: courier;">print("--- %s seconds ---" % (time.time() - start_time))</span></p><p style="margin: 0px;"><span style="font-family: courier;">return result</span></p><p style="margin: 0px;"><span style="font-family: courier;">lolailo = calcOnlySixStops(1000000)</span></p><p style="margin: 0px;"><span style="font-family: courier;">print(sum(lolailo)/len(lolailo))</span></p><p style="margin: 0px;"><span style="font-family: courier;">####### about 1.5</span></p><p style="margin: 0px;"><span style="font-family: courier;">####### it takes ca. 43 seconds on my laptop</span></p><p style="margin: 0px;"><span style="font-family: courier;"><br /></span></p><p style="margin: 0px;"><span style="font-family: courier;">##### Same, but throw a three sided die.</span></p><p style="margin: 0px;"><span style="font-family: courier;">def calcThreeSidedDie(howManyTimes):</span></p><p style="margin: 0px;"><span style="font-family: courier;">result = list()</span></p><p style="margin: 0px;"><span style="font-family: courier;">start_time = time.time()</span></p><p style="margin: 0px;"><span style="font-family: courier;">for i in range(howManyTimes):</span></p><p style="margin: 0px;"><span style="font-family: courier;">a = list()</span></p><p style="margin: 0px;"><span style="font-family: courier;">a.append(random.choice([2,4,6]))</span></p><p style="margin: 0px;"><span style="font-family: courier;">while a[-1] != 6:</span></p><p style="margin: 0px;"><span style="font-family: courier;">a.append(random.choice([2,4,6]))</span></p><p style="margin: 0px;"><span style="font-family: courier;">result.append(len(a))</span></p><p style="margin: 0px;"><span style="font-family: courier;">print("--- %s seconds ---" % (time.time() - start_time))</span></p><p style="margin: 0px;"><span style="font-family: courier;">return result</span></p><p style="margin: 0px;"><span style="font-family: courier;">lolailo = calcThreeSidedDie(1000000)</span></p><p style="margin: 0px;"><span style="font-family: courier;">print(sum(lolailo)/len(lolailo))</span></p><p style="margin: 0px;"><span style="font-family: courier;">####### abt 3.0</span></p><p style="margin: 0px;"><span style="font-family: courier;">####### it takes ca. 19 s on my laptop.</span></p><p style="margin: 0px;"><span style="font-family: courier;"><br /></span></p><p style="margin: 0px;">As you can see from the annotated results, or if you run it yourself, it shows that the expected value is approximately 1.5. It uses a Monte Carlo approach with a million trials, which seems sufficient here. Also, if you look through the algorithm to condition on the previous rolls being even, you'll see that it's exactly the same as what you would do if you were to condition on all rolls being even.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">The key error that we made is the same one to get the wrong answer most of the time, I think, just a little drawn out. Note that we conditioned on individual even rolls, not all rolls being even. That's the wrong event. If we want to take that approach, we need to condition the entire $P(N_6=n)$ on getting even rolls. (We could also use the individual pieces, but we still must condition on getting <i>all</i> even rolls, not just the one under consideration at that moment.)</p>
\begin{align}
P(N_6=n \, | \, \text{even rolls}) &= \frac{P(N_6 =n \cap \text{even rolls})}{P(\text{even rolls})}
\end{align}
<p style="margin: 0px;">The numerator is relatively easy to figure out. Based on what we saw above, we find that</p>
\begin{align}
P(N_6 =n \cap \text{even rolls}) = \left ( \frac{2}{6} \right)^{n-1} \cdot \frac{1}{6}
\end{align}
<p style="margin: 0px;">To get this we we took the unconditioned probability of getting a certain number of rolls and combined it with the fraction of the rolls that meet our all evens criteria. But what is the probability of even rolls? Note that this isn't the probability of getting even rolls given a length, it's the overall probability. Here it may be useful to turn things around.</p>
\begin{align}
P(\text{even rolls}) &= \sum_n P(\text{even rolls} \, | \, N_6=n) \cdot P(N_6=n) \\
&= \sum_n P(\text{even rolls} \cap N_6=n)
\end{align}
<p style="margin: 0px;">Since we already know this joint probability from above, we can plug it in.</p>
\begin{align}
P(\text{even rolls}) &= \sum_{n=1}^\infty \left ( \frac{2}{6} \right)^{n-1} \cdot \frac{1}{6}\\
&= \frac{1}{6} \cdot \sum_{n=1}^\infty \left ( \frac{1}{3} \right)^{n-1}
\end{align}
<p style="margin: 0px;">The above includes a geometric series. We can adjust the range and the exponent to make it look more familiar</p>
\begin{align}
P(\text{even rolls}) &= \frac{1}{6} \cdot \underbrace{\sum_{n=0}^\infty \left ( \frac{1}{3} \right)^{n}}_{\cfrac{1}{1-\cfrac{1}{3}}} \\
&= \frac{1}{6} \cdot \frac{3}{2}\\
& = \frac{1}{4}
\end{align}</div><div>Does this number make sense? At first, it may seem like too few of the sequences. But consider that on each roll, we throw out half of the results. That is, every time we roll the die half of the results are excluded.<br />
<p style="margin: 0px;">Now we have the pieces we need and we can find the average number of rolls.</p>
\begin{align}
P(N_6=n \, | \, \text{even rolls}) &=\frac{P(N_6 =n \cap \text{even rolls})}{P(\text{even rolls})} \\
&= \frac{\left ( \cfrac{2}{6} \right)^{n-1} \cdot \cfrac{1}{6}}{\cfrac{1}{4}} \\
P(N_6=n \, | \, \text{even rolls}) &=\left(\frac{1}{3} \right )^{n-1} \cdot \frac{2}{3} \label{eq:myd_2} \qquad (2)\end{align}</div><div><p style="margin: 0px;">Leveraging our previous work with Memoir '44, this has the same form as asking how long it takes to get the first result, when the result occurs with probability $p=2/3$. Thus,</p>
\begin{align}
\mathbb{E} \left [ N_6 \, | \, \text{even rolls} \right ] &= \frac{1}{2/3}\\
&=1.5
\end{align}</div><div>Note that here we found that </div><div> \begin{align}
P(N_6=n \, | \, \text{even rolls}) &= \left(\frac{1}{3} \right )^{n-1} \cdot \frac{2}{3} \end{align}
<p style="margin: 0px;">which contradicts our earlier hand-wavy equation. Which one is right? Well, I generally trust more rigorous derivations, so I'm inclined towards the later. Interestingly, they both give the correct average. Let's go back to our simulation and look at not just the average, but also the distribution of lengths given all even rolls. By adding a calculation of the percentage of sequences of each length to the above simulation, we get the results in Table 4. </p><p style="margin: 0px;"><br /></p><div style="text-align: center;">\begin{align*}
\begin{array}{cccc}
\text{Sequence length} & \text{Equation (1)} & \text{Equation (2)} & \text{Estimated probability} \\ \hline
1 & 0.1667 & 0.6667 & 0.6665 \\
2 & 0.1111 & 0.2222 & 0.2226 \\
3 & 0.0741 & 0.0741 & 0.0740 \\
4 & 0.0494 & 0.0247 & 0.0241 \\
5 & 0.0329 & 0.0082 & 0.0084 \\
6 & 0.0219 & 0.0027 & 0.0029 \\
7 & 0.0146 & 0.0009 & 0.0009 \\
8 & 0.0098 & 0.0003 & 0.0004 \\
9 & 0.0065 & 0.0001 & 0.0001
\end{array}
\end{align*}
Table 4: Simulated and theoretical sequence length conditional probabilities</div><p style="margin: 0px;"><br /></p><p style="margin: 0px;">As we can see, this lines up well with our second, revised, equation (2). Interestingly, equation (1) looks like it should have a higher expected number of rolls, as the probability of having sequences of length 1 and 2 is lower than simulated while the probability of sequences longer than 3 is higher. An observation that is useful to recall at this point is that equation (1) gave us that $P(N_6=n \, | \, \text{even rolls})$ is half of $P(N_3=n)$. However, further reflection indicates that that doesn't make sense as the sum of the probability over the whole sample space must be 1. The probability that there is some outcome is 1.</p>
\begin{align}
\sum_n P(N=n) = 1
\end{align}
<p style="margin: 0px;">If this is true of some function $f(n)$ such that $P(N=n)=f(n)$ it cannot be true of some other function $g(n) = f(n)/2$. That is, we should find that our incorrect equation gives the sum to be 0.5.</p>
\begin{align}
\sum_{n=1}^\infty \left ( \frac{2}{3} \right) ^{n-1} \cdot \frac{1}{6} & = \frac{1}{6} \cdot\underbrace{\sum_{n=0}^\infty \left ( \frac{2}{3} \right) ^n}_{\cfrac{1}{1-\cfrac{2}{3}}}\\
&= \frac{1}{6} \cdot 3 \\
& = \frac{1}{2}
\end{align}
<p style="margin: 0px;">
</p><p style="margin: 0px;">Indeed, that is the case. This is confirmation that equation (1) is incorrect.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Again, note that there is no sequence that would be included or excluded differently if we were to emphasis that we conditioned on rolling all even numbers before the 6. The two descriptions are logically equivalent and have the same expected number of rolls.</p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-64094508284062334292022-04-04T15:00:00.002-07:002022-04-06T13:51:00.011-07:00How often does each number come up in Space Base?<p> In <a href="https://boardgamegeek.com/boardgame/242302/space-base">Space Base</a>, every turn the active player rolls two six-sided dice. Each player then chooses to treat these as separate numbers or first sum them together and get the corresponding rewards or reward, respectively. Thus, in some sense, the question is not answerable, because it depends on each player's choice. The <a href="https://www.alderac.com/wp-content/uploads/2020/09/Space-Base-rules.pdf">rulebook </a>does a decent job on laying this out and speaking somewhat about the probabilities.</p>
<p style="margin: 0px;"><a href="https://www.quantifyingstrategy.com/2020/04/whats-up-with-dots-on-number-discs-in.html">We previously found the probability of rolling each result on 2d6 for Catan</a>, so we won't revisit that. Is there a good way to layer on top of that the idea that we can take either the sum of the dice or the results individually? The rulebook makes one choice. A quick glance at the table there may be misleading, as it shows the distribution of a regular 2d6 roll with die faces, but then show the numbers for a combination of sum and individual results.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">If we want to get a single probability for how often each number comes up, we have to make a choice of how to handle the case where we roll doubles. Should we count that as two occurrences of the single die value or just one? It depends on what we care about. If we're trying to figure out the average return then I think it makes sense to choose, as the rulebook did, to count that as two results. You can see that in the number of times that they list a 1 showing up: 12 out of the 36 possible results of rolling two 6-sided dice, as shown in Table 1. Note that one of these times is when both dice are rolled together. Thus, there are only 11 rolls that produce these 12 ones. While the double roll makes up for there being only 11 outcomes that include a 1 being rolled in the average reward over many rolls, there may be cases where we are more interested in how many rolls include a given number and don't benefit from rolling doubles. In Space Base there are some cards that gain a charge cube when rolled, but can only hold one charge cube. Thus, rolling doubles of that number can be worse overall, as we don't have access to rewards from a second number.</p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{c|cccccc}
& 1 & 2 & 3 & 4 & 5 & 6 \\ \hline
1& {1},{1} & {1},2 & {1},3 & {1},4 & {1},5 & {1},6\\
2& 2,{1} & 2,2 & 2,3 & 2,4 & 2,5 & 2,6\\
3& 3,{1} & 3,2 & 3,3 & 3,4 & 3,5 & 3,6\\
4& 4,{1} & 4,2 & 4,3 & 4,4 & 4,5 & 4,6\\
5& 5,{1} & 5,2 & 5,3 & 5,4 & 5,5 & 5,6\\
6& 6,{1} & 6,2 & 6,3 & 6,4 & 6,5 & 6,6\\
\end{array}
\end{align*}
<p style="margin: 0px; text-align: center;">Table 1: Rolling ones on two 6-sided dice</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We also need to choose how to handle the option to take the sum of the dice or the individual values. The rulebook includes both at full weight. That is, out of the 36 possible results of rolling two dice, it includes all the times that a 6 is rolled on individual dice as well as all the times that the sum of the two dice is 6. If this were the only number for which we received rewards, or if it were significantly better than our other rewards, then this makes sense, as we'd always choose 6 when it's an option. However, in many cases it could be that getting both a 2 and a 4, for example, is better than just getting the sum of 6. That may be an obvious choice or a difficult one. A way to handle this is to say that we don't know which way players are going to choose (though this may vary with strategy) and treat it as a random event with each option having equal probability. We can think of this as reducing the number of times each number comes up by a factor of 2. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Fortunately, we are spared some complexity by the fact that the sum and individual numbers are always different, since each die has a minimum value of 1. Otherwise, we'd have to consider what to do when the sum matches a single die. Actually, I think we'd always choose the single values, unless it was to use an ability to adjust the number that depends on using the sum. However, we'd still have to account for it in the math to avoid double counting.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There's also a choice of how to combine these two factors. I see two natural pairings. First, if looking at the average amount of return, I think it makes sense to assume that the sum and individual values are each used half the time. This gives something like a weighted probability that you get the rewards from a given number. (I say weighted, because it may sometimes involve double rewards, as discussed above.) Second, if looking at how often something is available, it makes sense to count double rolls as single, but include both individual values and the sum at full weight. This is essentially answering how many turns a given number is an option.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Those both give the middling option for the probabilities. Interestingly, the rulebook went with neither and instead prints the more optimistic combination of counting a double value as two result and including both individual numbers and sums. This does make sense if you're looking at the average reward of a number that is strictly better than everything else, but it ignores the counterfactual or opportunity cost of not choosing the other option. That is, if you're choosing between the sum 5 and the individual numbers 2 and 3, if you're looking at 5, the benefit of what's there has to be compared to the alternative of the rewards for both 2 and 3. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">I suppose I should say something about the last of the four options: what does pairing no doubles with random sum or individual? It seems appropriate to use when you only get benefit from a single reward per turn, but it's a tossup as to whether the number would be chosen given the other choices.</p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{c|cccc}
\text{Method} & 1 & 2 & 3 & 4 \\ \hline
P(\text{sum}) = P(\text{individual}) & 0.5 & 0.5 & 1 & 1 \\
\text{# single} & 11 & 12 & 11 & 12 \\ \hline
1 & \frac{5.5}{36} & \frac{6}{36} & \frac{11}{36} & \frac{12}{36}\\
2 & \frac{6}{36} & \frac{6.5}{36} & \frac{12}{36} & \frac{13}{36}\\
3 & \frac{6.5}{36} & \frac{7}{36} & \frac{13}{36} & \frac{14}{36}\\
4 & \frac{7}{36} & \frac{7.5}{36} & \frac{14}{36} & \frac{15}{36}\\
5 & \frac{7.5}{36} & \frac{8}{36} & \frac{15}{36} & \frac{16}{36}\\
6 & \frac{8}{36} & \frac{8.5}{36} & \frac{16}{36} & \frac{17}{36}\\
7 & \frac{3}{36} & \frac{3}{36} & \frac{6}{36} & \frac{6}{36}\\
8 & \frac{2.5}{36} & \frac{2.5}{36} & \frac{5}{36} & \frac{5}{36}\\
9 & \frac{2}{36} & \frac{2}{36} & \frac{4}{36} & \frac{4}{36}\\
10 & \frac{1.5}{36} & \frac{1.5}{36} & \frac{3}{36} & \frac{3}{36}\\
11 & \frac{1}{36} & \frac{1}{36} & \frac{2}{36} & \frac{2}{36}\\
12 & \frac{0.5}{36} & \frac{0.5}{36} & \frac{1}{36} & \frac{1}{36}\\
\end{array}
\end{align*}
<p style="margin: 0px; text-align: center;">Table 2: Probability of reward in Space Base</p>
<p style="margin: 0px;"><br /></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-60831735948398777872022-04-01T05:00:00.001-07:002022-04-01T05:00:00.209-07:00How many unique starting spice counts are there in Century: Spice Road?<p>Suppose you want all players to start with a unique setup in terms of the number of each of the four spices, with a total number of spices equal to 0 to the maximum 10 in a caravan. How many players could you have?</p>
<p style="margin: 0px;">A first guess would be that each of the 10 caravan positions can have one of five possible values (one of the four spices or no spice). Thus, we might think that there are $5^{10}=9765625$ setups. However, as we don't distinguish, for example, one yellow (turmeric) and one red (saffron) from one red and one yellow, this dramatically over counts the number of unique setups.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">One approach to dealing with this type of problem is to always order the spices in a certain way. Imagine the 10 caravan spaces laid out in a line, starting with brown (cinnamon), then green (cardamom), red (saffron), yellow (turmeric), and finally no spice. We can express each unique setup in terms of the number of each spice. Equivalently, we may note the transition points. For example, instead of focusing on 3 brown cubes, 2 green cubes, 1 red cube, 3 yellow cubes, and 1 blank space, we can look at the transitions after positions 3, 5, 6, and 9. In terms of numbers, this hasn't helped us much, though we have reduced down from five parameters to four (we could have done this other ways, since we know there are 10 total spots for cubes, so the initial numbers must sum to 10). However, if we look at the nine possible transition points between the ten caravan locations, we can see that each unique setup is a unique selection of four of those nine possible transition points. Selecting a subset from a larger set is a problem we know how to solve with our handy combination or binomial coefficient, </p>
\begin{align}
\binom{n}{k} = \frac{n!}{k! \cdot (n-k)!},
\end{align}<div>said as "n choose k".<br />
<p style="margin: 0px;">However, that's not quite right. Let's consider what happens when we have none of one type of the spices. That means that two of our transition points overlap, which isn't accounted for when always choosing four transition points. We could handle this by adding up different scenarios, but that's ugly and boring. So while it could give us the answer, let's find something more elegant. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We're trying to count the number of ways to take 10 of something and allocate it into 5 buckets, where each bucket can hold 0 through 10. We can add one into each of the buckets and not change the situation. Since there are five buckets, that means adding five to the number of possible transition points. That is, the number of ways to take 15 of something and allocate it into 5 buckets where each bucket can hold 1 through 11 is the same. Thus, we can take $n+5-1$ choose $4$,</p><p style="margin: 0px;">\begin{align}
\binom{10+5-1}{4} = \binom{14}{4} = \frac{14!}{4! \cdot 10!} = 1001.
\end{align}</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">As a check for this method, we can look at a simpler case, where it's easier to count or come up with the number in another way. Suppose there are only 2 spots on the caravan. Our formula above says there should be $\binom{2+5-1}{4} = \binom{5}{4} = 15$ setups. With only 2 caravan spots, there are only two types of pattern: two of one spice (including no spice) and one each of two different spices. For the two of one there are 5 ways to do this, and for the one of each, there are $\binom{5}{2} = 10$ ways of doing it. Summing these two ways we get 15. This isn't a perfect check, and it's probably more useful to use to think about the problem and how it works.</p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-63829364302943312882021-10-25T15:00:00.003-07:002021-10-25T15:00:00.235-07:00Should everyone always lose semi-coop games?<p>Unfortunately, in order to answer this question, we have to do a bit of taxonomy first, as "semi-coop", short for semi-cooperative, means different things to different people.</p>
<p style="margin: 0px;">Some people call hidden team games like Battlestar Galactica and/or cooperative games with a possible traitor like Shadows over Camelot semi-coops. I can see the motivation for this as they look like a "cooperative, but ..." game, yet it doesn't seem necessary to differentiate these from other team games like Space Cadets: Dice Duel, Codenames, and The Resistance.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Instead, we are talking about games like CO<sub>2</sub>, Legendary, and Dead of Winter. The through-line seems to be that these are games where players do not always win together (like a cooperative game), but they may all lose together. However, that definition includes games like Galaxy Trucker, which I don't think anyone would consider a semi-coop. A more precise definition would be that there is a condition that if not met means that none of the non-traitor players are eligible to win and instead lose. I specify non-traitor because many, but not all, of these games feature a traitor, who is essentially on a team with the game trying to make the rest of the players lose.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Within this definition I see three types of semi-coop, which have important distinctions that we'll get to.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">In type I semi-coops, or single-winner semi-coops, either all players lose or one player wins while all other players lose. Examples include CO<sub>2</sub> (in "mostly competitive" mode), Robin Hood and the Merry Men, Castaways, and Divided Republic. Examples that include a possible traitor are AuZtralia, Homeland, and Republic of Rome (which has an opt-in traitor).</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">In type II semi-coops, or group-win semi-coops, there are two types of winning. Either all players lose or all players win, but if all players win there is also an individual winner. Examples include Legendary, Castle Panic (although it only uses the word "win" for the group win), Arkham Horror (group win plus "honorary title of First Citizen of Arkham"), Horizon Zero Dawn (although the terminology is confusing "Although all players have won..., the player with the most victory points...emerges as the winner of the game"), and Tomorrow (mentions "win" for both, but in separate sections of the rulebook). Archipelago is an example with a possible traitor.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Type III semi-coops, or separate-goal semi-coops, have separate win conditions for each player in addition to the group loss. An example is Forgotten Waters. Examples with a possible traitor include Dead of Winter, Nemesis, and New Angeles. Dead of Winter labels itself as a "meta-cooperative" game, but the term doesn't seem to have caught on, though it may be useful to describe type III semi-coops.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Games that don't fit this definition but some may call semi-coops include Cutthroat Caverns, Crisis, Bag of Dungeon (using an optional advanced rule), Hellapagos (whoever gets rescued wins, which can be any subset of players), Fog of Love (each player's performance is determined individually), Pax Emancipation (which has a first phase after which the game may end with any number of players may win except all, as well as a possible second phase which is purely competitive) and Core Space (which has the odd combination of a group win if an objective is completed and an individual win if it is not). While these games do feature the possibility of everyone losing, this is usually still determined on a per-player basis.</p>
<p style="margin: 0px;"><br /></p><h2 style="margin: 0px; text-align: left;">Type I: single-winner semi-coops</h2><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's look at a simplified model of a three player type I semi-coop game. Each player has two moves and chooses simultaneously: cooperate (C) or defect (D). If at least two players cooperate, this prevents the all lose scenario. If one player defects, that player is the winner. If all players cooperate, then the winner is randomly select from them. This is depicted in Table 1, where each row represents an outcome based on the first player's move (P1), while each column represents the combined moves of the second and third players (P2 & P3).</p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{c |c|c|c}
\text{P1 \\P2 & P3} & 2 D & 1D, 1C & 2C \\ \hline
D & \text{All lose} & \text{All lose} & \text{P1 wins} \\
C & \text{All lose} & \text{P2 or P3 wins} & \text{P1 may win}
\end{array}
\end{align*} <div><div style="text-align: center;">Table 1: A simple type I semi-coop game</div><p style="margin: 0px; text-align: center;"><br /></p>
<p style="margin: 0px;">Type I semi-coops have the issue that the best move is to defect, as defecting is a weakly dominant strategy, meaning that defecting is sometimes better but never worse than cooperating. This is perhaps more clear in Table 2, which is focused on the first player. Additionally, if players put any positive value to have fellow players also lose (that is, any preference for all lose to someone else wins), then defecting is even more incentivized, but remains a weakly dominant strategy. </p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{c |c|c|c}
\text{P1 \P2 & P3} & 2 D & 1D, 1C & 2C \\ \hline
D & \text{Lose} & \text{Lose} & \text{Win} \\
C & \text{Lose} & \text{Lose} & \text{May win}
\end{array}
\end{align*}
<p style="margin: 0px; text-align: center;">Table 2: First player's outcomes simple type I semi-coop game</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Note that this model only holds if two players cannot easily spoil the victory of another. Additionally, it assumes individual victory and avoiding group loss are at odds with each other. This trade-off is not inherent. For example, suppose you have a game where players earn points throughout the game and all players lose if the sum of the points of all players is not sufficiently high. Now, consider two metrics for individual victory. In the first, the player with the fewest number of points is the individual winner. Here, as long as you lack the ability to manipulate other player's points, the lessons we learned above hold and we wouldn't expect there to be a winner (depending on the total point threashold), as all players tries to minimize their own scores. However, in the second metric, the player with the most number of points is the individual winner. Here, actions that avoid a group loss and obtain individual victory are likely perfectly aligned (there are likely some exceptions due to interactions with other players). Since players are trying to maximize their own scores to be the individual winner, the group loss condition is easily avoided. Of course, in such a situation, you may ask why a group loss condition is included in the game. (While I doubt such a game exists, you could include the rule to avoid dominant strategies that end the game very quickly and are not satisfying in some way. There may be better solutions than making the game semi-cooperative.) The defect or cooperate paradigm does not match with this second metric for an individual win.</p>
<p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">Type II: group-win semi-coops</h2>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's move onto the more interesting type II semi-coop. Table 3 shows another model of a simple simultaneous-play semi-coop game. This time we've adjusted the values both to represent a type II semi-coop, but also to look at the payoffs for the first player, so that we can make use of a game theory analysis. We will assume that all lose is valued at 0, while group win or all win ($AW$) and individual win ($IW$) each have some positive unknown value (but common to all players).</p>
<p style="margin: 0px;"><br /></p>
\begin{align*} <br />\begin{array}{c |c|c|c} <br />\text{P1 \P2 & P3} & 2 D & 1D, 1C & 2C \\ \hline <br />D & 0 & 0 & AW+IW \\ <br />C & 0 & AW &AW+\frac{1}{3}IW <br />\end{array} <br />\end{align*} <br /><div style="text-align: center;">Table 3: A simple type II semi-coop game</div><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">First, let's acknowledge some fragility to this system. Akin to how competitive games can break down if any of the players are not trying to win (it seems relevant to quote Reiner Knizia: <a href="https://twitter.com/reinerknizia/status/132697097714675713">"Remember: When playing a game, the goal is to win, but it is the goal that is important, not the winning..."</a>), semi-cooperative games can break down if players do not accept the payoffs given by the game. While competitive games have their payoffs generally accepted and understood by most people, semi-cooperative games are more rare, especially type II semi-coops, which have multiple types of winning. Some players may ignore one or the other type of winning. If $IW$ is valued at 0, then the game is essentially cooperative, and all players will cooperate as it is a weakly dominant strategy. If $AW$ is valued at 0, then the game reverts to a type I. Some people also reject the idea that a group win is better than a group loss in a type II semi-coop (the interpretation is that in the case of a group loss, all players do as well as each other and so the game ends in a draw, which is preferable to a group win where you are losing to another player; the latter is interpreted as a simple loss), essentially valuing $AW<0$. In that case, as in type I, defecting is a weakly dominant strategy (it's better if exactly one other player cooperates, but doesn't matter if both others either cooperate or defect together). Under such a valuing of the outcomes the game breaks down as it does in a Type I semi-coop. Conversely, players of a Type I semi-coop may value avoiding the all-lose condition such that they effectively add a group win, turning it into a type II semi-coop. We will proceed assuming all players accept the value of both types of winning, while also acknowledging there is some ambiguity in that these games do not specify how much to care about the two types of winning relative to each other.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">In this type II semi-coop there is no obviously best move. If both other players defect, it doesn't matter what the first player does. If one other player defects but one cooperates, then cooperation is preferred as this ensures that all win (including player one). On the other hand, if both other players cooperate, then defection is preferred, as that move guarantees obtaining the individual win.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">This type II semi-coop has several <a href="https://en.wikipedia.org/wiki/Nash_equilibrium">Nash Equilibria</a>. The first three pure-strategy Nash Equilibria are the cases where one player defects while the other two cooperate. There are three, because there's one for each player being the defector. This is a Nash Equilibrium because no player can do better by changing strategy. Suppose the first player is defecting while the other two are cooperating. This puts us in the third column. The first player is better off with a definite individual win than a one-third chance of an individual win. In both cases, the group win condition is guaranteed. The second and third players each face the choice between a group win and a group loss. Neither can unilaterally do anything to do better given the strategies of the other players. A lesson that we can take from this model is that if you can be the first to convince other players that you either have or will defect, you will likely be the individual winner. As such, these games may have a strong first-player advantage, depending on how quickly a player can establish defection.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Another pure strategy Nash Equilibrium is if all players defect. With all players defecting, the all lose outcome occurs, but no single player is in a position to change it. Here it is evident that the Nash Equilibrium is really about stability not about a how good a set of strategies is. Note that in this situation, though, any player may deviate from a defection strategy without detriment.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There is also a mixed-strategy (a mixed-strategy employs one of a number of pure strategies with a given set of corresponding probabilities) Nash Equilibrium of cooperate and defect. The mix depends on the relative valuing of the different outcomes. To find this Nash Equilibrium, we'll make use of the fact that we know that each component strategy must be a best response and have the same average payout. So the payout of defect and cooperate must be the same. Assume in the equilibrium that each player cooperates with probability $p$, and thus defects with probability $1-p$. The probability that both players 2 and 3 cooperate is $p^2$. The probability that they do one of each is $2 \cdot p \cdot (1 - p)$. Recall that the 2 comes from the fact that either player could be the one that cooperates, so there are two ways that it happens. The payoff for player one are thus as follows.</p>
\begin{align} <br />u(D) &= p^2 \cdot \left ( AW + IW \right ) \\ <br />u(C) &= 2 p(1-p) \cdot AW + p^2 \cdot \left ( AW +\frac{1}{3} IW \right ) <br />\end{align} <br /><br />So let's set these equal to find $p$. <br />\begin{align} <br />u(D) &= u(C) \\ <br />p^2 \cdot \left ( AW + IW \right ) &= 2 p(1-p) \cdot AW + p^2 \cdot \left ( AW +\frac{1}{3} IW \right ) \\ <br />p^2 \cdot \left (\frac{2}{3} IW \right ) &= 2 p(1-p) \cdot AW \\ <br />p\cdot \frac{2}{3} IW &= 2 (1-p) \cdot AW \\ <br />p\cdot \left (\frac{2}{3} IW + 2AW \right ) &= 2\cdot AW \\ <br />p &= \frac{2 AW}{\frac{2}{3} IW + 2AW} <br />\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can see our earlier conclusions about the simplified cases fall out from this. If $AW=0$, then $p=0$, as we're in the type I semi-coop case. If $IW=0$, then the game is cooperative and $p=1$. For positive values of both AW and IW, though, we find $0 < p < 1$. Note that this works even if having everyone win is valued significantly above having the individual win, as an individual win requires a group win. We can rewrite this based on the ratio of the two values, $r = AW / IW$.</p>
<p style="margin: 0px;"><br /></p>
\begin{align} <br />p &= \frac{2 AW}{\frac{2}{3} IW + 2AW} \\ <br />p &= \frac{2 \frac{AW}{IW}}{\frac{2}{3} + 2\frac{AW}{IW}} \\ <br />\require{cancel}p &= \frac{\cancel{2}\cdot 3 \frac{AW}{IW}}{\cancel{2} + \cancel{2}\cdot3\cdot\frac{AW}{IW}} \\ <br />p& = \frac{3r}{1 + 3r} <br />\end{align}
<p style="margin: 0px;">This is a monotonically increasing function, as shown in Figure 1, so the more we care about the group win compared to the individual win, the more we cooperate (this is expected and perhaps obvious). </p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghW-_BoJNreWCV_-mTHIe9lRG4C0Y8Ry4a3iWuYBmjk-8V6aVL43QvJRVYPRwekLlyhzLbs2qAGnUZbX7qHAO9_9ZkI3GqrftsOs1mTx-VyifhsNO7nwXR7M1E-P9pVBlAav_Si4XEZUOD/s800/semi_coop_equal_standing.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghW-_BoJNreWCV_-mTHIe9lRG4C0Y8Ry4a3iWuYBmjk-8V6aVL43QvJRVYPRwekLlyhzLbs2qAGnUZbX7qHAO9_9ZkI3GqrftsOs1mTx-VyifhsNO7nwXR7M1E-P9pVBlAav_Si4XEZUOD/w400-h275/semi_coop_equal_standing.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Probability of Cooperation in a Type II Semi-cooperative Game with Equal Player Standing</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Suppose we value them equally, such that achieving individual victory has twice the total utility as being part of a group win. This means that we'll cooperate with probability $p=3/4$ or 75% of the time. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Operating under this strategy, we can find the probability that the group wins. This occurs when at most one player defects. The probability that all players cooperate is $p^3$. The probability that one player defects is $3\cdot p^2 \cdot (1-p)$. For $p=3/4$, this means the probability of a group win is,</p>
\begin{align} <br />P(AW) &= p^3 + 3 \cdot p^2 \cdot (1-p) \\ <br />&= 3p^2 - 2p^3 \\ <br />&= 3 \cdot \left (\frac{3}{4} \right ) ^2 - 2 \cdot \left ( \frac{3}{4} \right ) ^3\\ <br />&\approx 0.84. <br />\end{align}
<p style="margin: 0px;">This is shown in Figure 2 as a function of the ratio $r$.</p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc1hk-wEqBUJpo5nfulPVHjfC_kpbbi5-dwIIhMCEIp63zUwrt3neneBiyI-5-mFP8SFAw9pnmFdnOADOmOrXLyUBcA8vMqtzL5nr2tuJyMeGhD1q0SuDDcGUjY8b1fP613w5h4hVUJqiP/s800/semi_coop_all_win_equal_standing.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc1hk-wEqBUJpo5nfulPVHjfC_kpbbi5-dwIIhMCEIp63zUwrt3neneBiyI-5-mFP8SFAw9pnmFdnOADOmOrXLyUBcA8vMqtzL5nr2tuJyMeGhD1q0SuDDcGUjY8b1fP613w5h4hVUJqiP/w400-h275/semi_coop_all_win_equal_standing.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Probability of Successful Cooperation in a Type II Semi-cooperative Game with Equal Player Standing</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<h2 style="margin: 0px; text-align: left;">Type II with unequal standing</h2>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Now, let's consider a case where the players do not have equal standing. This perhaps models the end of the game. Let's assume players 1, 2, and 3 are in that rank, such that if all cooperate, then player 1 will win. However, if any one player defects (with the other two cooperating) the defecting player wins.</p>
<br />\begin{align*} <br />\begin{array}{c |c|c|c} <br />\text{P1 \ P2 & P3} & 2 D & 1D, 1C & 2C \\ \hline <br />D & 0 & 0 & AW+IW \\ <br />C & 0 & AW &AW+IW \\ <br />\end{array} <br />\end{align*}
<p style="margin: 0px; text-align: center;">Table 4: A simple type II semi-coop game for player 1 while ahead</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Here, for player 1, cooperate is weakly dominant, since the individual win is ensured if all player cooperate. Thus, player 1 likely cooperates.</p>
<br />\begin{align*} <br />\begin{array}{c |c|c|c} <br />\text{P2/3 \ P1 & P3/2} & 2 D & 1D, 1C & 2C \\ \hline <br />D & 0 & 0 & AW+IW \\ <br />C & 0 & AW &AW <br />\end{array} <br />\end{align*}
<p style="margin: 0px; text-align: center;">Table 5: A simple type II semi-coop game for players 2 or 3 while behind</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">However, players 2 and 3 are much more like the earlier analysis. We can check the previous Nash Equilibria to see if they still hold. All defect still is, as well as cases where any one player defects while the other two cooperate. However, player 1 defecting and others cooperating is now a weak Nash Equilibrium, as player 1 is no worse off for cooperating.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Due to the asymmetry introduced, when looking for an updated mixed-strategy Nash Equilibrium, let's say that the first player cooperates with probability $p_1$ and the second and third players each cooperate with probability $p_2$. We can now employ similar techniques as before, however, we'll have more equations as we have a new variable. We'll still assume that $AW$ and $IW$ are valued equally between all players. First, let's look at the payoffs for player 1.</p>
\begin{align} <br />u(D_1) &= p_2^2 \cdot \left ( AW + IW \right ) \\ <br />u(C_1) &= 2 p_2(1-p_2) \cdot AW + p_2^2 \cdot \left ( AW + IW \right ) \\ <br />u(D_1) &= u(C_1) <br />\end{align}
<p style="margin: 0px;">From this point, we just do some algebra.</p>
\begin{align} <br />\require{cancel}\cancel{p_2^2 \cdot \left ( AW + IW \right )} &= 2 p_2(1-p_2) \cdot AW + \cancel{p_2^2 \cdot \left ( AW + IW \right )}\\ <br />0 &= 2 p_2(1-p_2) \cdot AW <br />\end{align}
<p style="margin: 0px;">Here there are two solutions, $p_2=0$ and $p_2=1$. This is somewhat of a contradiction, as we assumed a mixed-strategy for players 2 and 3, yet here we get pure strategies. If we look at the payoffs for player 1, we see the incorrect assumption that we made: that player 1 plays a mixed strategy. Cooperating is always as good as defection for player 1, and sometimes better. If players 2 and 3 are playing mixed strategies, then we should expect that sometimes one will cooperate and one will defect, which means that the only way for player 1 to have a best response 100% of the time is to cooperate.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Knowing this, we can actually simplify the game from, since we know player 1 will cooperate.</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">\begin{align*} <br />\begin{array}{c|c|c} <br />\text{P2/3 \ P3/2} & D & C \\ \hline <br />D & 0 & AW+IW \\ <br />C & AW &AW <br />\end{array} <br />\end{align*}</p>
<p style="margin: 0px; text-align: center;">Table 6: A simple type II semi-coop sub-game for players 2 & 3 if player 1 cooperates</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Again using $p_2$ for the probability of cooperation for only players 2 and 3, we can find the payoffs for each move. We'll repeat the same method of setting the payoffs equal to each other.</p>
\begin{align} <br />u(D) &= u(C)\\ <br />p_2 \cdot \left (AW+IW \right ) &= AW\\ <br />p_2 &= \frac{AW}{AW+IW}\\ <br />p_2 &= \frac{r}{1+r} <br />\end{align}
<p style="margin: 0px;">We find a probability of cooperation which is lower than before (assuming the same values of ratio of the value of the group win AW to the individual win IW). For equal values ($r=1$), $p_2=0.5$, only 50%! This makes sense, as there's less incentive now to cooperate. A graphical comparison is presented in Figure 3.</p>
<p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYAhwOiT0iYcFE5zi4c3gfU_o1rGLIfjuqVDNOnbE5IHUYdaTF9rEaLpKxowFEwHOZkmxnzeBouLnpU2qmR-z0oidcoAi_J8n9GBCTGjxg8tIQhmSSpZnuL79DW2oq3LdhFNtQauLAhzXN/s800/semi_coop_behind_players.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYAhwOiT0iYcFE5zi4c3gfU_o1rGLIfjuqVDNOnbE5IHUYdaTF9rEaLpKxowFEwHOZkmxnzeBouLnpU2qmR-z0oidcoAi_J8n9GBCTGjxg8tIQhmSSpZnuL79DW2oq3LdhFNtQauLAhzXN/w400-h275/semi_coop_behind_players.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: Probability of Cooperation in a Type II Semi-cooperative Game with 2 Players Behind a Leader compared to Equal Standing</td></tr></tbody></table><br /><p style="margin: 0px;">However, did this decrease the probability of a group win?</p>
\begin{align} <br />P(AW) &= p_2^2 + 2\cdot p_2 \cdot (1-p_2) \\ <br />&=2p_2 - p_2^2\\ <br />&=0.75 <br />\end{align}
<p style="margin: 0px;">This did somewhat decrease the probability of a group win, but perhaps not by as much as we might have thought. As shown in Figure 4, there are even some cases where the probability of successful cooperation is higher than with equal standing, although this is only when the group win is valued at a small fraction of the individual win.</p><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBqRfK3b4fY7LDEVwOzjfIWY1gdTpOoF3b5uG6vSv1R32ihI6zlS2NJiF6NEc7JHrNYpVv1H0HLMa9caPaT-GF1W965RAs4eHngvkeNXTZSA4AD5iu__OHDRDSc7QqdixKh2kOns9BRtPE/s800/semi_coop_all_win_behind_players.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBqRfK3b4fY7LDEVwOzjfIWY1gdTpOoF3b5uG6vSv1R32ihI6zlS2NJiF6NEc7JHrNYpVv1H0HLMa9caPaT-GF1W965RAs4eHngvkeNXTZSA4AD5iu__OHDRDSc7QqdixKh2kOns9BRtPE/w400-h275/semi_coop_all_win_behind_players.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 4: Probability of Successful Cooperation in a Type II Semi-cooperative Game with 2 Players Behind a Leader compared to Equal Standing</td></tr></tbody></table><p style="margin: 0px;"><br /></p><h2 style="margin: 0px; text-align: left;">Type III: separate-win semi-coops</h2><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Since type III semi-cooperative games, or meta-cooperative games, do not rank players to determine a winner, there is not the same kind of concept of cooperating vs. defecting as in the analyses we performed thus far. There may still be tension between avoiding the all-lose outcome and achieving personal goals, but this tension is not directly influenced by the situation of other players.</p>
<p style="margin: 0px;"><br /></p><h2 style="margin: 0px; text-align: left;">Conclusion</h2><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">To recap, we saw that in a simple type I semi-coop game, where either all lose or there is one winner, we somewhat expect that all players lose. (Note that while this may be a strategically unsatisfying play experience, it may be interesting art or commentary.) This is the only Nash Equilibrium and defecting is a weakly dominant strategy. If we add a group win, thus converting to a type II semi-coop, we can avoid this, as there are stable states where all players win. However, this is subject to the strategies employed by the players. If a majority of the players demand to get advantage for the individual win by defecting, then all will lose, and all players defecting is also a Nash Equilibrium. Additionally, even in the case where the group win is achieved, this could be because a certain player is defecting while the others cooperate. Such a condition may be unpleasantly static. </p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">So the answer is no, as players in a group-win semi-coop may be able to rationally achieve cooperation.</p>
<p style="margin: 0px;"><br /></p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-47712365512733214072021-05-31T15:00:00.001-07:002021-05-31T15:00:00.231-07:00Errata: What's the toughest unit in Memoir '44?I was preparing to revisit what the toughest unit in Memoir '44 is by looking at it using a Markov chain model. Then I discovered that I had an error in <a href="https://www.quantifyingstrategy.com/2020/05/whats-toughest-unit-in-memoir-44.html">my earlier calculation</a>. I'll fix my calculation and derive the expected number of dice needed to eliminate each type of unit.
Recall that I derived the following equation for the expected number of dice needed to eliminate a given unit, $N$, as follows.
\begin{align}
\mathbb{E} N &= \sum_{n=0}^\infty 1 - F_N(n)
\end{align}
Here $F_N(n)$ is the CDF of $N$, meaning that $F_N(n) = P(N \leq 0)$. See the previous analysis for the derivation of the CDF. The error came in the range of the summation for $\mathbb{E} N$, which starts at zero. However, my code to the computation stored the CDF starting at $n=1$, since it is known to be 0 at $n=0$; it's impossible to eliminate a unit without rolling any dice. This means that I should add one to the previous estimates, as shown below.
\begin{align}
\widehat{\mathbb{E} N_\text{infantry}} & \approx 8.000000000000002 \\
\widehat{\mathbb{E} N_\text{armor}} & \approx 8.999999999999932 \\
\widehat{\mathbb{E} N_\text{artillery}} & \approx 11.999998659711212 \\
\end{align} <div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizaiITTR8f0-dQcYcNFUpJRjMCXrUuJKXt9Atgf1OAD8WDEmf7sLsVoZr8kJeKb3CLdA6iiRXv_YuHUcrMkB2gQPzYT-o8eNyXhhYI7dUd_Je1Dp_AY4eIYbTyFbAKWLYfpCiXgkyVZ6je/s700/memoir_hits_exp.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizaiITTR8f0-dQcYcNFUpJRjMCXrUuJKXt9Atgf1OAD8WDEmf7sLsVoZr8kJeKb3CLdA6iiRXv_YuHUcrMkB2gQPzYT-o8eNyXhhYI7dUd_Je1Dp_AY4eIYbTyFbAKWLYfpCiXgkyVZ6je/w400-h286/memoir_hits_exp.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Estimating expected value with finite sum</td></tr></tbody></table><br /><div>This means that our guess as to the true expected values are below and the updated formula would be $\mathbb{E} N = f/p$.
\begin{align}
\mathbb{E} N_\text{infantry} & = 8 \\
\mathbb{E} N_\text{armor} & = 9 \\
\mathbb{E} N_\text{artillery} & = 12
\end{align}
This makes a lot more sense and perhaps I should have caught the previous error. Without the odd $-1$ hanging off the back end of the equation, this means that the expected value of proportional to the number of starting figures. This makes sense, especially in our one die at a time analysis. If it takes an average of $1/p$ dice to remove one figure, then it should take an average of $f/p$ dice to remove $f$ figures. First, we remove one figure, then the second, and then so on $f$ times. Each time takes an average of $1/p$ dice, so $f/p$ dice in total.
The expectation is also inversely proportional to $p$. While clearly in the correct direction, it'll take a little more analysis to establish this precise relationship. If we increase the probability of hitting with each die, it'll decrease the number of dice we need to roll before getting a hit. Let's analysis the expected number of dice rolled to get the first hit, $N_\text{hit}$, for a unit with a probability of getting hitting one die $p$. To get a hit on the $n$-th die, after missing previously, the probability is,
\begin{align}
P(N_\text{hit} = n) = (1-p)^{n-1} \cdot p.
\end{align}
While we could use this, we can use the same shortcut to find the expected value as before.
\begin{align}
\mathbb{E} N_\text{hit} = \sum_{n=0}^\infty P(N_\text{hit} > n)
\end{align}
The probability that we haven't gotten a hit in $n$ dice, $P(N_\text{hit} > n)$ is the probability that we roll a miss all $n$ times.
\begin{align}
P(N_\text{hit} > n) = (1-p)^n
\end{align}
Thus, the expected value is,
\begin{align}
\mathbb{E} N_\text{hit} = \sum_{n=0}^\infty (1-p)^n .
\end{align}
This is a familiar infinite series, although it might not be immediately recognizable in this form. If we instead substitute $a = 1-p$ and notice that $a < 1$ for $p > 0$, then it becomes more familiar.
\begin{align}
\mathbb{E} N_\text{hit} &= \sum_{n=0}^\infty a^n \\
&= a^0 + a^1 + a^2 + a^3 + \ldots \\
& = \frac{1}{1-a}
\end{align}
This is very similar to <a href="https://www.quantifyingstrategy.com/2021/05/should-i-roll-or-use-two-pawns-in-first.html">the analysis done related to rolling for actions in First Martians</a>.
Finally, we substitute back in that $a = 1-p$.
\begin{align}
\mathbb{E} N_\text{hit} &= \frac{1}{1-a} \\
&= \frac{1}{1 - (1-p)} \\
& = \frac{1}{p}
\end{align}
Combining this result for a single figure with the previous analysis we find that indeed $\mathbb{E} N = f/p$.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-31217608720291125002021-05-24T15:00:00.001-07:002021-05-24T15:00:00.255-07:00Link: Special Hunt Tiles in War of the Ring<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/_l7OF8INbtc" width="320" youtube-src-id="_l7OF8INbtc"></iframe></div><br /><p>I found the above analysis of the special red and blue hunt tiles in War of the Ring by Ira Fay to be interesting. Also see the linked simulator here: <a href="http://irafay.com/wotr_mordor.php">http://irafay.com/wotr_mordor.php</a>.</p><p>For my taste, I'd want to figure out how to do this without relying on a Monte Carlo simulation, but it's probably a lot easier and seems to run pretty fast.</p><p>Note: Ira also has several videos <a href="http://tinyurl.com/WotRChamp">on his channel</a> of him going through games of War of the Ring that he goes through and comments on.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-9190941039546291732021-05-17T15:00:00.002-07:002021-05-17T15:00:00.265-07:00Should I roll or use two pawns in First Martians?
In my <a href="https://boardgamegeek.com/thread/2323877/first-martians-case-study-failed-design">review </a>of First Martians, I included a table showing the expected number of pawns required for each type of action when rolling (see Table 1). Here's I'll go through the math behind that table. <div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5iibx6Tu9Kwtffohq34DhFDjWdUaMtSbr8r6foDUTOyzwVQMAFEyZxG8VtJebalSzsPlkZqXNtWzdyFhK4IxJ1oCNEONWKDi4iG-NHxxjWhPh7Z9V3Ezz_Xiy4eRBPWGabx7qA6A1hyoE/s650/fm_table_from_review.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="204" data-original-width="650" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5iibx6Tu9Kwtffohq34DhFDjWdUaMtSbr8r6foDUTOyzwVQMAFEyZxG8VtJebalSzsPlkZqXNtWzdyFhK4IxJ1oCNEONWKDi4iG-NHxxjWhPh7Z9V3Ezz_Xiy4eRBPWGabx7qA6A1hyoE/w400-h125/fm_table_from_review.png" title="Table 1: Expected pawns when rolling for actions" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Table 1: Expected pawns when rolling for actions</td></tr></tbody></table><div><br /></div><div>First, let me establish the relevant rules and constraints of the analysis. In general, actions may completed by using two pawns on them for an automatic success, or only using one pawn but having to roll three dice that determine a number of possible outcomes. Some actions require additional dice, which I'll discuss briefly later. The first die determines whether the action succeeds or the player gains two morale tokens (which power special abilities), the second die determines whether or not the character receives a wound, and the third die determines whether the character has an adventure, which entails requesting a the app for the game to explain some additional event which generally harms the character in some way or provides some additional obstacle. Since these are three separate dice being rolled they are all independent and any combination of outcomes is possible. Further, the distributions of the types of sides on the three dice depend on the type of action. Each die determines only one of two sets of outcomes, Table 1 shows the probabilities for the three outcomes of interest: success, wound, and adventure. We'll denote these as $p_s$, $p_w$, and $p_a$, respectively. While morale tokens can be useful, I have ignored them here, as they do not necessarily translate into success in a given action.
Next, let's look at how many times we'll have to roll in order to succeed at the action, given by the random variable $N$. A useful way to calculate this for non-negative random variables is the following equation.
\begin{align}
\mathbb{E} N = \sum_{n=0}^\infty P(N > n)
\end{align}
While I won't do a full proof, I'll note that there's some discussion of it <a href="https://en.wikipedia.org/wiki/Expected_value#Alternative_formula_for_expected_value">here</a>. The following illustration will help to see why this is true. We can write $P(N > n)$ in terms of all the relevant $P(N = n)$.
\begin{align}
P(N>n) &= \sum_{i=n+1}^\infty P(N=i) \\
&=P(N=n) + P(N=n+1) + P(N=n+2) + \ldots \\
\mathbb{E} N &= \sum_{n=0}^\infty \sum_{i=n+1}^\infty P(N=i) \\
\end{align}
We can expect and regroup this to see how it's equal to the expected value.
\begin{alignat}{9}
\mathbb{E} N =& P(N = 1) &&+& P(N = 2) &&+& P(N = 3) &&+& P(N = 4) &&+&\ldots \\
& &&+& P(N=2) &&+& P(N = 3) &&+& P(N = 4) &&+&\ldots \\
& &&& &&& P(N = 3) &&+& P(N = 4) &&+&\ldots \\
&\underbrace{\phantom{P(N = 1)}}_{1\cdot P(N=1)} &&& \underbrace{\phantom{P(N = 2)}}_{2\cdot P(N=2)} &&& \underbrace{\phantom{P(N = 3)}}_{3\cdot P(N=3)} &&+& \underbrace{P(N = 4)}_{4\cdot P(N=4)} &&+& \ldots \\
\end{alignat}
This matches the expected value, which is the average, given by the sum of all possible outcomes weighted by the probability that they occur.
\begin{align}
\mathbb{E} N = \sum_{n=1}^\infty n \cdot P(N = n)
\end{align}
Here, the number of rolls must be at least one, so the range of the summation is set accordingly. However, note that this also works for random variables which are non-negative ($N\geq 0$) instead of strictly positive ($N>0$), because the 0 term is always zero ($0 \cdot P(N= 0) = 0$).
Now let's look at the relevant probabilities in this case. Given a probability of success, $p_s$, we can find the probability that the number of rolls, $N$, is more than $n$. It is the probability that the first $n$ rolls fails, which each occur with probability $1-p_s$. These are independent, so we can multiply all the probabilities together.
\begin{align}
P(N > n) &= (1-p_s)^n
\end{align}
Thus, the expected value is,
\begin{align}
\mathbb{E} N = \sum_{n=0}^\infty (1-p_s)^n .
\end{align}
This is a familiar infinite series, although it might not be immediately recognizable in this form. If we instead substitute $a = 1-p_s$ and notice that $a < 1$ for $p_s > 0$, then it becomes more familiar.
\begin{align}
\mathbb{E} N &= \sum_{n=0}^\infty a^n \\
&= a^0 + a^1 + a^2 + a^3 + \ldots \\
& = \frac{1}{1-a}
\end{align}
If you haven't seen this before, first, let's remember that $a^0 = 1$.
\begin{align}
\mathbb{E} N &= 1 + a^1 + a^2 + a^3 + \ldots
\end{align}
Next we can multiple both sides by $a$ and then add 1 to both sides.
\begin{align}
a \cdot \mathbb{E} N &= a^1 + a^2 + a^3 + \ldots \\
1 + a \cdot \mathbb{E} N &= 1 + a^1 + a^2 + a^3 + \ldots \\
\end{align}
At this point we notice that the right hand side is equal to our original infinite series for $\mathbb{E} N$. From there we can employ some algebra to find the expected value in question.
\begin{align}
1 + a \cdot \mathbb{E} N &= \mathbb{E} N \\
1 &= \mathbb{E} N \cdot (1 - a) \\
\frac{1}{1-a} &= \mathbb{E} N
\end{align}
Finally, we substitute back in that $a = 1-p_s$.
\begin{align}
\mathbb{E} N &= \frac{1}{1-a} \\
&= \frac{1}{1 - (1-p_s)} \\
& = \frac{1}{p_s}
\end{align}
This means that expect to roll 1.2 times and 1.5 times for $p_s = 5/6$ and $p_s = 4/6$, respectively. If this were the only die in consideration, perhaps this would make a good game. In general it would be more efficient to roll, but sometimes it be important to guarantee success now. However, there are two other dice in the picture, related to wounds and adventures.
To deal with a wound costs 1 pawn in 1--3 player games and 2 pawns in 4 player games; I'll use the lower 1 pawn cost, even though sometimes a wound can trigger a condition token which usually costs a pawn to remove. Based on my experience with the game (20+ plays), I estimate the cost of dealing with an adventure to average out to about 1 pawn also, though this in more variable. In both cases, you may or may not have to pay these costs. If the game is close to the end, or it affects an abundance resource, you may not have to. However, wounds usually need to be healed to avoid potential death. Any cost here is borne in subsequent rounds, which can make a difference, but is not quantified here. Wounds occur with probability, $p_w$, of $3/6=1/2$ or $2/6 = 1/3$, while adventures occur with probability, $p_a$, of $3/6=1/2$ for all action types. Since the cost is 1 pawn, the additional pawns expected for each roll is $1\cdot p_w + 1\cdot p_a = p_w + p_a$. Note that this is per roll, not overall.
To get the overall expected number of pawns when rolling, we have to look at expectation of the number of rolls times the number of pawns used for that roll (including resolving wound and adventure consequences). The number of pawns when rolling (still assuming a base cost of 1 pawn to declare the action), is $1+C$, where $C$ is a random variable of the cost in pawns of wounds and adventures determined by the roll. For the $n$-th roll, we can label the corresponding cost $C_n$. The total pawn cost, $T$, is $1+C_n$ for the $n$-th roll and summed over all $N$ rolls.
\begin{align}
T &= \sum_{n=1}^N 1 + C_n \\
& = N + \sum_{n=1}^N C_n
\end{align}
The average cost is given by the expected value.
\begin{align}
\mathbb{E} T &= \mathbb{E} \left (N + \sum_{n=1}^N C_n \right )\\
&= \mathbb{E} N + \mathbb{E}\sum_{n=1}^N C_n \\
&= \frac{1}{p_s} + \mathbb{E}\sum_{n=1}^N C_n \\
\end{align}
To simplify the expectation above, we can recognize that the all $C_n$ are independent and identically distributed, so we can turn the summation into multiplication.
\begin{align}
\mathbb{E}\sum_{n=1}^N C_n &= \mathbb{E}\left ( \underbrace{C + C + \ldots + C}_{N \text{terms}} \right ) \\
&= \mathbb{E} \left (N \cdot C \right )
\end{align}
Because $N$ is set by the rolls of the one of the dice and $C$ is set by a roll of the other two dice, they are independent. That means we can distribute the expectation across the two random variables.
\begin{align}
\mathbb{E} \left (N \cdot C \right ) &= \mathbb{E} N \cdot \mathbb{E} C
\end{align}
We already computed the expected pawn cost due to wounds and adventures.
\begin{align}
\mathbb{E} C &= p_w + p_a
\end{align}
Putting this all together, we find the average total cost as the expected value of $T$.
\begin{align}
\mathbb{E} T &= \mathbb{E} N + \mathbb{E} N \cdot \mathbb{E} C \\
&=\mathbb{E} N \cdot \left ( 1 + \mathbb{E} C \right )\\
\mathbb{E} T &= \frac{1}{p_s} \cdot \left ( 1 + p_w + p_a \right)
\end{align}
When the is computed for each of the action types, we get the expected pawns listed in Table 1. Note that in all cases this value is greater than the 2 pawns required to guarantee success. This means that on average, you are better off using 2 pawns to guarantee success rather than using 1 initial pawn and rolling.
For actions that have a higher base cost, requiring additional pawns, this effect continues, and is even more pronounced. This is because the additional pawns are required in every roll, the number of which still averages to $1/p_s$. Thus, for $k$ pawns required to roll, the average total cost, $T_k$ is,
\begin{align}
\mathbb{E} T_k &= \frac{k + p_w + p_a}{p_s}
\end{align}
Ignoring the cost of wounds and adventures, just the pawns spent to attempt the action average to $k/p_s$, which should be compared to $k+1$. For $k=2$, $k/p_s$ is 2.4 and 3.0 for $p_s$ of $5/6$ and $4/6$, respectively. The total costs are $\mathbb{E} T_2$ are shown in Table 2. </div><div><br /></div><div>\begin{align*}
\begin{array}{c|c|c|c|c}
\text{Action} & p_s & p_w & p_a & \mathbb{E} T_2 \\ \hline
\text{Explore} & 5/6 & 3/6 & 3/6 & 3.6 \\
\text{Gather} & 5/6 & 2/6 & 3/6 & 3.4 \\
\text{Research} & 4/6 & 2/6 & 3/6 & 4.25 \\
\text{Build} & 4/6 & 2/6 & 3/6 & 4.25 \\
\end{array}
\end{align*} </div><div style="text-align: center;">Table 2:Expected pawns with one additional pawn to roll</div><div><br /></div><div> In fact, for any base cost $k$, the expected number of pawns when rolling is larger than the number of pawns required to guarantee success. We can see this by showing that $\mathbb{E} T_k > k+1$. For all actions types $p_s < 1$, which means that $k/p_s > k$. Furthermore, $(p_w+p_a) / p_s \geq 1$ for all action types.
\begin{align}
\mathbb{E} T_k &= \frac{k + p_w + p_a}{p_s} \\
\mathbb{E} T_k &\geq \frac{k}{p_s} + 1 \\
\mathbb{E} T_k &> k + 1
\end{align}
Thus, the expected number of pawns when rolling is higher than the number of pawns needed to guarantee success.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-38739136140298903252021-04-01T15:00:00.001-07:002021-04-01T15:00:00.791-07:00Are there really 504 games in 504?<p><span style="white-space: pre-wrap;">The game 504 is actually many games. You assemble each one by selecting one of nine modules for the top, middle, and bottom of the rules, which flip around separately to accommodate the selection.</span></p><p style="margin: 0px; white-space: pre-wrap;">You may think that there should be $9^3=729$ games, because for each of the three sections of the rules you have nine options. However, you cannot pick the same module for more than one section.</p><p style="margin: 0px; white-space: pre-wrap;"><br /></p><p style="margin: 0px; white-space: pre-wrap;">Considering that, you may adjust to think that there should be ${9 \choose 3} = \frac{9!}{3! \cdot (9-3)!} = 84$ games. You're selecting three modules out of a total of nine, it sounds like a combination problem. However, the order here matters. It matters if module 9 is the top or the bottom of the rules, as they describe different aspects of the game.</p><p style="margin: 0px; white-space: pre-wrap;"><br /></p><p style="margin: 0px; white-space: pre-wrap;">Thus, there are indeed $\frac{9!}{(9-3)!} = 9\cdot 8 \cdot 7 = 504$ games. This is a permutation problem. For the first, you have nine options. The second, you have eight remaining choices, and seven for the third.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-44961742169658815992020-11-30T15:30:00.001-08:002020-11-30T15:30:01.864-08:00Who has an advantage in Risk, attacker or defender?<p>Let's first assume that we're talking about the frequent case where the attacker is rolling 3 dice, while the defender can only roll 2 dice, but ties go to the defender. More dice is better. Winning ties is better. But which of those wins out? Let's see.</p>
<p style="margin: 0px;">One thing that's tricky here is that we compare the highest attacker die to the highest defender die, and the second highest attacker die to the lowest defender die. So we have to consider the joint probability distribution of the two attacker dice and the two defender dice. We can treat the attacker and defender separately, though, since they are independent.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's start by working with the defender, and looking at the CDF of the better roll of 2d6. Recall the CDF $F_X(x) = P(X \leq x)$. Let's say $D_1$ is the the higher die of the defender, with $D_2$ being the lower die. Let's say that X is the result of rolling a 1d6.</p>
\begin{align}
F_{D_1}(d) = P(D_1 \leq d) = P(X \leq d)^2
\end{align}
<p style="margin: 0px;">That is, the probability that the highest die is less than or equal to $d$ is the probability that both dice are less than or equal to $d$.</p>
\begin{align}
F_{D_1}(d) = \left ( \frac{d}{6} \right)^2
\end{align}
<p style="margin: 0px;">What about $F_{D_2}(d)$? Similar to above, we can say that</p>
\begin{align}
F_{D_2}(d) &= P(D_2 \leq d) \\
&= 1 - P(D_2 > d) \\
&= 1 - P(X > d)^2 \\
&= 1 - \left ( \frac{6-(d+1)+1}{6} \right)^2 \\
&= 1 - \left ( \frac{6-d}{6} \right)^2 \\
&= \frac{6^2}{6^2} - \frac{6^2-12d+d^2}{6^2} \\
&= \frac{6^2-6^2+12d-d^2}{6^2} \\
&= \frac{12d-d^2}{6^2} \\
&= \frac{d}{6}\cdot \frac{12-d}{6} .
\end{align}
<p style="margin: 0px;">Those make sense, though we should check that they work out at say $d=1$ and $d=6$. But those are assuming that they're independent. Given that the highest die comes out to be $d_1$, what's the distribution of $D_2$? Or what is $P(D_2 = d_2 | D_1 = d_1)$. Well, it's certainly 0 if $d_2 > d_1$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">This seems to be a hard one.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">It may just be easier to calculate the joint probability directly. </p>
\begin{align}
P(D_1=d_1, D_2=d_2) = \begin{cases}
0 & d_1 < d_2 \\
P(d_1\text{ and }d_2\text{ on 2d6}) & d_1 = d_2 \\
P(d_1\text{ and }d_2\text{ on 2d6}) & d_1 > d_2
\end{cases}
\end{align}
<p style="margin: 0px;">Let's drill down more, in the $d_1=d_2$ case, it's just the probability of getting both of that value when rolling 2d6. </p>
\begin{align}
P(d_1\text{ on 1d6}) &= \frac{1}{6}\\
P(d_1\text{ on both of 2d6}) &= P(d_1\text{ on 1d6})^2 \\
&=\left ( \frac{1}{6} \right ) ^2 \\
&=\frac{1}{36} \\
P(D_1=d_1, D_2=d_2) & = \frac{1}{36}, \quad d_1=d_2
\end{align}
<p style="margin: 0px;">Okay, now the $d_1 > d_2$ case. If we have two different values, there's two ways we could get them. Let's say we have two dice $A$ and $B$. We roll $d_1$ on $A$ and $d_2$ on $B$, or $d_1$ on $B$ and $d_2$ on $A$. The probability of rolling $d_1$ on a particular die is $1/6$, similarly for $d_2$. Thus, the probability of getting $D_1=d_1$ and $D_2=d_2$ is twice the probability of rolling $d_1$ and then $d_2$.</p>
\begin{align}
P(D_1=d_1, D_2=d_2) & = 2\cdot\frac{1}{6}\cdot\frac{1}{6}, \quad d_1>d_2\\
& = 2\cdot\frac{1}{36}, \quad d_1>d_2\\
& = \frac{1}{18}, \quad d_1>d_2
\end{align}
\begin{align}
P(D_1=d_1, D_2=d_2) = \begin{cases}
0 & d_1 < d_2 \\
\frac{1}{36} & d_1 = d_2 \\
\frac{1}{18} & d_1 > d_2
\end{cases}
\end{align}
<p style="margin: 0px;">This makes some sense, and we can see that the probabilities are going to add up to one, though we should probably check more explicitly. You can think of this as rolling two dice in order. Then, if the second one came out larger, we switch the order. Thus, all the probabilities for $d_1 < d_2$ went from $1/36$ to 0, and all the probabilities for $d_1 > d_2$ went from $1/36$ to $2/36=1/18$. I think, ultimately, this last explanation is probably the way to think about it.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">So let's take that kind of thinking and apply it to the attacker. Here we have three dice, but only use two. If we use this algorithmic approach we can conceive of rolling three dice, and then reordering them to be from largest to smallest. With two dice, we reordered, or we didn't. With three dice, there are more cases. Let's assume that we have three distinct results on our rolls. Then there are $3! = 3 \cdot 2 \cdot 1 = 6$ ways to order them. Thus, </p>
\begin{align}
P(A_1=a_1, A_2=a_2, A_3=a_3) &= 3! \cdot \left ( \frac{1}{6} \right ) ^3\\
&= 6 \cdot \frac{1}{6^3}\\
&= \frac{1}{6^2}\\
&= \frac{1}{36}.
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Interestingly, we only care about two of the values. So we want to sum up for all possible $a_3$. However, we've assumed here that $a_1 > a_2 > a_3$. Thus, the number of cases to sum is limited. The number of cases where $a_3 < a_2$ is equal to $a_2 - 1$. </p>
\begin{align}
P(A_1=a_1, A_2=a_2) &= \sum_{a_3 < a_2} P(A_1=a_1, A_2=a_2, A_3=a_3) \\
&= (a_2-1) \cdot \frac{1}{36} \\
&= \frac{a_2-1}{36}
\end{align}
<p style="margin: 0px;">Oops, we left out one above. We left one case out. We were assuming $a_3 < a_2$, but that doesn't show up in the equation as we wrote it. We only really need to assume $a_3 \leq a_2$ (otherwise, it won't occur at all and the probability is zero). Thus, we can fix our equation as follows.</p>
\begin{align}
P(A_1=a_1, A_2=a_2) &= \sum_{a_3 \leq a_2} P(A_1=a_1, A_2=a_2, A_3=a_3) \\
&= a_2 \cdot \frac{1}{36} \\
&= \frac{a_2}{36}
\end{align}
<p style="margin: 0px;">Oops, now I think I've done some double counting. Because if $a_1 > a_2 = a_3$ then there aren't $3!=6$ orderings There are only $(3!)/(2!) = 6/2 = 3$ ways. Thus,</p>
\begin{align}
P(A_1=a_1, A_2=a_2, A_3=a_2) &= 3 \cdot \frac{1}{6^3}\\
&= \frac{1/2}{36}.
\end{align}
<p style="margin: 0px;">So</p>
\begin{align}
P(A_1=a_1, A_2=a_2) &= P(A_1=a_1, A_2=a_2, A_3 < a_2) + P(A_1=a_1, A_2=a_2, A_3=a_2) \\
&= \sum_{a_3 < a_2} P(A_1=a_1, A_2=a_2, A_3=a_3) + P(A_1=a_1, A_2=a_2, A_3=a_2) \\
&= (a_2-1) \cdot \frac{1}{36} + \frac{1/2}{36}\\
&= \frac{a_2-1/2}{36}
\end{align}
<p style="margin: 0px;">We now have more cases to consider. As before, we need to consider the all equal case $a_1=a_2=a_3$, which, similar to before, occurs with probability $1/6^3 = 1/216$. We also have to consider all the cases where two of the dice are equal, but not to the third. We considered the $a_1 > a_2=a_3$ case above. But we also have $a_1=a_2 > a_3$. Again, we only have 3 orderings, so</p>
\begin{align}
P(A_1=a_1, A_2=a_1, A_3 < a_1) &= 3 \cdot \left ( \frac{1}{6} \right ) ^3\\
&= \frac{1/2}{36} .
\end{align}
<p style="margin: 0px;">Note: I'm writing this weird fraction to keep a common denominator of 36. Perhaps we should really be working with a denominator of 72. Again we combine to get the probability independent of $a_3$.</p>
\begin{align}
P(A_1=a_1, A_2=a_1) &= P(A_1=a_1, A_2=a_1, A_3 < a_1) + P(A_1=a_1, A_2=a_1, A_3=a_1) \\
&= \sum_{a_3 < a_1} P(A_1=a_1, A_2=a_1, A_3=a_3) + P(A_1=a_1, A_2=a_1, A_3=a_1) \\
&= (a_1-1) \cdot \frac{1/2}{36} + \frac{1}{216}\\
&= (a_1-1) \cdot \frac{3}{6^3} + \frac{1}{6^3}\\
&= \frac{3\cdot (a_1-1) + 1}{6^3} \\
&= \frac{3 a_1-2}{6^3}
\end{align}
<p style="margin: 0px;">Do these all add up to 1?</p>
\begin{align}
\sum_{a_1} P(A_1=a_1, A_2=a_1) + \sum_{a_1 > a_2} P(A_1 = a_1, A_2 = a_2) &= 1 \\
\sum_{a_1=1}^6 \frac{3 a_1 - 2}{6^3} + \sum_{a_1=2}^6 \sum_{a_2=1}^{a_1-1} \frac{a_2-1/2}{36} &= 1 \\
\sum_{a_1=1}^6 \frac{3 a_1 - 2}{6^3} + \sum_{a_1=2}^6 \sum_{a_2=1}^{a_1-1} \frac{a_2-1/2}{36} &= 1
\end{align}
<p style="margin: 0px;">Recall that,</p>
\begin{align}
\sum_{k=1}^n k = \frac{n(n+1)}{2}.
\end{align}
<p style="margin: 0px;">Thus, continuing on, we have as follows.</p>
\begin{align}
\frac{3 \cdot \frac{6(6+1)}{2} - 2\cdot 6}{6^3} + \sum_{a_1=2}^6 \left (\frac{(a_1-1)a_1}{2}-\frac{1}{2}\cdot (a_1-1)\right) \cdot \frac{1}{36} &= 1 \\
\frac{51}{6^3} + \sum_{a_1=2}^6 \frac{a_1^2-2a_1+1}{2} \cdot \frac{1}{36} &= 1
\end{align}
<p style="margin: 0px;">Now we have the sum of a squared term, which is given by,</p>
\begin{align}
\sum_{k=1}^n k^2 = \frac{n(n+1)(2n+1)}{6}.
\end{align}
\begin{align}
\frac{51}{6^3} + \frac{\left(\frac{6(6+1)(12+1)}{6}-1\right)-2 \cdot \left(\frac{6(6+1)}{2}-1\right) + 5}{2} \cdot \frac{1}{36} &= 1 \\
\frac{51}{6^3} + \frac{\left((6+1)(12+1)-1\right)-2 \cdot \left(3(6+1)-1\right)+5}{2} \cdot \frac{1}{36} &= 1 \\
\frac{51}{6^3} + \frac{(90)-2 \cdot (20)+5}{2} \cdot \frac{1}{36} &= 1 \\
\frac{51}{6^3} + \frac{(90)-(40)+5}{2} \cdot \frac{1}{36} &= 1 \\
\frac{51}{6^3} + \frac{55}{2 \cdot 36} &= 1 \\
\frac{51}{6^3} + \frac{55}{2 \cdot 36} &=1 \\
\frac{3 \cdot 17}{6^3} + \frac{55}{2 \cdot 36} &=1 \\
\frac{17}{2 \cdot 6^2} + \frac{55}{2 \cdot 36} &=1 \\
\frac{17+55}{2 \cdot 6^2} &=1 \\
\frac{72}{72} &=1
\end{align}
<p style="margin: 0px;"><strike>Wow, we've made a big mistake here somewhere!</strike> Yay, I fixed it. </p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Note, that the first time I did this, I made a few mistakes. First, I copied the wrong expression in for one of the terms, then I made some algebra and arithmetic mistakes. That's why it's helpful to do these kinds of checks. It is also possible that I could have made such a mistake deriving the expressions themselves instead of in the check combining them.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's summarize our result for the attacker.</p>
\begin{align}
P(A_1=a_1, A_2=a_2) = \begin{cases}
0 & a_1 < a_2 \\
\frac{3a_1 - 2}{6^3} & a_1 = a_2 \\
\frac{a_2 - 1/2}{36} & a_1 > a_2
\end{cases}
\end{align}
<p style="margin: 0px;">Recall the result for the defender.</p>
\begin{align}
P(D_1=d_1, D_2=d_2) = \begin{cases}
0 & d_1 < d_2 \\
\frac{1}{36} & d_1 = d_2 \\
\frac{1}{18} & d_1 > d_2
\end{cases}
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Also, I could use a computer to help me evaluate the expression to confirm that my mistake was in the evaluation and not in deriving the probabilities. A computer simulation could also be helpful, but less conclusive. I draw the distinction as this. You can use a computer to evaluate or to simulate. When you have a computer evaluate, you're using it as a glorified calculator or a plotting tool. Maybe you use it to solve some transcendental equations. If you use a computer to simulate, then you aren't doing much thinking, you're just setting up the problem, running one or more experiments, and hoping the result tells you something both correct and meaningful. Here, though, we can also brute force all the combinations. This is still using the computer like a calculator, but not bothering to simplify before chugging away.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">With the probability distributions for both the attacker's and the defender's dice rolls, we can do the comparison and see what the outcome of a round of combat is. In this case there are three outcomes,</p>
<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><p style="margin: 0px;">1) attacker loses two units,</p><p style="margin: 0px;">2) defender loses two units, or</p><p style="margin: 0px;">3) attacker and defender each lose one unit.</p></blockquote>
<p style="margin: 0px;">These cases come from the results of our die rolls.</p>
\begin{align}
P(\text{attacker loses two units}) &= P(A_1 \leq D_1, A_2 \leq D_2) \\
P(\text{defender loses two units}) &= P(A_1 > D_1, A_2 > D_2) \\
P(\text{both lose one unit}) &= P(A_1 \leq D_1, A_2 > D_2) + P(A_1 > D_1, A_2 \leq D_2)
\end{align}
<p style="margin: 0px;">Note the use of $\leq$, corresponding to the fact that ties go to the defender. Also note that there are two ways that both can lose one unit: attacker can win with the top die and lose with the lower die, and vice versa. We can compute these by looking at all the cases.</p>
\begin{align}
P(A_1 \leq D_1, A_2 \leq D_2) &= \sum_{d_1=1}^6 \sum_{d_2=1}^{d_1} P(A_1 \leq d_1, A_2 \leq d_2) \cdot P(D_1 = d_1, D_2 = d_2)
\end{align}
\begin{align}
P(A_1 \leq d_1, A_2 \leq d_2) = \sum_{a_1=1}^{d_1} \sum_{a_2=1}^{d_2} P(A_1 = a_1, A_2 = a_2)
\end{align}
\begin{align}
P(A_1 \leq D_1, A_2 \leq D_2) &= \sum_{d_1=1}^6 \sum_{d_2=1}^{d_1} \sum_{a_1=1}^{d_1} \sum_{a_2=1}^{d_2} P(A_1 = a_1, A_2 = a_2) \cdot P(D_1 = d_1, D_2 = d_2)
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Because our expressions for $P(A_1=a_1, A_2=a_2)$ and $P(D_1 = d_1, D_2 = d_2)$ depend on whether $a_1=a_2$ and whether $d_1=d_2$, respectively, we can break up the sum to look at the four cases.</p>
\begin{align}
1: & \quad a_1=a_2 \quad d_1=d_2 \\
2: & \quad a_1=a_2 \quad d_1>d_2 \\
3: & \quad a_1>a_2 \quad d_1=d_2 \\
4: & \quad a_1>a_2 \quad d_1>d_2
\end{align}
<p style="margin: 0px;">We can label the summations related to these cases at $s_1$--$s_4$.</p>
\begin{align}
P(A_1 \leq D_1, A_2 \leq D_2) &= s_1 + s_2 + s_3 + s_4
\end{align}
<p style="margin: 0px;">In many of the cases, collapsing some terms to be equal simplifies the summation.</p>
\begin{align}
s_1 &= \sum_{d_1=1}^6 \sum_{d_2=d_1}^{d_1} \sum_{a_1=1}^{d_1} \sum_{a_2=a_1}^{a_1} P(A_1 = a_1, A_2 = a_2) \cdot P(D_1 = d_1, D_2 = d_2) \\
&=\sum_{d_1=1}^6 \sum_{a_1=1}^{d_1} P(A_1 = a_1, A_2 = a_1) \cdot P(D_1 = d_1, D_2 = d_1) \\
&=\sum_{d_1=1}^6 \sum_{a_1=1}^{d_1} \left (\frac{3a_1-2}{6^3} \right) \cdot \frac{1}{36} \\
&=\sum_{d_1=1}^6\frac{3 \frac{d_1 \cdot (d_1+1)}{2}-2d_1}{6^5}\\
&=\sum_{d_1=1}^6\frac{\frac{3}{2}d_1^2 -\frac{1}{2}d_1}{6^5}\\
&= \frac{1}{6^5} \cdot \left ( \frac{3}{2}\cdot \frac{6 \cdot (6+1) \cdot (2\cdot 6 +1 )}{6} - \frac{1}{2} \cdot \frac{6 \cdot (6+1)}{2} \right ) \\
&=\frac{6\cdot 7 \cdot 13 - 6 \cdot 7 }{2^2 \cdot 6^5}\\
&=\frac{6\cdot 7 \cdot 2 \cdot 6 }{2^2 \cdot 6^5}\\
&= \frac{7}{2 \cdot 6^3}\\
&\approx 0.0162
\end{align}
<p style="margin: 0px;">Now on to the next term.</p>
\begin{align}
s_2 &= \sum_{d_1=1}^6 \sum_{d_2=1}^{d_1-1} \sum_{a_1=1}^{d_1} \sum_{a_2=a_1}^{a_1} P(A_1 = a_1, A_2 = a_2) \cdot P(D_1 = d_1, D_2 = d_2) \\
&=\sum_{d_1=1}^6 \sum_{d_2=1}^{d_1-1} \sum_{a_1=1}^{d_1} P(A_1 = a_1, A_2 = a_1) \cdot P(D_1 = d_1, D_2 = d_2) \\
&=\sum_{d_1=1}^6 \sum_{d_2=1}^{d_1-1} \sum_{a_1=1}^{d_1} \left (\frac{3a_1-2}{6^3} \right) \cdot \frac{1}{18} \\
&=\sum_{d_1=1}^6 \sum_{d_2=1}^{d_1-1}\frac{3 \frac{d_1 \cdot (d_1+1)}{2}-2d_1}{3 \cdot 6^4}\\
&=\sum_{d_1=1}^6 (d_1-1) \cdot \frac{3 d_1^2 -d_1}{6^5}\\
&=\sum_{d_1=1}^6 \frac{3 d_1^3 -4d_1^2+d_1}{6^5}\\
\end{align}
<p style="margin: 0px;">To solve this part, we need to know what the sum of a sequence of cubed terms is.</p>
\begin{align}
\sum_{k=1}^n k^3 = \frac{n^2(n+1)^2}{2^2}.
\end{align}
<p style="margin: 0px;">I will avoid proving the above, as I did with the previous summations. This is not one I had known existed, but it was easy to find. A proof by induction should work here easily as well.</p>
\begin{align}
s_2 &= \frac{3 \cdot\frac{6^2 \cdot 7^2}{2^2} - 4\cdot\frac{6 \cdot 7 \cdot 13}{6} + \frac{6\cdot7}{2}}{6^5}\\
&= \frac{3 \cdot 3^2\cdot7^2 - 4\cdot7\cdot13+3\cdot7}{6^5}\\
&=\frac{2^2\cdot5\cdot7^2}{6^5}\\
&\approx 0.126
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Alright, I'm trying to make a point, but this is getting too tiresome. We haven't even completed one of the scenarios! Let's just write a program to run all the cases, there aren't that many, only $6^5=7776$, and then be done with it.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The construction is this: we'll run 5 loops, one for each of the 5 dice, each taking the values from 1 to 6 to cover all possible cases. The first three loops correspond to the attacker's dice, the last two to the defender's dice. Then we sort the values and compare to see which of the three scenarios we end up in. We'll initialize three counters to zero before the loops and use them to keep track of how many times each case occurs. After the loops complete, we can check that they sum to the required 7776 cases as a basic check that we didn't skip any outcomes. From the counts, we can divide by 7776 to get the probabilities of each case.</p>
<p style="margin: 0px;"><br /></p>
\begin{align}
P(\text{attacker loses two units}) &= \frac{2275}{7776} \approx 0.293 \\
P(\text{defender loses two units}) &= \frac{2890}{7776} \approx 0.372 \\
P(\text{both lose one unit}) &= \frac{2611}{7776} \approx 0.336
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">As we can see, all three outcomes are quite likely, but the probability that the defender loses two units is the highest, which gives the edge to the attacker.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Note that while I have used a computer to obtain this result (and indeed to compute several values and generate many plots in the past), we have not performed a simulation. That is, we are not limited here by the randomness of the computer and the number of trials run. On the other hand, we've used the same technique as <a href="https://www.quantifyingstrategy.com/2020/04/whats-up-with-dots-on-number-discs-in.html">when we first looked at the distribution of 2d6</a>: counting all the cases. This can be an exhaustive tedious method, but in cases where we can make the computer do it for us it is often the most efficient path to a solution. It doesn't necessarily give us a lot of insight here, but neither was all the analysis we did above.</p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-9170413323750351865.post-31619622849124116102020-11-23T15:30:00.001-08:002020-11-23T15:30:00.368-08:00The Haunt Roll in Betrayal Games<p>I'll get to the Betrayal games in a minute, but let me share some background for how I'm approaching it.</p>
<p style="margin: 0px;">There was a recent question on BoardGameGeek that asked about a mechanic for finding a spy amidst a group of senators. The proposal was to use a bag with 11 tokens, 2 of which are spy tokens, with the remaining 9 being senators. Both spy tokens need to be drawn to find the spy.</p><blockquote>
<p style="margin: 0px;"><a href="https://boardgamegeek.com/thread/2530083/probability-question-finding-spy-chit-drawing">I would like the average resolution to be about 6-7 attempts, hopefully landing in the neighborhood of 4-9 attempts, beyond some extreme flukes.</a></p></blockquote><p style="margin: 0px;"></p>
<p style="margin: 0px;">First, let me say that I love the framing here in terms of the desired average and extremes. We can evaluate the mechanic much better with a design criteria as described above.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">As to the problem, we can simplify the problem by turning it around, which avoids having to consider the combinatorics of order. This approach is similar to how I've solved the game length in <a href="https://www.quantifyingstrategy.com/2020/04/when-will-high-society-end.html">High Society</a>. Let's analyze the problem as if the order the chits is known or determined ahead of time (even though it isn't). The question then becomes, what is the probability that the second spy chit is in round $r$ counting from the front? That's the same as looking for the first spy chit from the back of the line. For the last round,$r=9$, that's easy,</p>
\begin{align}
P(r=9) = \frac{2}{11},
\end{align}
<p style="margin: 0px;">as there are 2 spies out of 11 total tokens. Let's count this as round $n=1$ from the back. </p>
\begin{align}
P(n=1) = \frac{2}{11} \end{align}
<p style="margin: 0px;">For earlier rounds, we must have drawn all senators "first" (again, we're starting at the back). The probability of drawing a senator in a round $n$ from the back is based on the number of tokens that weren't drawn yet. If we've yet to draw a spy, in round $n$, there are $11-(n-1)=12-n$ total tokens. Two of them are spies, so $12-n-2$ are spies. Thus the probability of drawing a senator in round $n$ (from the back) given no previous spies is as follows.</p>
\begin{align}
P(\text{senator in round } n | \text{ no spies in rounds} < n) & = \frac{11 - (n-1) - 2}{11 - (n-1)} \\
&= \frac{10-n}{12-n}
\end{align}
<p style="margin: 0px;">So first $\frac{9}{11}$, then $\frac{8}{10}$, and so on. Similarly, the probability of drawing the "first" spy in round $n$ from the back is,</p>
\begin{align}
P(\text{spy in round } n | \text{ no spies in rounds} < n) & = \frac{2}{11 - (n-1)} \\
&= \frac{2}{12-n}.
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can combine the above in order to get the probability of finding a spy in round $n$. To be able to write the probabilities in a more compact way, such that we can fit our equations on one line, let's make use of the following events.</p>
\begin{align}
S_n &= \text{senator in round } n \\
Y_n &= \text{spy in round } n
\end{align}
<p style="margin: 0px;">We can rewrite the above probabilities using these events.</p>
\begin{align}
P\left(S_n \:\middle\vert\: \bigcap_{i<n} S_i\right) &= P(\text{senator in round } n \mid \text{no spies in rounds} < n)\\
P\left(Y_n \:\middle\vert\: \bigcap_{i<n} S_i\right) &= P(\text{spy in round } n \mid \text{no spies in rounds} < n)
\end{align}
<p style="margin: 0px;">Here $\bigcap_{i<n} S_i$ refers to the intersection of all events $S_i$ when $i<n$. Basically, that means $S_1$, $S_2$, $\ldots$, $S_{n-2}$, and $S_{n-1}$ all occur. Note that because senators and spies are mutually exclusive and the only options,</p>
\begin{align}
P(Y_n) = 1- P(S_n).
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Using this more compact notation, we can combine our previous equations to get the total probability of drawing the first spy in round $n$ from the back.</p>
\begin{align}
P(Y_n) &= P\left(Y_n \:\middle\vert\: \bigcap_{i<n} S_i\right) \cdot P\left(\bigcap_{i < n} S_i\right)
\end{align}
<p style="margin: 0px;">Recall that $P(S_i)$ depends on what was previous drawn, meaning that $S_i$ are not independent. Because of this, we cannot simply break up $P\left(\bigcap_{i < n} S_i\right)$ as a product of the probabilities.</p>
\begin{align}
P\left(\bigcap_{i < n} S_i\right) &\neq \prod_{i=1}^n P(S_i) \\
\end{align}
<p style="margin: 0px;">Instead, we use the conditional probabilities that we found earlier.</p><div>
\begin{align}
P(Y_n) &=P\left(Y_n \:\middle\vert\: \bigcap_{i<n} S_i\right) \cdot\prod_{i=1}^n P\left(S_i \:\middle\vert\: \bigcap_{k<i} S_k\right) \\
&= \frac{2}{12-n}\frac{9}{11} \cdot \frac{8}{10} \cdot \ldots \cdot \frac{10-(n-1)}{12-(n-1)} \\
&= \frac{2 \cdot 9 \cdot 8 \cdot \ldots \cdot (10-(n-1))}{11 \cdot 10 \cdot \ldots \cdot (12-n)} \\
&= 2 \cdot \frac{9!}{11!} \cdot \frac{(12-(n+1))!}{(10-n)!}
\end{align}
<p style="margin: 0px;">At this point, we can turn things back around to count from the front. We know that $n=1$ is equivalent to $r=11$ and $n=11$ is equivalent to $r=1$. From this we can write the equations defining the relationship between the number of rounds from the front, $r$, and the number of rounds from the back, $n$.</p>
\begin{align}
n = 12-r
\end{align}
<p style="margin: 0px;">Thus the probability of finding the spy chit in round $r$ is as follows.</p>
\begin{align}
P(\text{spy revealed in round } r) &= P(Y_{12-r}) \\
&= 2 \cdot \frac{9!}{11!} \cdot \frac{(12-(12-r+1))!}{(10-(12-r))!}\\
&= 2 \cdot \frac{9!}{11!} \cdot \frac{(r-1)!}{(r-2)!} \\
&= 2 \cdot \frac{9!}{11!} \cdot (r-1) \\
&= \frac{2}{11\cdot 10} \cdot (r-1)
\end{align}
<p style="margin: 0px;">The result of this equation is shown in Figure 1, which shows a linearly increasing probability as each new token is drawn, starting with a probability of 0 in round 1. This makes sense, as the second spy token must be drawn to actually find the spy. A numerical check confirms that the values for all value $r$ sum to 1. As clearly shown in the plot, this favors the last rounds, which does not match the desired properties.</p><p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyc4ki730n3u5SlIsKywVmXDu2LKXaDK7L-dAQuE5vozZfolTXemOqp97QiPFVzKgwJlVKWlKABttzstevbu1GvV2BOVQyyrDZyZ6Ar4xTG3Bj6tLQEYBEziLUNEX-IYulPogx8mKNxD5r/s800/spies.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyc4ki730n3u5SlIsKywVmXDu2LKXaDK7L-dAQuE5vozZfolTXemOqp97QiPFVzKgwJlVKWlKABttzstevbu1GvV2BOVQyyrDZyZ6Ar4xTG3Bj6tLQEYBEziLUNEX-IYulPogx8mKNxD5r/w400-h275/spies.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Probability of finding the spy<br /></td></tr></tbody></table><p></p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Now, let's turn to the haunt roll mechanics found in the various Betrayal games, including <a href="https://www.fgbradleys.com/rules/rules2/BetrayalAtTheHouseOnTheHill-rules.pdf">Betrayal at the House on the Hill</a>, <a href="https://media.wizards.com/2017/avalon_hill/BaBG_Rulebook.pdf">Betrayal at Balder's Gate</a>, Betrayal Legacy, and <a href="https://media.wizards.com/2020/ah/downloads/AH_BMM_Rulebook.pdf">Betrayal at Mystery Mansion</a>. We'll actually set the legacy version aside, as the legacy aspects of the game can influence the roll.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">In the original game (Betrayal at the House on the Hill), each time an omen is drawn the active player rolls 6 dice and if the result is less than the number of omen cards then the haunt starts (the example in the rulebook actually says equal to or less than number of omen cards, which I'll assume is an error). The dice in all betrayal games are the same: custom six-sided dice with two sides each of 0, 1, and 2. This means the probability mass function (pmf) of each die is $1/3$ for values on the dice, and $0$ elsewhere. We'll denote the result of one of the betrayal dice as a random variable $D$ with pmf $f_D(d)$.</p>
\begin{align}
f_D(d) = \begin{cases}
\frac{1}{3} \quad & d \in {0, 1, 2} \\
0 \quad &\text{else}
\end{cases}
\end{align}
<p style="margin: 0px;">We can get the pmf of the entire hunt roll of six dice, $f_H(h)$ by convolving the pmf of each die with itself enough times to account for the six dice that a player rolls.</p>
\begin{align}
f_H(h) = f_D(h) * f_D(h) * f_D(h) * f_D(h) * f_D(h) * f_D(h)
\end{align}
<p style="margin: 0px;">Because convolution is associative, we don't have to worry about the order of the convolutions. The result is shown in calculation in Figure 2. We get what we expect after convolving a reasonable number (even if it is only six here) of independent identically distributed (i.i.d.) random variables, which is a roughly Gaussian, or normal-looking distribution. (Due to the Central Limit Theorem. There are probably some comments I should be making about whether them being identically distributed matters here, but I'll omit them for ease and brevity.) We expect a minimum value of 0 and maximum value of 12, each corresponding to the extreme values on all dice. These are possible, but with low probability. The distribution is also symmetric. </p><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ9025WZ4_bx-XBZ65N3oIglFLxEzlesWfQkRsceMUbw6qwU5iw1kH8d1bdMyYWhz3ZbKV1O3vLeDrXaJbigU6bx6CJVbxYX2XoSCAxHRGqYofOVduOOiNOhux-cnJFo7tXkh9MT35Lw7A/s800/betrayal_haunt_roll_pmf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ9025WZ4_bx-XBZ65N3oIglFLxEzlesWfQkRsceMUbw6qwU5iw1kH8d1bdMyYWhz3ZbKV1O3vLeDrXaJbigU6bx6CJVbxYX2XoSCAxHRGqYofOVduOOiNOhux-cnJFo7tXkh9MT35Lw7A/w400-h275/betrayal_haunt_roll_pmf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Probability mass function of haunt roll<br /></td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">By computing the cumulative distribution (CDF) of the haunt roll result, $F_H(h)$, we can easily compute the probability that the haunt starts in any given round. Finding the CDF is a straightforward computation based on the pmf.</p>
\begin{align}
F_H(h) &= P(H \leq h) \\
&= \sum_{i=0}^h f_H(i)
\end{align}
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPtTjlhbs8Kw3Z5j58KM_9jpmUU8mGlqGsm8VqVoB4F8PYKt2_urCwSHxLHeMXY1MR8U57V9xZv4EZDSN2vL8-kNYUMBmVnIXrCPmtXl-Rm8djucaYQ_xmzoPsnczmuHU5ImYNfkD-4ynW/s800/betrayal_haunt_roll_cdf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPtTjlhbs8Kw3Z5j58KM_9jpmUU8mGlqGsm8VqVoB4F8PYKt2_urCwSHxLHeMXY1MR8U57V9xZv4EZDSN2vL8-kNYUMBmVnIXrCPmtXl-Rm8djucaYQ_xmzoPsnczmuHU5ImYNfkD-4ynW/w400-h275/betrayal_haunt_roll_cdf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: Cumulative distribution function of haunt roll</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Note that here, the minimum possible value on a haunt roll is 0. The resulting CDF is plotted in Figure 3. Because the haunt starts whenever the haunt roll is less than the number of omens drawn, the probability of a haunt being triggered when making a haunt roll is equal to the CDF evaluated at one less than the number of omens, $o$.</p>
\begin{align}
P(\text{haunt starts} \mid o \text{ omens}) = F_H(o-1)
\end{align}
<p style="margin: 0px;">The next step is to assemble the probability distribution of the number of omens drawn before the haunt starts. We use the distribution of the haunt roll to do this, noting that we only consider drawing more omens if the haunt starts. Therefore, the probability that the number of omens when the haunt starts, $O$, is 1 is equal to the probability that we roll less than 1 on the first haunt roll.</p>
\begin{align}
f_O(1) &=P(O=1)\\
&= F_H(1-1)\\
& = F_H(0)\\
&=f_H(0)\\
&=f_D(0)^6\\
& \left( \frac{1}{3} \right)^6 \\
&\approx 0.00137
\end{align}
<p style="margin: 0px;">In this case, as shown above, the probability shakes out to the probability of rolling 0 on all six haunt dice, which occurs with a probability of about 0.00137.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">When looking at the probability that $O>1$, we must consider the result of all previous haunt rolls. That is, we only make a haunt roll with $o$ omens, where $o>1$, if all previous haunt rolls failed to start the haunt.</p>
\begin{align}
P(\text{make haunt roll with $o$ omens}) &= 1 - P(O < o)\\
&= 1- F_O(o-1)\\
& 1 - \sum_{i=0}^{o-1}f_O(i)
\end{align}
<p style="margin: 0px;">This gives us an equation to compute the distribution of $O$ where we can compute each term one at a time, using the one term to compute the next.</p>
\begin{align}
f_O(o) &= \left ( 1 - \sum_{i=0}^{o-1}f_O(i) \right) \cdot F_H(o-1)
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Now that we've gone all the way through this exercise, we can turn to the other versions of the game. Betrayal and Balder's Gate and Betrayal at Mystery Mansion both function similarly (though the latter game uses the term clue instead of omen, it functions the same). Instead of rolling a constant number of dice and adjusting the target number, the number of dice rolled is equal to the number of omen cards drawn and a constant target number is used. In Balder's Gate, if the haunt roll is 6 or higher the haunt starts, whereas Mystery Mansion uses a threshold of 5 or higher.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">To compute the distribution of dice, we can use a similar method as above, but varying the number of haunt dice pmfs which are convolved. The resulting pmfs and CDFs are plotted in Figures 4 and 5.</p><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiph6enrnHX9Ey_G9Dr2HjRUxYLp7hPfebJBzhaR1MxV9Nytppbdsh1ZV1rFEqoLNv426CBp2WIUSKnQzVo85RtJ4s-nslRu6E5QIYTCzHP9g6uTPDWQDBhGkd-NnQp1Sj8fkNQloSs-SvJ/s800/betrayal_haunt_roll_pmf_by_round.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiph6enrnHX9Ey_G9Dr2HjRUxYLp7hPfebJBzhaR1MxV9Nytppbdsh1ZV1rFEqoLNv426CBp2WIUSKnQzVo85RtJ4s-nslRu6E5QIYTCzHP9g6uTPDWQDBhGkd-NnQp1Sj8fkNQloSs-SvJ/w400-h275/betrayal_haunt_roll_pmf_by_round.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 4: Probability mass function of haunt roll by omen</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilmvI8a3izqeVQqap2ZZblQNYGiiPQmm6DMfMrW3-bswY3pEaQdFJvYvSylckyN9zZ2zD5XobcXJepzJdsjvUbIVrbXAP7BxEMwIyJKnXetFR6j-W0goJCJIaC4R3ltKMYfR96foJ3P0Eh/s800/betrayal_haunt_roll_cdf_by_round.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilmvI8a3izqeVQqap2ZZblQNYGiiPQmm6DMfMrW3-bswY3pEaQdFJvYvSylckyN9zZ2zD5XobcXJepzJdsjvUbIVrbXAP7BxEMwIyJKnXetFR6j-W0goJCJIaC4R3ltKMYfR96foJ3P0Eh/w400-h275/betrayal_haunt_roll_cdf_by_round.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 5: Cumulative distribution function of haunt roll by omen</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can reuse the same equation to find the pmf and CDF of the number of omens drawn before the haunt starts for the three games, which are plotted in Figures 6 and 7. We can note a couple differences. Most evident is that each iteration on the game tends to make the haunt start sooner, as shown most clearly in the CDFs. Second, the possibility of a very early haunt with the original game, with only 1 or 2 drawn, has been completely eliminated in Balder's Gate and Mystery Mansion. For the later games, rolling one or two dice is insufficient to get a sum or 5 or 6 to trigger the haunt. On the other hand, these games have a non-zero probability of an arbitrarily long game according to the probabilities shown. Mystery Mansion has a special rule that the haunt always starts after the 9th omen (clue) card is drawn.</p>
<p style="margin: 0px;"><br /></p><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvzPRf-C4eqEBin78nkTJX3IyzJPL06IHwmTTXpDjlUiMGNVRzq0EWyh9pQ1i8yPs4kNpv8M95yFVLESg45wKjJ4fjK-aWwbrtt9YpxTTWumE1mJEXq9rNuH_G6VsvFeVG7t6BPZh01e7b/s800/betrayal_haunt_pmf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvzPRf-C4eqEBin78nkTJX3IyzJPL06IHwmTTXpDjlUiMGNVRzq0EWyh9pQ1i8yPs4kNpv8M95yFVLESg45wKjJ4fjK-aWwbrtt9YpxTTWumE1mJEXq9rNuH_G6VsvFeVG7t6BPZh01e7b/w400-h275/betrayal_haunt_pmf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 6: Probability of triggering the haunt when drawing current omen</td></tr></tbody></table><br /><p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFeTVN7VGmr1HcBIl2x_uVl0kQeWf6QtuAYLuwzvCzTx8F4XOrsSHHnAY6q_9zCPTZlo-B5HAyQdNz5H6Bxewy8UZeSQQn6ZIligLWE8AWLkg86w-P4n4RvE5tq0sQKFz3CjnRJWVfjEwA/s800/betrayal_haunt_cdf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFeTVN7VGmr1HcBIl2x_uVl0kQeWf6QtuAYLuwzvCzTx8F4XOrsSHHnAY6q_9zCPTZlo-B5HAyQdNz5H6Bxewy8UZeSQQn6ZIligLWE8AWLkg86w-P4n4RvE5tq0sQKFz3CjnRJWVfjEwA/w400-h275/betrayal_haunt_cdf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 7: Cumulative probability of triggering the haunt</td></tr></tbody></table><p></p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We could modify the dice so that they naturally provide both an upper and lower bound, as originally desired for the spy search mechanism, by using a similar mechanism to the later Betrayal games but having a non-zero minimum value on the dice. Doing this sets a maximum number of turns needed for the search, equal to the ratio between the target sum and the minimum value on the dice. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Recall that we want between 4 and 9 searches, averaging 6-7. Let's use a minimum value of 1 on the dice and decide on the number of values to include to achieve the properties above. With a minimum of 1 and max 9 rounds, the target sum must be 9. To prevent 3 searches from being successful, there must be at most 2 sides on the dice. This gives the distributions functions shown in Figures 8 and 9. While these center more on 6 searches, they demonstrate the feasibility of this type of mechanism. The particular type of dice and target numbers can be adjusted to get the desired probability properties.</p>
<br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi61ZziqyCUs3jAKpk4V9AJsNjeCHaL3fVt9Wb37Tb740g2OAQCHBnc7a0a_Y6Pm2uqw5ippGo8QI-d2q3_Lhql8JTMPmQiIS3pBgd42W1IQ9w6YNd8mqvNkKhfmfCj9YQhfr6PFawyaZL6/s800/spies_roll_pmf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi61ZziqyCUs3jAKpk4V9AJsNjeCHaL3fVt9Wb37Tb740g2OAQCHBnc7a0a_Y6Pm2uqw5ippGo8QI-d2q3_Lhql8JTMPmQiIS3pBgd42W1IQ9w6YNd8mqvNkKhfmfCj9YQhfr6PFawyaZL6/w400-h275/spies_roll_pmf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 8: Probability of finding the spy in the current round (pmf)</td></tr></tbody></table><br /><p style="margin: 0px;"></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOXTuusnkHGQNucFdH2S8UoJwJcT41fSbY8-gs2DU7n1g1B1qQj9ljVvfuaJ5XdoXPDJR5qjAsHS6_sSKJGV7UzitgDq5-J570DmiHqFk7bMP6mcHirE8wZFQbO4gFd4viy6lb_iy5Kqdh/s800/spies_roll_cdf.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="550" data-original-width="800" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOXTuusnkHGQNucFdH2S8UoJwJcT41fSbY8-gs2DU7n1g1B1qQj9ljVvfuaJ5XdoXPDJR5qjAsHS6_sSKJGV7UzitgDq5-J570DmiHqFk7bMP6mcHirE8wZFQbO4gFd4viy6lb_iy5Kqdh/w400-h275/spies_roll_cdf.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 9: Cumulative probability of finding the spy by round (CDF)</td></tr></tbody></table><p></p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-90537334921487585662020-10-19T15:30:00.001-07:002020-10-19T15:30:05.402-07:00Simplifying Combat<p>Many "dudes on a map'' games, involve combat mini-games that mostly consist of taking a break from the normal game, and taking turns rolling lots of dice, losing some units, and repeating until only one player has units left. Sometimes you may be able to target specific units (e.g. Buck Rogers), play a card that influences the dice rolling that round (e.g. Star Wars: Rebellion), or decide whether to retreat or give up (e.g. War of the Ring).</p>
<p style="margin: 0px;">This is similar to combat in many RPGs, or skill challenges in D&D 4th edition.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">However, some games (e.g. Bottom of the 9th) don't offer any choices in between rounds of rolling dice. My contention is that such a game is likely bad design, simply based on the math. That is, you could replace any decision-free process with a single-step process with equivalent probabilities. Even for games with choices in between rounds of combat, the value of having such a choice should outweigh the cost of game time and complexity.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's look at a theoretical game. Suppose in this game when you move a number of units into an enemy territory you engage in rounds of combat. Each round you roll one die for each attacker and destroy one defender with probability $p$. Similarly, your opponent rolls one die for each defender and destroys one attacker with the same probability $p$. Each round is simultaneous; that is, remove destroyed units at the end of each round. If only one player has units at the end of a round, then stop. Suppose you start with $A$ attackers, and your opponent starts with $D$ defenders.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The combat will end with either the attacker remaining with 1 to $A$ units, the defender will remain with 1 to $D$ units, or both armies will be destroyed. If we could compute the probability of each of these results, then we could simply use the result instead of all the dice rolling.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">What's tricky is that there's a probability of $(1-p)^{(A+D)}$ that no units are destroyed in a round. This comes from all $A+D$ units missing, which occurs with probability $1-p$, since $P(\text{hit}) + P(\text{miss}) = 1$. That means that the combat could go on for a long time. In fact, it's not guaranteed to ever end. So, while it's relatively easy to show the probability distribution of the state of combat after $r$ rounds, the end of the combat is not so clear. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Well, let's start by looking at what happens in round $r$ and see what the distribution is first. Let's denote $a_r$ and $d_r$ as the number of attackers and defenders, respectively, remaining at the end of round $r$. Let's also just say that $a_0 = A$ and $d_0 = D$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Actually, let's look at the simple case of one attacking unit and one defending unit. After the first round of combat, there are four possible outcomes: both units are destroyed, the defender is destroyed, the attacker is destroyer, or neither are destroyed. In the first three outcomes the combat ends. In the last, another round commences with the same possible outcomes and the same probabilities, since the combat starts in the same state. The probabilities are,</p>
\begin{align}
P(\text{both destroyed in first round}) &= p^2 \\
P(\text{attacker destroyed in first round}) &= p\cdot (1-p) \\
P(\text{defender destroyed in first round}) &= p\cdot (1-p) \\
P(\text{neither destroyed in first round}) &= (1-p)^2 .
\end{align}
<p style="margin: 0px;">Then, the probability of what happens in the second round is the same as the first, multiplied by the probability that you get to the second round.</p>
\begin{align}
P(\text{both destroyed in second round}) &= p^2\cdot (1-p)^2 \\
P(\text{attacker destroyed in second round}) &= p\cdot (1-p)^3 \\
P(\text{defender destroyed in second round}) &= p\cdot (1-p)^3 \\
P(\text{neither destroyed in second round}) &= (1-p)^4 .
\end{align}
<p style="margin: 0px;">The probability that the combat ends with both destroyed is equal to the probability that it happens in the first round, plus the probability that it happens in the second round, and so on.</p>
\begin{align}
&P(\text{both destroyed at end of combat}) = \sum_{r=1}^\infty P(\text{both destroyed in round } r)\\
&= \sum_{r=1}^\infty P(\text{both destroyed in a round}) \cdot P(\text{get to round } r)\\
&= \sum_{r=1}^\infty p^2 \cdot (1-p)^{2(r-1)} \\
&= p^2 \sum_{r=1}^\infty \cdot \left((1-p)^2\right)^{r-1} \\
&= p^2 \sum_{r=0}^\infty \cdot \left((1-p)^2\right)^r
\end{align}
<p style="margin: 0px;">Recall that (Honestly, right now I'm just relying on Wikipedia, but I'm pretty sure I have derived or will derive this.)</p>
\begin{align}
\sum_{i=0}^\infty a^i &= \frac{1}{1-a}
\end{align}
<p style="margin: 0px;">Thus, </p>
\begin{align}
P(\text{both destroyed at end of combat}) &= p^2 \sum_{r=1}^\infty \cdot \left((1-p)^2\right)^r \\
&= p^2 \cdot \frac{1}{1 - (1-p)^2}
\end{align}
<p style="margin: 0px;">Similarly,</p>
\begin{align}
P(\text{attacker destroyed at end of combat}) &= p \cdot (1-p) \cdot \frac{1}{1 - (1-p)^2} \\
P(\text{defender destroyed at end of combat}) &= p \cdot (1-p) \cdot \frac{1}{1 - (1-p)^2}
\end{align}
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">As a check, do these probabilities add up to one? Let's find out.</p>
\begin{align}
&P(\text{both destroyed at end of combat}) \\
&+ P(\text{attacker destroyed at end of combat}) \\
&+ P(\text{defender destroyed at end of combat}) = \\
&=p^2 \cdot \frac{1}{1 - (1-p)^2} + p \cdot (1-p) \cdot \frac{1}{1 - (1-p)^2} + p \cdot (1-p) \cdot \frac{1}{1 - (1-p)^2} \\
&=p \cdot (p + 2\cdot (1-p)) \frac{1}{1 - (1-p)^2} \\
&=p \cdot (p + 2\cdot (1-p)) \frac{1}{1 - (1-2p+p^2)} \\
&=p \cdot (p + 2\cdot (1-p)) \frac{1}{2p-p^2} \\
&=p \cdot (p + 2\cdot (1-p)) \frac{1}{p\cdot(2-p)} \\
&=(p + 2\cdot (1-p)) \frac{1}{2-p} \\
&=(p + 2-2p) \frac{1}{2-p} \\
&=(2-p) \frac{1}{2-p} \\
&=1
\end{align}
<p style="margin: 0px;">So we're correct. (Initially I had $(1-p)^2$ in the numerator because I had $r$ instead of $r-1$ in the early equations above. As indicated by my errata, these checks are important.) That's mostly algebra, but I need a lot more explanation here.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We used an infinite series above, but we could instead argue that we can simply ignore the case where neither are destroyed in a round since we only care about the end state. Getting such a result simply delays the final outcome. Thus, we take the probabilities of the remaining three cases and divide by their sum to get the probability of ending in the corresponding states.</p>
\begin{align}
P(\text{both destroyed at end of combat}) &= \frac{P(\text{both destroyed in first round})}{P(\text{something destroyed in first round})} \\
P(\text{attacker destroyed at end of combat}) &= \frac{P(\text{attacker destroyed in first round})}{P(\text{something destroyed in first round})} \\
P(\text{defender destroyed at end of combat}) &= \frac{P(\text{defender destroyed in first round})}{P(\text{something destroyed in first round})}
\end{align}
<p style="margin: 0px;">Where $P(\text{something destroyed in first round})$ is the sum of the three first-round probabilities above.</p>
\begin{align} &\begin{split}
P(\text{something destroyed in first round}) &= P(\text{both destroyed in first round}) \\
&+ P(\text{attacker destroyed in first round}) \\
&+ P(\text{defender destroyed in first round})
\end{split} \\
&= p^2 + p\cdot (1-p) + p\cdot (1-p) \\
&= p^2 +2\cdot p - 2\cdot p^2 \\
&= 2 \cdot p - p^2 \\
&= p \cdot (2-p)
\end{align}
<p style="margin: 0px;">Plugging in, we find that,</p>
\begin{align}
P(\text{both destroyed at end of combat}) &= \frac{p^2}{p \cdot (2-p)} \\
P(\text{attacker destroyed at end of combat}) &= \frac{p\cdot (1-p)}{p \cdot (2-p)} \\
P(\text{defender destroyed at end of combat}) &= \frac{p\cdot (1-p)}{p \cdot (2-p)}
\end{align}
<p style="margin: 0px;">These are the same probabilities that we calculated earlier. Note that the two different versions of the equations are written a little differently, but $1-(1-p)^2 = p\cdot (2-p)$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">That's enough for now. I'll later expand this same idea to more complicated combat mechanics.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-25211016807076657492020-10-12T15:30:00.001-07:002020-10-12T15:30:02.258-07:00Errata: Are you a Cylon in Battlestar Galactica?<p>There's an error in my <a href="https://www.quantifyingstrategy.com/2020/04/are-you-cylon-in-battlestar-galactica.html">previous analysis of the probability of me being a Cylon</a> if you've gotten to look at one of my loyalty cards randomly and it was a Human card. We seemingly innocently transformed the previous scenario into the condition that I have one or more human cards, which are not quite the same thing. While it is true that I have one or more human cards, you have additional information: that a randomly selected card was human. Actually, even if you made the statement about having one or more Cylon cards, we'd still be in the same situation, as all Cylon detection abilities either allow you to look at all Loyalty cards or one randomly (see this handy chart: <a href="https://boardgamegeek.com/filepage/41329/crisis-card-chart">https://boardgamegeek.com/filepage/41329/crisis-card-chart</a>). If there were an ability that allowed the target to select the card to be observed, the analysis would hold.</p>
<p style="margin: 0px;">To see what's happening here, let's look at a three player game to make the number of cases simpler. You, Chelsea, and I are playing and you get to look at one of our loyalty cards. All of us have two cards, you know you're human, so there's one Cylon card among the four loyalty cards that Chelsea and I have. I could either have the Cylon card or not, without loss of generality we can say that it's my "first'' card. You randomly get one of my cards. Table 1 shows all the cases, which occur with equal probability.</p>
<p style="margin: 0px;"><br /></p>
\begin{align*}
\begin{array}{c|c|c|c|c}
\text{Scenario #} & \text{Loyalty card 1 } & \text{Loyal card 2} & \text{Card # observed} & \text{Card observed} \\ \hline
1 & \text{Cylon} & \text{Human} & 1 & \text{Cylon} \\
2 & \text{Cylon} & \text{Human} & 2 & \text{Human} \\
3 & \text{Human} & \text{Human} & 1 & \text{Human} \\
4 & \text{Human} & \text{Human} & 2 & \text{Human} \\
\end{array}
\end{align*}
<p style="margin: 0px;">Table 1: Cylon Detection in Battlestar Galactica</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">As we can see here, the probability of me being a Cylon given that you randomly looked at one of my cards, which was human, is $1/3$. There are three cases where you see a human card, one of which involves me having a Cylon card.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's go back to the five player case. The differentiating factor is that the probability of me getting one Cylon card is not $1/2$, but instead $24/56=3/7\approx0.429$ as we computed before, and the probability of me getting two human cards is $30/56=15/28\approx0.536$. We don't care about the two Cylon card case, as we're only looking at the scenarios where you see a human card. The probability of that happening is as follows.</p>
\begin{align}
P(\text{see human}) &= \underbrace{0.5}_\text{Chance to see each of my cards.} \cdot P(\text{1 Cylon}) + P(\text{human})\\
&=0.5 \cdot \frac{24}{56} + \frac{30}{56} \\
&=\frac{12+30}{56} \\
&=\frac{3}{4}\\
&=0.75
\end{align}
<p style="margin: 0px;">The probability that I am Cylon, given that you see a human card from me uses this probability in the denominator.</p>
\begin{align}
P(\text{Cylon} | \text{see human}) &= \frac{P(\text{1 Cylon} \cap \text{see human})}{P(\text{see human})} \\
&= \frac{0.5 \cdot P(\text{1 Cylon})}{P(\text{see human})} \\
&= \frac{0.5 \cdot \frac{24}{56}}{\frac{3}{4}}\\
&=\frac{12}{56} \cdot \frac{4}{3}\\
&=\frac{4}{14}\\
&=\frac{2}{7}
\end{align}
<p style="margin: 0px;">This is the same probability as if we saw that the first loyalty card was human before the sleeper agent phase.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-34584845756713813782020-10-05T15:30:00.013-07:002020-10-05T15:30:00.471-07:00Isn't it better to use a dice deck in Catan?<p>First of all, <i>better</i> is a value judgement. Let's examine the properties and you can evaluate whether you like them better or not.</p>
<p style="margin: 0px;">The idea of a dice deck in Catan is that you have a deck of 36 cards, where instead of rolling 2d6 you flip over a card and it gives you the number for resource generation. (See <a href="https://boardgamegeek.com/boardgame/20038/catan-event-cards">here</a>, although I'll ignore the events and the New Year card.) The values on the cards match the distribution of 2d6, such that the first draw has the same probability as dice. However, if you draw the deck to exhaustion, then you're guaranteed to get exactly five results of "6".</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's start with a question about using dice: if the probability of rolling a six is $5/36$, then do we expect to roll 5 sixes out of 36 rolls? First, let me say that in probability, <i>expect</i> is a word with particular meaning. It refers to the average, or mean value, or something. We write it as an operator using a special capital E. It being an operator means that we write it to the left and it <i>operates</i> on whatever is to the right of it. So when we write $\mathbb{E} X$, we're taking the expectation of the random variable $X$. I'm writing with special typesetting tools (Well, just $\LaTeX$.), but if you're writing with pencil and paper, on a blackboard, or on an internet forum, you may not have access to such special symbols. Then just a capital E will do.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">So our question, reformulated is whether the expected value of the number of occurrences of the number six is $5/36$â€”i.e. $P(\text{rolling a six on 2d6})$â€”or is it some other value? To find out, let's calculate the expected value of the number of occurrences of the number six on 2d6. Wow, that's long winded. Let's assign it a variable name, $Y$.</p>
\begin{align}
Y = \text{number of results equal to six across 36 rolls of 2d6}.
\end{align}
<p style="margin: 0px;">How do we count this? Let's assign names to these 36 rolls. We'll call the results of the 36 2d6 rolls $X_1$â€”$X_{36}$.</p>
<p style="margin: 0px;">As we've been saying, we know from our previous analysis of 2d6 that</p>
\begin{align}
P(X_i = 6) = \frac{5}{36} \quad i \in \{1,2,\cdots,36\}.
\end{align}
<p style="margin: 0px;">Recall that the probability of something not happening is equal to 1 minus the probability of it happening, or</p>
\begin{align}
P(\text{not some thing}) = 1 - P(\text{some thing}).
\end{align}
<p style="margin: 0px;">So</p>
\begin{align}
P(X_i \neq 6) = 1 - P(X_i = 6) = 1 - \frac{5}{36} = \frac{31}{36}.
\end{align}
<p style="margin: 0px;">Let's define the random variables $Y_1$â€”$Y_{36}$ to be 1 if $X_i=6$ and 0 if $X_i \neq 6$. We write this as,</p>
\begin{align}
Y_i = \begin{cases}
1 & X_i = 6 \\
0 & X_i \neq 6
\end{cases} \quad i \in \{1,2,\cdots,36\}.
\end{align}
<p style="margin: 0px;">From this definition, we can see that the sum of these $Y_i$ is the count $Y$ we are looking for.</p>
\begin{align}
Y = \sum^{36}_{i=1} Y_i
\end{align}
<p style="margin: 0px;">What then, is the expected number of sixes $\mathbb{E}Y$? Expectation is a linear operator. That means a few things, that we'll go into elsewhere, but what's important here is that it means that since $Y_i$ are independent, we can distribute the expectation across the different terms in the summation $Y_i$. Basically, we can move it from the left to the right of the summation, like this</p>
\begin{align}
\mathbb{E}Y = \mathbb{E} \sum^{36}_{i=1} Y_i = \sum^{36}_{i=1} \mathbb{E}Y_i.
\end{align}
<p style="margin: 0px;">As mentioned above, the expected value of a random variable is the average so,</p>
\begin{align}
\mathbb{E}Y_i &= \sum^1_{y=0} y \cdot P(Y_i = y).
\end{align}
<p style="margin: 0px;">Note that the summation above is from 0 to 1 because those are the only two values possible for $Y_i$. Using the probabilities of $X_i = 6$ and $X_i \neq 6$ above, we can find</p>
\begin{align}
\mathbb{E}Y_i &= 0 \cdot P(Y_i = 0) + 1 \cdot P(Y_i = 1)\\
\mathbb{E}Y_i &= 0 \cdot P(X_i \neq 6) + 1 \cdot P(X_i = 6)\\
\mathbb{E}Y_i &= 0 \cdot \frac{31}{36} + 1 \cdot \frac{5}{36}\\
\mathbb{E}Y_i &= \frac{5}{36}.
\end{align}
<p style="margin: 0px;">Plugging this back into our equation for $\mathbb{E}Y$ above yields,</p>
\begin{align}
\mathbb{E}Y &= \sum^{36}_{i=1}\frac{5}{36} \\
\mathbb{E}Y &= 36 \cdot\frac{5}{36} \\
\mathbb{E}Y &= 5 .
\end{align}
<p style="margin: 0px;">So we do expect to get 5 sixes when rolling 2d6 36 times. Note that above, we changed from summing $5/36$ 36 times to multiplies $5/36$ by 36. That's because those are equivalent. That's what multiplication is! We can do this whenever we are summing a constant value.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The same thing also holds for all other result here, not just six.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can also ask, what's the distribution of $Y$? Or, what's the probability of getting 5 sixes, or 4, or 3, or however many? We could try to follow the approaches we've used to find the distribution of the sums of dice. But we have 36 rolls here, that doesn't sound like a fun calculation. On the other hand, each $Y_i$ has a simple distribution, so maybe it's not so bad. </p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Fortunately, this is a problem with an existing solution that has been well studied: the binomial distribution. We've used it before, but this time we'll derive what the distribution of $Y$ is. It's probably not that bad. Let's change our notation a little bit, though. The binomial distribution is a parameterized distribution, which means it takes parameters. Basically, there's a bunch of different versions of the distribution. A normal (I mean, regular) single die has a uniform distribution, but the particulars of the uniform distribution depend on the number of faces of the die as a parameter. Similarly a binomial distribution, written as $Y ~ B(n, p)$ takes two parameters: the number of trials, $n$, and the probability of the success of each one, $p$. The number of trials is the number of times that we roll the die. Here we'll use 36 trials to match the 36 cards in the dice deck. The probability, $p$, depends on which face we're focused on. For a result of six, the probability of getting that value in each trial, which we call a success, is $5/36$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">So then in each trial we either get a success, with probability $p$, or failure with probability $1-p$. We're interested in the count of the successes. The extremes are relatively easy to calculate. The probability that we get $n$ successes in $n$ trials is the probability that we succeed on every roll.</p>
\begin{align}
f_Y(n) = p^n
\end{align}
<p style="margin: 0px;">Similarly, the probability that we get no successes is the probability that we fail on every roll.</p>
\begin{align}
f_Y(0) = (1-p)^n
\end{align}
<p style="margin: 0px;">Now, let's consider some result in between, where we get $k$ successes. This could happen by the first $k$ rolls succeeding and the last $n-k$ rolls failing.</p>
\begin{align}
p^k \cdot (1-p)^{n-k}
\end{align}
<p style="margin: 0px;">However, we could also fail the first $n-k$ rolls, and succeed in the last $k$.</p>
\begin{align}
(1-p)^{n-k} \cdot p^k
\end{align}
<p style="margin: 0px;">Note that these occur with the same probability. We can construct several different distinct orders of success and failure that result in $k$ successes. All of them share this same $p^k \cdot (1-p)^{n-k}$ term, but we need to multiply this by the number of ways that we can construct a sequence with $k$ successes in $n$ trials. We need the number of ways to select $k$ elements out of a set of size $n$. We know that this is $\binom{n}{k} = \frac{n!}{k! (n-k)!}$. Thus, we can write the pmf of $Y$ as follows.</p>
\begin{align}
f_Y(k) &= \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k} \\
f_Y(k) &= \binom{36}{k} \cdot \left(\frac{5}{36}\right)^k \cdot \left(1-\frac{5}{36}\right )^{n-k}
\end{align}
<p style="margin: 0px;">By replacing $p$ with the probabilities for each valid result on 2d6, we can get the distributions for the number of times that each of those results appear across a sequence of 36 rolls. These distributions are plotted in Fig. 1. Note that these random variables are not independent. We analyzed each separately, but it's clear that in the case when there are an excess of one value, it decreases the probability of getting a large number of another value.</p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyZBBIU-tgz4XFRHher5TaKyNCNrKp2nta-BxeHe5hyphenhyphenL5yoVpleFIDQfv_HaHhkTVinKrPELAqTon0Bo4h9Hxpy6d4BQ6WsNVdpGoItAqxik7OLHMZTjFfa78yQuW3TzJ2FbMqPPJj4fXe/s700/dice_deck_dice.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyZBBIU-tgz4XFRHher5TaKyNCNrKp2nta-BxeHe5hyphenhyphenL5yoVpleFIDQfv_HaHhkTVinKrPELAqTon0Bo4h9Hxpy6d4BQ6WsNVdpGoItAqxik7OLHMZTjFfa78yQuW3TzJ2FbMqPPJj4fXe/w400-h285/dice_deck_dice.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Probabilities of rolling 2d6 </td></tr></tbody></table><br /><p style="margin: 0px;">We can contrast that with the certainty of a dice deck expressed in terms of the probability mass functions shown in Fig. 2. Here we know the number of times that each value appears, and so each value has a probability of 1 at the number of times that it occurs in the deck. While these values correspond to both the average and peak values of the distribution of 2d6, it does not capture the sizable variation. This is particularly evidence for the results that come up more rarely. It's almost as likely to get no twos across 36 rolls as to get 1 two. At the other extreme, if we consider the number of sevens, we see that the probability of getting exactly the expected number of sevens is significantly lower than for twos. Getting 4 or 7 of them, instead of 6,may seem close to the average and within desired variation, but neither is possible with the dice deck.</p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYytxx4k4mXBW2kSl4zmFpXDAyAYiaDhIdXZmuZYvPI0c8Rnm4S3vG3Yujyq889WTeVhlNZcKmX5cO5nsIw1_rUFzcRfezj77i3JfIVhGCISKrjAzX2GKDgHLzUQRhX_s9y7W_1RS8NO2p/s700/dice_deck.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYytxx4k4mXBW2kSl4zmFpXDAyAYiaDhIdXZmuZYvPI0c8Rnm4S3vG3Yujyq889WTeVhlNZcKmX5cO5nsIw1_rUFzcRfezj77i3JfIVhGCISKrjAzX2GKDgHLzUQRhX_s9y7W_1RS8NO2p/w400-h285/dice_deck.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Probabilities using a dice deck<br /></td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There are a couple of extreme cases where what we get compared to what we want may break down with the dice deck. First, if near the end of the game enough of the deck remains that it's pretty clear that it will not get reshuffled, but certain values have already been exhausted, the benefits of building certain settlements and cities is quite different than with dice. With dice you can build on a twelve and hope that it pays out, but with the dice deck you may know that it never will. The other extreme case is when the deck does get reshuffled very near the end of the game. Through most of the game you've been playing with the knowledge that the deck ensures that the rolls across several turns produce a set distribution. However, if you end shortly after a reshuffle, you now have very similar probability properties to that of dice, where there's the possibility that something more unexpected may come up.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">By modifying the simple dice deck that we considered you can adjust the properties between these two extremes. For example, could reshuffle before reaching the end of the deck. By adjusting the time of reshuffling, you can slide on a spectrum between a our pure example and using dice. Of course, if you shuffle after every draw you get the same probabilities as dice. In that case, dice <i>are</i> better, because they're so much faster to use.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">So far, we've covered differences between dice and a deck of cards which basically boil down to this: a deck has memory. What we draw on one term influences the next, because the state of the deck is changed. If you draw a seven, it's less likely you'll draw another until the deck is reshuffled. On the other hand, each roll of the dice is independent. There's no influence of one roll on the next.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">
</p><p style="margin: 0px;">There's another fundamental difference between the two: the deck is shuffled at the beginning. This means that the result of each draw is predetermined (unless you believe the entire deck can be in a state of <a href="https://en.wikipedia.org/wiki/Quantum_superposition">superposition</a>). If you make a poor choice, you can wallow in regret, as you knew that if you had made a different choice you could have had a better outcome. Not so with dice. Following the <a href="https://en.wikipedia.org/wiki/Butterfly_effect">butterfly effect</a>, any decisions you make before a roll influence that roll. This is not in a controllable way, but just that minute differences in the timing or action of a die roll may yield a different result. Thus, no second guessing is necessary, as if you had decided to do something different, the dice may still have been against you.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-30626858543552479902020-09-21T14:30:00.001-07:002020-09-21T14:30:01.567-07:00The Hunt in War of the RingFirst, let's review the <a href="https://www.aresgames.eu/download/20980/">rules</a> for the Hunt roll in <a href="https://boardgamegeek.com/boardgame/115746/war-ring-second-edition">War of the Ring</a>. When the Fellowship moves (before the Mordor track), the Shadow player rolls a number of dice equal to the number of dice showing an Eye on the Hunt Box, up to a maximum of five. Each roll of a $6+$ is a success. Every previous move of the Fellowship that placed a die in the Hunt Box previously that turn gives a $+1$ to each die roll (an unmodified 1 still misses). There are also three conditions that can grant up to three re-rolls. If there's at least one success, then a tile is drawn to determine damage. <div><br /></div><div> Let's first find the probability of a successful hunt, given the following three parameters. <div>\begin{align}
e & \in \{0, 1, 2, 3, 4, 5\} \qquad &&\text{Number of eyes in the Hunt Box} \\
r &\in \{0, 1, 2, 3\} \qquad &&\text{Number of rerolls} \\
n & \in \{1, 2, 3, 4, 5\} \qquad &&\text{Number of Fellowship moves this turn}
\end{align} </div><div>The probability of succeeding on each die during the first move is $1/6$, as the shadow needs to roll a 6. We could look at the pmf of the number of successes, but instead, we can compute the probability of success as the complement of the probability of failure. To fail, all dice must have failed to roll a success. Each die here fails with probability $1-1/6=5/6$. For $e$ dice with no re-rolls, this is, </div><div>\begin{align}
P(\text{failed hunt}) = \left ( \frac{5}{6} \right) ^e .
\end{align} </div><div>In this framework, incorporating re-rolls is relatively simple also. To fail with re-rolls, first the main roll is failed, then the re-rolls must fail. This means a total of $e+r$ failures are rolled, as long as the number of dice is at least equal to the number of re-rolls. We could restrict $r \leq e$, or we could say that when $r> e$ we look for $2e$ failed dice instead. Ignoring this special case, equivalently, considering $r$ as the effective number of re-rolls, this updates the probability of a failed first hunt as follows. </div><div>\begin{align}
P(\text{failed hunt}) = \left ( \frac{5}{6} \right) ^{e+r}
\end{align} </div><div>To incorporate the effect of the number move involved, we just look at the probability of failing each roll. Instead of $5/6$, we can write this as, </div><div>\begin{align}
\frac{6-n}{6}.
\end{align} </div><div>This brings us a comprehensive equation, using the fact that $P(\text{successful hunt}) = 1 - P(\text{failed hunt})$. </div><div>\begin{align}
P(\text{successful hunt}) = 1 - \left ( \frac{6-n}{6}\right) ^{e+r}
\end{align} </div><div>The result of this equation is plotted in Figures 1â€“3. </div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ta1z20TW34JkZkiUeoy5svzFux8Y8Or8VupTDsDGdlxKCH3MxgkLm_302nO1KjO5eNJ6qVM-uMPW1tQL8OgkSd4JBx8XwAgLIIWYV8w5OfO_nPDvod8_wR05nutRF6TM7pdUZXBzM7id/s700/wotr_hunt_first.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ta1z20TW34JkZkiUeoy5svzFux8Y8Or8VupTDsDGdlxKCH3MxgkLm_302nO1KjO5eNJ6qVM-uMPW1tQL8OgkSd4JBx8XwAgLIIWYV8w5OfO_nPDvod8_wR05nutRF6TM7pdUZXBzM7id/w400-h284/wotr_hunt_first.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Probabilities of a successful first Hunt</td></tr></tbody></table><br /><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAmGG8-lk37DkiAtgRegljOPRXL1eCwsii89pwog_POyP5X5nZptIugunSpBCfrDPDg_bw55GyJZqxyk9lfTKi2kKuK-Z5nWfWLs5xCMPufZChIl0-rbxdGI7YcsLkNdOMFjyin3cGz-6z/s700/wotr_hunt_by_n.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAmGG8-lk37DkiAtgRegljOPRXL1eCwsii89pwog_POyP5X5nZptIugunSpBCfrDPDg_bw55GyJZqxyk9lfTKi2kKuK-Z5nWfWLs5xCMPufZChIl0-rbxdGI7YcsLkNdOMFjyin3cGz-6z/w400-h284/wotr_hunt_by_n.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Probabilities of a successful Hunt by number of moves</td></tr></tbody></table><br /><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0VVaIFo-x5IXSzvQcX2KBdCvD58cg1MNUPxol7IvAQTI48EQfwhFKxl73m2o_21UpoNekgBNAD6LrXi4icwq3QSVv7b3BXE_mHPkCyV8ddobSkHwVSQRU-1wVP3sD3rzpoDksIrYXDA4E/s700/wotr_hunt_by_dice.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0VVaIFo-x5IXSzvQcX2KBdCvD58cg1MNUPxol7IvAQTI48EQfwhFKxl73m2o_21UpoNekgBNAD6LrXi4icwq3QSVv7b3BXE_mHPkCyV8ddobSkHwVSQRU-1wVP3sD3rzpoDksIrYXDA4E/w400-h284/wotr_hunt_by_dice.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: Probabilities of a successful Hunt by number of dice</td></tr></tbody></table><br /><div>Now that we have the probabilities, there are a number of questions about possible choices in the game that we can answer. First, is it preferable to have another eye in the Hunt Box, or move a Nazgul in order to get a re-roll. In terms of a successful hunt, there's no difference between the two. However, an aspect of the rules we haven't covered here is that if an Eye Tile is drawn, then the Hunt Damage is equal to the number of successes rolled. Thus, we prefer to have eyes to a re-roll. However, we have to consider the cost and how each are obtained. The shadow player can assign eyes to the Hunt Box before the action die roll (with some limits), but may roll more. Shadow players should consider the possibility of getting more eyes than desired and leaving few actions. There are also cases when the Shadow player rolls fewer eyes than expected. In such times, it makes sense to use action dice to obtain one or more re-rolls. This is especially attractive if Nazgul were going to be moved anyways, and one can incidentally be placed with the Fellowship. At worse, this costs one action die (the same), as well as the position of one Nazgul. Army movement costs vary more. Some cases will have an army nearby the Fellowship (possibly with a Nazgul as well). Each army die allows two armies to move, so in some sense the cost is half of that of assigning an eye. However, this likely leaves the army in an otherwise undesirable position (even if it is just one unit), so half of an additional army movement would be needed to put it back into position. </div><div><br /></div><div>Another question, which the Free Peoples player may be faced with is whether it is better to move again this turn, or wait until next turn. There are a couple of considerations here. First, the distribution of the number of eyes rolls on the next turn, which also depends on a choice that the Shadow player has yet to make. We'll set this aside here, and focus on what the Free People's player expects. Let's say there are usually two eyes in the Hunt Box with no re-rolls. However, this turn there are four eyes. Using Figure 3, we can compare the probability of a successful hunt on the first move this turn with a second move on the next turn with two dice. We can see that a first move against four dice actually has a lower probability of success (though not by much). Thus, while moving against four dice sounds much worse, because of the diminishing returns of additional dice, it's not as bad as we may think.</div></div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-9170413323750351865.post-33118190517832184982020-09-14T14:30:00.002-07:002020-09-21T14:54:08.710-07:00Game length scaling by player count<p>That is, how to tell if the game box is lying by looking at the rules (it almost always is, but still...).</p><p>My basic framework here is that for many games, the length is simply the product of the number of turns and the amount of time taken per turn. This obviously doesn't work for games without turns, such as real-time games like Space Cadets Dice Duel. There also may be overhead that doesn't scale the same way, e.g. once per day activities in Robinson Crusoe, or once per round activities in Agricola.</p>
<p style="margin: 0px;">Many games are the same length to first order, independent of player count: Battlestar Galactica, Carcassonne, Pandemic, Kingdomino. These games have a roughly fixed number of total turns. Some of these may have strong second-order terms to affect game length, for example Pandemic, which tends to last more turns with more players as it's harder to get cards in a single hand. Other games could take more time per turn with more players due to group discussion, which may be play group dependent. These games can be identified by the fact that the there's some shared resources (e.g. cards or tiles) that advances the players towards the end (Battlestar Galactica, Pandemic), or ends the game when it runs out (Carcassonne, Kingdomino*).</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Let me expand my thoughts on Kingdomino. First, for 2-player I'm focused on the "Mighty Duel" 7x7 variant (which I've almost always played). This alone makes the 2 player and 4 player games take the same amount of time, at least to first order. If instead we looked at 2 player 5x5 games, we'd expect them to be roughly half the length of a 4 player game. Second, we should probably break up the two aspects of the game: selecting tiles and placing them. In Mighty Duel and 3-4 player games, all tiles/dominos are available to choose at some point. Also, each round three tiles are chosen, and the fourth is forced to whoever is left. Thus, this part of the game is the same whether there are 2, 3, or 4 players. The question is whether placing takes a different amount of time. Perhaps it's slightly different in a 3 player game, but I often think of it as incidental to your choice of tile in the next round (as it happens at the same time). I can see how 4 player games we may expect to take more time, but I don't think it'd be linear.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Many games are proportional to the number of players to first order: Ticket to Ride, Splendor, Agricola. These games have a roughly fixed number of turns per player. Some of these games (e.g. Agricola) are honest and state that the play time is a certain number of minutes per player. Others, like Ticket to Ride, do not. These games can be identified by an explicit number of rounds (Agricola), the end of the game triggered by a single player's resources depleting (Ticket to Ride), or games which are a race to a victory condition (Splendor).</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Sometimes, though, a game doesn't fit neatly into one of the above categories, as some elements are adjusted by player count. First, let's consider Bohnanza. There's a shared deck of cards and the game ends as soon as the players exhaust it three times (see more below). At first, we'd think that this would be a fixed length game, however things get more complicated when we consider the variant rules below, which allow the full 7 players.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Bohnanza, 45 minutes</p>
<p style="margin: 0px;">104 normal cards</p>
<p style="margin: 0px;">expansion: +50 cards: 154</p>
<p style="margin: 0px;">3 player: -4 cards: 150 cards</p>
<p style="margin: 0px;">4-5 players: -24 cards: 126 cards</p>
<p style="margin: 0px;">6-7 players: -4 -6 cards: 144 cards</p>
<p style="margin: 0px;">3 players: only two times through the deck. 3 bean fields</p>
<p style="margin: 0px;">4-7 players: 3 times, 2 bean fields</p>
<p style="margin: 0px;">new rules: flip 2 cards, draw 1 card per player per turn (original: draw three cards)</p><p style="margin: 0px;"><a href="https://www.riograndegames.com/wp-content/uploads/2013/02/Bohnanza-Rules.pdf">https://www.riograndegames.com/wp-content/uploads/2013/02/Bohnanza-Rules.pdf</a></p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">There are three things coming into play here. First, the number of cards in the deck varies with player count. Second, with 3 players you only go through the deck twice and each player has three bean fields instead of two. Third, the number of cards drawn per turn is a function of the number of players.</p><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Let's calculate the number of turns it takes to get through the deck the first time.</p>
<p style="margin: 0px;">3: 150 / (2+3) = 30</p>
<p style="margin: 0px;">4: 126 / (2+4) = 21</p>
<p style="margin: 0px;">5: 126 / (2+5) = 18</p>
<p style="margin: 0px;">6: 144 / (2+6) = 18</p>
<p style="margin: 0px;">7: 144 / (2+7) = 16</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">If subsequent times through deck has no card removal (almost certainly not true), then we can calculate the following number of total turns.</p>
<p style="margin: 0px;">3 players: 60 turns</p>
<p style="margin: 0px;">4 players: 63 turns</p>
<p style="margin: 0px;">5 players: 54 turns</p>
<p style="margin: 0px;">6 players: 54 turns</p>
<p style="margin: 0px;">7 players: 48 turns</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">Practically, each time through the deck actually takes much less time than the first. Some of this may just be as players get into the flow of the game, but there are two structural reasons as well. First, cards are essentially removed from play as they are sold and converted to coins. Second, a number of bean cards are still in players' fields as they go through the deck the second and third time. Let's look at the total number of bean fields in each player count.</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">3 players: 9 fields</p><p style="margin: 0px;">4 players: 8 fields</p><p style="margin: 0px;">5 players: 10 fields</p><p style="margin: 0px;">6 players: 12 fields</p><p style="margin: 0px;">7 players: 14 fields</p><p style="margin: 0px;"><br /></p><p style="margin: 0px;">This effect would further skew decrease the number of turns in large player count games relative to smaller player count games. However, with more players there are more possible negotiation considerations. It's more likely that there are multiple other players who have something you want, and similarly more likely that there are multiple players who want something you have. Three player games can go very quickly, as players get committed to what they are going for and you have more need to manage the large number of plantings you'll do. But in a 7 player game, your turn is much more rare, so trading is more important. While I do not have data to quantify it, I suspect that this at least equalizes the length of the game and probably even pushes larger player length games to be longer. If there's any data on this, it'd be interesting to see.</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">As another example, let's look at Century: Spice Road. Here what's interesting is that the game ends when one player gets a certain number of point cards, but that number depends on the number of players in the game.</p><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Century: Spice Road, 30-45 minutes</p>
<p style="margin: 0px;">2-3 players: 6 cards</p>
<p style="margin: 0px;">4-5 players: 5 cards</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">Thus, if each card takes "x" turns to obtain, then the relative game length is as follows.</p><p style="margin: 0px;">2 players: 12x</p>
<p style="margin: 0px;">3 players: 18x</p>
<p style="margin: 0px;">4 players: 20x</p>
<p style="margin: 0px;">5 players: 25x</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;">As we can see, we'd expect a 5 player game to take more than twice as long as a 2 player game. This ignores the fact that obtaining the 6th point card likely takes fewer turns than the first, as you've already built up an engine. This clearly indicates that the 30-45 minute ranges is incorrect, as the max range should be closer to twice the minimum.</p><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Some games get shorter with more players: Sushi Go Party, at least to first order, given negligible overhead for scoring more players, actually has fewer cards per player in higher player count games.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Sushi Go Party!</p>
<p style="margin: 0px;">2-3: 10 cards each</p>
<p style="margin: 0px;">4-5: 9 cards each</p>
<p style="margin: 0px;">6-7: 8 cards</p>
<p style="margin: 0px;">8: 7 cards</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There are a host of other considerations in game length that I haven't touched on here, many of which have clear implications as to whether they increase or decrease game length, but how to quantify that effect is less clear.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-82362525682646650562020-08-10T17:30:00.000-07:002020-08-10T17:30:01.064-07:00Why run for President in Battlestar Galactica?Because it's always better when you're in control.<br />
<br />
Let's say that it's in the first half of the game, before the sleeper agent phase. It's a 5-player game and you think that everyone is human. Someone else is President. Why would you want to spend the action and cards necessary to make yourself President instead? Because one of you might become a Cylon.<br />
<br />
Let's say all players are going to get one more loyalty card. So there are five cards, two of which are Cylon cards. The probability that one (or more) of you turns Cylon is $1 - P(\text{neither Cylon})$. $P(\text{neither Cylon}) = \frac{3}{5}\cdot\frac{2}{4}$. That is, one of you gets a human card ($3/5$), and then the other also gets one of the remaining human cards ($2/4$). Thus,<br />
\begin{align}<br />
P(\text{one or more of you become Cylon}) &= 1 - \frac{3}{5}\cdot\frac{2}{4} \\<br />
&= 1 - \frac{3}{10} \\<br />
&= 0.7.<br />
\end{align}<br />
<br />
Don't forget about the case where both of you end up as Cylons. Then resources are "wasted", and maybe you look suspicious. But maybe that's okay, because it's a good cover for depleted resources and allows you to stay hidden. But let's take this out, just assume that it's not valuable to switch here.<br />
<br />
\begin{align}<br />
\begin{split}<br />
P(\text{one of you become Cylon}) &= P(\text{one or more of you become Cylon}) \\ <br />
& \phantom{= } - P(\text{both of you become Cylon}) <br />
\end{split}\\<br />
\end{align}<br />
\begin{align}<br />
P(\text{one of you become Cylon}) &= 0.7 - \frac{2}{5}\cdot\frac{1}{4} \\<br />
&= 0.7 - 0.1 \\<br />
&= 0.6<br />
\end{align}<br />
Thus, it is more likely than not that you and the current President are going to end up on opposite teams, so you'd be better off having more power. The remaining question is whether or not you think the benefit is worth the cost.<br />
Let's assign this a shorter variable, $p_1$, for use later on.<br />
\begin{align}<br />
p_0 &= P(\text{one of you become Cylon}) \\<br />
&= 0.6.<br />
\end{align}<br />
<br />
I'll be honest in that I used to think it was inefficient to squabble about the Presidency unless you knew the President was a Cylon. But after a forum post about the importance of control in the game got me thinking about this case. It's interesting to me how the game is structured in this way that encourages loyal humans to do selfish things even without explicit personal goals (a la Dead of Winter). This is an interesting emergent property of the rules.<br />
<br />
We've considered the case when there aren't any Cylons out, now let's look at having one Cylon out before the sleeper agent phase. There are three sub-cases: you're the Cylon, the President is the Cylon, someone else is the Cylon. We've already tacitly assumed above that if you or the President is or becomes a Cylon, it's worth it to take the Presidency. So those cases are taken care of. If someone else is a Cylon, then we're similar to the above analysis, but with a smaller probability that one of you becomes a Cylon in the sleeper agent phase. In this case there is only one Cylon card out of 4 left. <br />
\begin{align}<br />
P(\text{one of you become a Cylon}) &= 1 - P(\text{both of you stay human}) \\<br />
&= 1 - \frac{4}{5}\cdot\frac{3}{4}\\<br />
&= 1 - \frac{3}{4} \\<br />
&= \frac{1}{4} = 0.25<br />
\end{align}<br />
Here the probability of one of you becoming a Cylon is much lower. One interesting case to consider here is if the existing Cylon gets the second Cylon loyalty card. In this case, the Cylon can then give this card to one of the humans. This is another opportunity for you or the current President to become a Cylon, and thus on opposite teams. Assuming this happens, and not knowing anything about the Cylon's strategy in selecting a target, there is a probability of $2/4 = 0.5$ that the Cylon selects you or the President out of the four humans. However, the President is arguably a higher-value target because of the powers of the office. For the rest of the analysis, we'll assume that a Cylon with two loyalty cards does give the second card away, with equal probability to all players. This increases the probability that one of you becomes a Cylon, $\Delta p = \Delta P(\text{one of you becomes a Cylon})$, is as follows.<br />
\begin{align}<br />
\Delta p &= P(\text{Cylon with two cards}) \cdot P(\text{Cylon gives card to one of you}) \\<br />
&= \frac{1}{5} \cdot \frac{2}{4} \\<br />
&= \frac{1}{10} = 0.1<br />
\end{align}<br />
Thus, our corrected probability for one of you becoming a Cylon is,<br />
\begin{align}<br />
P(\text{one of you become a Cylon}) &= 0.25 + 0.1 \\<br />
&= 0.35.<br />
\end{align}<br />
As before, let's assign this a shorter variable, $p_1$, for use later on.<br />
\begin{align}<br />
p_1 &= P(\text{one of you become a Cylon}) \\<br />
&= 0.35.<br />
\end{align}<br />
<br />
Now, let's consider the case when two Cylons are out, which I'd argue doesn't depend on when in the game it occurs. (I choose my words carefully here. I would argue this if pressed, but I'm not going to because I'm lazy.) There are four sub-cases: you are a Cylon, the President is a Cylon, both of you are Cylons, neither of you are Cylons. In the first two cases, it makes sense to get the Presidency, as you and the President are on opposite teams. If neither of you are Cylons, it doesn't make sense (unless the President isn't using the office well). If both of you are Cylons, I'd say in general it doesn't make sense, unless the President is already suspected and you can keep the office on your team by taking it.<br />
<br />
What is the confidence (i.e. assessed probability) you must have that a third party is a Cylon to make it not worth while to go for the presidency? As a break-even point we could assign a probability of 0.5. A better approach would be to have values assigned for the benefit of taking the presidency from the opposing team as well as the cost of moving the presidency. Determining those values is beyond the scope of this analysis, so we'll stick with a probability threshold of 0.5, meaning we're looking for the point at which it's more likely than not that you have incentive to take the presidency. This critical point occurs according the following equation.<br />
\begin{align}<br />
0.5 &= p_0 \cdot P(\text{no Cylons}) + p_1 \cdot P(\text{one Cylon}) + 0 \cdot P(\text{two Cylons})\\<br />
&= 0.6 \cdot P(\text{no Cylons}) + 0.35 \cdot P(\text{one Cylon})<br />
\end{align}<br />
I included the two Cylon case to point out that the no and one Cylon cases are not the only possibilities. There's no $1-p$ type tricks here in general. Now, if we do assume that there is at most one other Cylon, then we condition becomes easier to conceptualize. Then it simplifies as follows.<br />
\begin{align}<br />
0.5 &= 0.6 \cdot (1 - P(\text{one Cylon})) + 0.35 \cdot P(\text{one Cylon}) \\<br />
&= 0.6 + (-0.6 + 0.35) \cdot P(\text{one Cylon}) \\<br />
&= 0.6 + -0.25 \cdot P(\text{one Cylon}) \\<br />
P(\text{one Cylon}) &= \frac{0.6-0.5}{0.25} \\<br />
&= 0.4<br />
\end{align}<br />
Here, as long as we believe the probability of one Cylon is 0.4 or less (and the probability of two is zero), then we're more likely than not to end up and opposite teams as the President, even though we are both presently human, and thus have reason to take it.<br />
<br />
As a reference it may be useful to know the probability of each of those cases (and the previous cases we've considered). If you have a human card, and you're sure that the President is also human, you know there are two Cylon cards and six human cards left. Three of those cards have been dealt, while five remain for later. <br />
\begin{align}<br />
P(\text{all humans}) &= \frac{6}{8} \cdot \frac{5}{7} \cdot \frac{4}{6} \approx 0.357 \\<br />
P(\text{one cylon}) &= \frac{6}{8} \cdot \frac{5}{7} \cdot \frac{2}{6} \cdot\underbrace{3}_{{\text{3 ways to assign Cylon}}} \approx 0.536 \\<br />
P(\text{two cylons}) &= \frac{6}{8} \cdot \frac{2}{7} \cdot \frac{1}{6} \cdot (\text{3 choose 2 ways to assign cylons) }\\<br />
& = \frac{6}{8} \cdot \frac{2}{7} \cdot \frac{1}{6} \cdot \underbrace{3}_{= \frac{3!}{2! \cdot 1!}} \approx 0.107<br />
\end{align}<br />
Check, does that add up to one? Yes. We can combine this to find the probability that you and the President will end up on opposite teams, given that you start off as human (without any assumptions about the other players.<br />
\begin{align}<br />
p &= p_0 \cdot P(\text{no Cylons}) + p_1 \cdot P(\text{one Cylon}) + 0 \cdot P(\text{two Cylons})\\<br />
&\approx 0.6 \cdot 0.357 + 0.35 \cdot 0.536 + 0 \cdot 0.107 \\<br />
p&\approx0.402<br />
\end{align}<br />
Thus, without any information pertaining to the loyalty of the other players, you're more likely than not to stay on the same team as the President. However, perhaps counter-intuitively, if you feel you can trust everyone, you're more incentivized to go for the presidency yourself.<br />
<br />
And what if you're not certain that the President is human? What if all you know is that you're human. Given that, there's a probability of $P(HH|H) = 7/9$ that the President is human with a probability of $P(CH|H) = 7/9$ that is a Cylon with probability $2/9$. Here $P(HH|H)$ refers to the probability that both the President and you are human given that you are human. Similarly, $P(CH|H)$ is the probability that the President is Cylon (now) and you are human (now) given that you are human (now). We can express the probability that you and the President end up on opposite teams given that you are human, $P(O|H)$ as follows. Here $O$ refers to the event that you and the President end up on opposite teams. We're still focusing on opposite teams, and ignoring possible benefits to the Cylons if resources are expended moving the presidency.<br />
\begin{align}<br />
P(O | H) = P(O | HH) \cdot P(HH | H) + P(O | CH) \cdot P(CH | H)<br />
\end{align}<br />
We previously computed $P(O|HH)$, which is the $p$ immediately above. <br />
<br />
Now let's find $P(O|CH)$, the probability that you and the President end up on opposite teams given that the President is a Cylon before the sleeper agent phase while you are human. There are similar cases to before. There are two ways that the two of you can remain on opposite teams. First, another player can receive the remaining Cylon card. Since there are five players and five loyalty card, only one of which is Cylon, everyone has the same probability of receiving the Cylon card. Thus, another player receives the Cylon card with probability $3/5$. Second, the President can receive the Cylon card (probability $1/5$) and give it to another player aside from you. Assuming the President gives it out randomly, the probability that this happens and you remain human is $\frac{1}{5}\cdot\frac{3}{4}$.<br />
\begin{align}<br />
P(O|CH) &= \frac{3}{5} + \frac{1}{5}\cdot\frac{3}{4} \\<br />
&=\frac{12+3}{20}\\<br />
&=0.75<br />
\end{align}<br />
Pulling everything together, we get the following.<br />
\begin{align}<br />
P(O | H) &\approx 0.402 \cdot \frac{7}{9} + 0.75 \cdot \frac{2}{9}\\<br />
&\approx 0.479<br />
\end{align}<br />
<br />
This is much closer to 0.5, but still less. So given that you're human before the sleeper agent phase, you're just slightly more likely than not to end up on the same side as the president, given all of the assumptions that we've made. However, once you get some information about how the other people are playing, you can throw out most of the probabilities regarding the current state of the game, and only pay attention to those that affect the future of the game. Individual behavior can be much more revealing than statistics.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-14129639505109279412020-08-03T14:30:00.002-07:002020-08-06T06:58:20.041-07:00Is it possible an event is never drawn?<p style="margin: 0px;"></p><blockquote><p style="margin: 0px;">A deck of cards with values in a 2d3 distribution (so a single card with a value of 2, two value 3 cards, etc) and a 10th reshuffle card. On a reshuffle card, draw a replacement card, until you get a value (ie not the reshuffle) card. I was going to add another card that has a specific in-game event, and was trying to work out how likely it was that card would appear before the game ends (about 50 draws, not tied to the cards): I think it is possible, albeit unlikely, that it may not appear to all (although the longer the game goes on, the less likely that is, from my understanding of probabilities).</p>
<p style="margin: 0px;">â€”paraphrased from <a href="https://boardgamegeek.com/thread/869326/article/35403786#35403786">here on BGG</a></p></blockquote><p style="margin: 0px;"></p>
<p style="margin: 0px;">This can be solved with a <a href="https://en.wikipedia.org/wiki/Markov_chain">Markov chain</a>, which is a way to model sequences of probabilistic events, where the probabilities involved can be expressed in terms of the state after the previous step in the sequence. In this case, the state represents what's still in the deck. We'll have a different state for each possible number of cards remaining in the deck 11 (only possible before first turn), 10, 9, ..., and 1. The last we'll use as a special state, primarily not to denote when one card is left, but the fact that an event has been drawn. For simplicity, I'll not keep track of how many events have occurred (although we could expand to include that).</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">So we need a vector representing the probabilities of the initial state, which is known to be 11 cards, so the state vector, $\mathbf{s}$.</p>
\begin{align}
\mathbf{s} =
\begin{bmatrix}
1\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0
\end{bmatrix}
\end{align}
<p style="margin: 0px;">Here each subsequent entry in the vector represents a different state, and the values are the probabilities of being in each state.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We also need the transition matrix. That is, given a state, what are the probabilities of moving to another state. Consider when there are $c$ cards left. There are three or four relevant possibilities, depending on how you count. </p>
<p style="margin: 0px;"></p><ol style="text-align: left;"><li>You could draw a number card, leaving $c-1$ cards, which occurs with probability $(c-2)/c$. </li><li>You could draw a shuffle card (probability $1/c$, and then draw a number card (probability $9/10$, as we can ignore drawing the shuffle card again), leaving 10 cards with probability $1/c \cdot 9/10$. </li><li>You could draw an event card, with probability $1/c$, and end up in the special event state (by our reckoning).</li><li>You could draw a shuffle card (probability $1/c$) and then draw the event card (probability $1/10$), and end up in the special event state with probability $1/c \cdot 1/10$.</li></ol><p></p>
<p style="margin: 0px;">We can combine 3 & 4 to find the total probability of getting an event, which is $1/c + 1/c\cdot1/10 = 1/c \cdot 11/10$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">For the first round the probabilities are a little bit special, as we have 11 cards. Thus, the shuffle card doesn't do anything but delay the game. The two possible outcomes are draw a number card (probability $9/10$) and draw an event card (probability 1/10).</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Putting this together, we have the transition matrix, $\mathbf{P}$. Each column represents the initial state, and each row represents the next state, in both cases starting with 11 remaining cards, descending to 2, and ending with the special event state.</p>
<p style="margin: 0px;">\begin{align} \mathbf{P}& =
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\frac{9}{10} & \frac{9}{10}\cdot\frac{1}{10} & \frac{9}{10}\cdot\frac{1}{9} & \frac{9}{10}\cdot\frac{1}{8} & \frac{9}{10}\cdot\frac{1}{7} & \frac{9}{10}\cdot\frac{1}{6} & \frac{9}{10}\cdot\frac{1}{5} & \frac{9}{10}\cdot\frac{1}{4} & \frac{9}{10}\cdot\frac{1}{3} & \frac{9}{10}\cdot\frac{1}{2} & 0 \\
0 & \frac{8}{10} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & \frac{7}{9} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & \frac{6}{8} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & \frac{5}{7} & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & \frac{4}{6} & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & \frac{3}{5} & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{2}{4} & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{3} & 0 & 0 \\
\frac{1}{10} & \frac{11}{10}\cdot\frac{1}{10} & \frac{11}{10}\cdot\frac{1}{9} & \frac{11}{10}\cdot\frac{1}{8} & \frac{11}{10}\cdot\frac{1}{7} & \frac{11}{10}\cdot\frac{1}{6} & \frac{11}{10}\cdot\frac{1}{5} & \frac{11}{10}\cdot\frac{1}{4} & \frac{11}{10}\cdot\frac{1}{3} & \frac{11}{10}\cdot\frac{1}{2} & 1 \\
\end{bmatrix}
\end{align}</p><p style="margin: 0px;">Note a check that we can do is that each column must sum to 1. That is, the probability of transitioning from one state to one of the states is 1. This is because all possible states are incorporated in the matrix.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">To find the probability of each state in round $r$, we just compute $P^r \cdot s$. I've done this for 1â€“100 rounds below. It's quite rare for a game of 50 rounds to have no events. Also note that after about 10 rounds we seem to have reached a stable condition, where the probabilities of being in each of the states isn't changing much (relative to total probability of not having had an event yet).</p>
<p style="margin: 0px;"><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3s_8qWnVVnGMkox09EsUjwa3OcrHevp4UrQ70gOV2aZ3O9NygbymHTDVL_pmxj_bKn4OzpvZYW1Qm8JDviqh4SMNYxNgx7p-23S5fKNccJ43FHMYIGlvOkf2aPYgk8uagm6rzm34KMnxc/s700/avoid_event.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3s_8qWnVVnGMkox09EsUjwa3OcrHevp4UrQ70gOV2aZ3O9NygbymHTDVL_pmxj_bKn4OzpvZYW1Qm8JDviqh4SMNYxNgx7p-23S5fKNccJ43FHMYIGlvOkf2aPYgk8uagm6rzm34KMnxc/w512-h365/avoid_event.png" width="512" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 1: Probabilities of having some and no events</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7we4YD4TB_gNyyga95QHvltAd70u0sGhyk76gzNiKwYM_JsUwoCvsfDF0n7yirub2m7chtAn_7ziYM-8_PzKvewoPZUojR2sX2RYFNehVwx_-cEgkEacDUwzDGOUBEHje-tX_hBzA0EVw/s700/avoid_event_semilogy.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7we4YD4TB_gNyyga95QHvltAd70u0sGhyk76gzNiKwYM_JsUwoCvsfDF0n7yirub2m7chtAn_7ziYM-8_PzKvewoPZUojR2sX2RYFNehVwx_-cEgkEacDUwzDGOUBEHje-tX_hBzA0EVw/w512-h365/avoid_event_semilogy.png" width="512" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 2: Probabilities of having no events, log scale</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">We can expand this solution to not only look at the probability of whether or not an event has occurred, but instead to look at the probability of an event in any given round. The most straightforward application of the previous method would be to (nearly) multiply the number of states by the number of events possible (i.e. the number of rounds). This keeps track of however many events that we may be interested in, just as we've kept track of the binary state of whether any events have occurred. However, this is very inefficient and quickly leads to very large matrices. Instead, we can take note of the fact that if we look at the current round, the only thing that affects whether we draw an event is whether it is still in the deck, not how many times we've drawn an event previously. Thus, we can merely (roughly) double the number of states, with about half corresponding to the cases where the event card is in still in the deck, and the rest corresponding to the cases where the event card has already been drawn. The first state is again one with 11 cards left, which is equivalent to the case when there is 1 card left. If one card is left, it must be the reshuffle card, which, when drawn at the beginning of the next round, then leaves 11 cards just as at the start of the game. The next 9 states are when 10â€“2 cards remain in the deck, including the event card. The final 9 states are when 10â€“2 cards are left in the deck, but the event card is not in the deck.</p>
<p style="margin: 0px;"><br /></p><p style="margin: 0px;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNevw0n2uqnv4RVE6JKj_mqfDkkjycaPKsm5ZkObMZ2ts_IoMiTUZUp_joFYLr3Z6TFQ4uktVyhvIQi6hz1NRBVyrjqFHmahef4kNq4RXG2PFqvzLrZjvz8U-9A-2b0CPJjf2LJIAQsZlT/s1201/matrix_image.PNG" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="488" data-original-width="1201" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNevw0n2uqnv4RVE6JKj_mqfDkkjycaPKsm5ZkObMZ2ts_IoMiTUZUp_joFYLr3Z6TFQ4uktVyhvIQi6hz1NRBVyrjqFHmahef4kNq4RXG2PFqvzLrZjvz8U-9A-2b0CPJjf2LJIAQsZlT/w512-h208/matrix_image.PNG" width="512" /></a></p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">The probabilities are much as before, except that we now broken up cases 3 & 4 from above, and we consider the transitions between the various number of possible cards left in the deck without the event card. The probability of decreasing by one card in the deck, both without the event card, is the probability of not drawing the reshuffle card, $(c-1)/c$. Also note that when there are two cards left there's a probability of $0.5$ that the reshuffle card remains. This is equivalent to the the initial state of having 11 cards, as previously mentioned, as is why the probability of moving from the two 2-card states to the 11-card state is $1/2$.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">From any of these states, we can compute the probability of drawing a card. This actually is equal to the sum of elements of the matrix we just constructed. We need to sum the elements which correspond to moving from a state with the event card in the deck to one without it. This includes the cases when the reshuffle card is drawn. To this we must add the cases when the event card is initially out of the deck, the reshuffle card is drawn, and finally the event card is drawn. That is, the 11th row all counts. We must also consider the $1/2$ probability that we go from 2 cards with event to 11 cards left, as this really represents drawing the event card and leaving only the reshuffle card in the deck. Using this we can construct a matrix, $\mathbf{G}$, with all of these probabilities are the elements, such that when we multiply it by any probabilistic state vector, we get the probability of drawing an event card from that state.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">Using these three we can find the probability of drawing an event in any round.</p>
\begin{align}
P(\text{event in round } r) = G P^r s
\end{align}
<p style="margin: 0px;">The result of this equation is plotted in Fig. 3. We see a perhaps somewhat unexpectedly consistent result that appears to be exactly equal to 0.1. But is it? Does this continue forever? We can certainly easily compute the probability for any practical number of rounds, and any deviation from exactly 0.1 in our computations appears to be due to computer rounding error. </p>
<p style="margin: 0px;"><br /></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXE8zOXfJSBNg2XoWp5MqJ2Imvu3EmD2CZG8xN47DzznlzSBZD8xCF-GDStrDLpnRvmPQRTsMGc-NvcB_clIL7o2v4MIwtD3MXoAcor0nu-WxP4xHLnx-La6728mqEu-83kSw27TB4EWD8/s700/avoid_event_p_event.png" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="500" data-original-width="700" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXE8zOXfJSBNg2XoWp5MqJ2Imvu3EmD2CZG8xN47DzznlzSBZD8xCF-GDStrDLpnRvmPQRTsMGc-NvcB_clIL7o2v4MIwtD3MXoAcor0nu-WxP4xHLnx-La6728mqEu-83kSw27TB4EWD8/w512-h365/avoid_event_p_event.png" width="512" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Figure 3: Probabilities of drawing an event in current round</td></tr></tbody></table><p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">So let's prove it. First, we'll quickly dispense with the simple case when there are 11 (or 1) cards left in the deck. Here we must end by drawing a non-reshuffle card, of which there are ten with only one being an event. Thus the probability of drawing an event given that there are 11 cards left is $1/10$.</p>
\begin{align}
P(\text{event} | C = 11) = 0.1
\end{align}
<p style="margin: 0px;">Note a slight change in notation here. After writing the above equation, it became obvious that the number of cards left is really a random variable, and hence the switch to a capital $C$. The rest of the cases rely on some observations about the relationship between having an event card in the deck and not when there are given number of cards, $c$, left in the deck. That is, given $C$, what is the probability that the event card is still in the deck?</p>
\begin{align}
P(\text{event in deck} | C = c) = ?
\end{align}
<p style="margin: 0px;">Let's consider how we get to having $c$ cards left at the beginning of a round. For this to happen, in the rounds immediately preceding the $11-c$ cards not in the deck must have been drawn. What is the probability of doing that while leaving the event card in the deck? Keep in mind that this is conditioned on not drawing the re-shuffle card in any of these rounds.</p>
\begin{align}
P(\text{draw value} | \text{don't shuffle}, C=c) = \frac{c-2}{c-1}
\end{align}
<p style="margin: 0px;">We need to multiply this term depending on the number of cards left.</p>
\begin{align}
P(\text{event in deck} | C = c) &= \prod_{i=11}^{c-1} \frac{i-2}{i-1} \\
\require{cancel}&= \frac{\cancel{9}}{10} \cdot \frac{\cancel{8}}{\cancel{9}} \cdot \frac{\cancel{7}}{\cancel{8}}\cdots \frac{\cancel{c}}{\cancel{c+1}} \frac{c-1}{\cancel{c}} \\
&= \frac{c-1}{10}
\end{align}
<p style="margin: 0px;">The probability of drawing an event depends on whether or not the event card is still in the deck. These probabilities largely follow from our initial analysis.</p>
\begin{align}
P(\text{event} | \text{event in deck}, C = c) &= \underbrace{\frac{1}{c}}_{{\text{draw event directly}}} + \underbrace{\frac{1}{c}\cdot\frac{1}{10}}_{{\text{draw reshuffle then event}}} \\
P(\text{event} | \text{event not in deck}, C = c) &= \underbrace{\frac{1}{c}\cdot\frac{1}{10}}_{{\text{draw reshuffle then event}}}
\end{align}
<p style="margin: 0px;">When the event is not in the deck, the only way to draw it again is to first draw the reshuffle. Putting these together we can find the following.</p>
\begin{multline}
P(\text{event in deck} ) = P(\text{event} | \text{event in deck}) \cdot P(\text{event in deck}) \\+ P(\text{event} | \text{event not in deck}) \cdot \left ( 1 - P(\text{event in deck} ) \right )
\end{multline}
<p style="margin: 0px;">In our case (conditioning on $C=c$), we can find what we're looking for.</p>
\begin{align}
P(\text{event in deck} | C = c) &= \left (\frac{1}{c} + \frac{1}{c}\cdot\frac{1}{10} \right ) \cdot \frac{c-1}{10} + \frac{1}{c}\cdot\frac{1}{10} \cdot \left ( 1 - \frac{c-1}{10} \right ) \\
&= \frac{1}{c} \cdot \frac{11}{10} \cdot \frac{c-1}{10} + \frac{1}{c} \cdot \frac{1}{10} \cdot \frac{11-c}{10} \\
\require{cancel}&= \frac{11\cancel{c}}{100\cancel{c}} - \cancel{\frac{11}{100c}} + \cancel{\frac{11}{100c}} - \frac{\cancel{c}}{100\cancel{c}} \\
&=\frac{11}{100} - \frac{1}{100} \\
&= \frac{10}{100} \\
&= \frac{1}{10}
\end{align}
<p style="margin: 0px;">Here we see that, indeed, regardless of how many cards there are in the deck, the probability of drawing an event always works out to be exactly 0.1. Here two effects exactly cancel each other out. On the one hand, when there are fewer cards, it's more likely to draw an event card that is still in the deck. On the other hand, with fewer cards it's less likely that there the event card still is in the deck.</p>
<p style="margin: 0px;"><br /></p>
<p style="margin: 0px;">There is yet a simpler way to see that the probability of drawing an event every round is 0.1. Consider the symmetry of the situation. Every round ends with a non-reshuffle card being drawn. There is no difference in the 10 non-reshuffle cards that impacts the probability of them being drawn. Therefore, the probability that each is drawn in any round must be 0.1. You may ask whether drawing the event card affects the probability of it being drawn in a subsequent round. It does; that effect shows up in certain conditional probabilities.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-85320013065481250572020-07-27T17:30:00.000-07:002020-07-27T17:30:01.985-07:00What is the best weapon in D&D?There's something interesting about the damage progression for the Monk class in D&D 3.5. For a Medium sized Monk, the damage progression is as shown in Table 1 (source: SRD <a href="http://www.d20srd.org/srd/classes/monk.htm">http://www.d20srd.org/srd/classes/monk.htm</a>).<br />
<br />
\begin{align*}<br />
\begin{array}{c|c}<br />
\text{Level} & \text{Damage Dice} \\ \hline<br />
\text{1--3} & 1d6 \\<br />
\text{4--7} & 1d8 \\<br />
\text{8--11} & 1d10 \\<br />
\text{12--15} & 2d6 \\<br />
\text{16--19} & 2d8 \\<br />
\text{20} & 2d10 <br />
\end{array}<br />
\end{align*}<br />
<div style="text-align: center;">
Table 1: Monk Damage Progression in D&D 3.5</div>
<br />
For levels 1â€“11 things are pretty clear. Each time the damage dice increase it's strictly better. However, that's not true when moving from 1d10 to 2d6. Certainly, the minimum and maximum are both higher for 2d6 (2 and 12, respectively, as opposed to 1 and 10 for 1d10). The average is also better: 7 versus 5.5. But often we don't care about such metrics. For example, say our Monk is fighting some opponents that each have 5 hit points each. In such as case, we'd like to take them out in one hit as often as possible. Thus, the probability of rolling 5 or higher is of particular interest.<br />
<br />
To consider the general case, let's look at the probabilities of rolling a given number or higher for each of the two damage rolls, as shown in Table 2.<br />
\begin{align*}<br />
\begin{array}{ccc}<br />
x & P(1d10 \geq x) & P(2d6 \geq x) \\ \hline<br />
1 & 1 & 1 \\<br />
2 & 0.9 & 1 \\<br />
3 & 0.8 & 0.972 \\<br />
4 & 0.7 & 0.917 \\<br />
5 & 0.6 & 0.833 \\<br />
6 & 0.5 & 0.722 \\<br />
7 & 0.4 & 0.583 \\<br />
8 & 0.3 & 0.417 \\<br />
9 & 0.2 & 0.278 \\<br />
10 & 0.1 & 0.167 \\<br />
11 & 0 & 0.0833 \\<br />
12 & 0 & 0.0278 <br />
\end{array}<br />
\end{align*}<br />
<div style="text-align: center;">
Table 2: Monk Damage Probabilities at Levels 11 & 12</div>
<br />
This is actually strictly better. But it makes you wonder whether there are cases where it looks like something is better, but it's actually worse. If we had looked at the pmf for 1d10 vs 2d6 we might have been misled, because at 10, 2d6 looks worse (lower probability of getting a 10), even though it is strictly better when considering the probability of rolling 10 or higher.<br />
<br />
So let's change the question to be about the best weapon. There are many different weapons in Dungeons and Dragons. Even just looking at the 5th edition Player Basic Rules download, there is almost a full page table on page 47. Weapons differ in cost, dice rolled for damage, type of damage dealt, weight, and properties such as whether it is thrown, requires two-hands to use, etc..<br />
<br />
To contain the discussion, let's first just focus on which does the most damage. A lot of the other characteristics of the weapon matter in very context-specific ways. Glancing through the table it's pretty easy to narrow down the list into two potential groups. Those weapons which do 1d12 damage (e.g. a greataxe), and those which do 2d6 damage (i.e. a maul). Both can do up to 12 damage. The maul always does at least 2 damage, so that's better. What about average damage? The average roll for a dN is $(N+1)/2$. This means the average greataxe damage is 6.5, while the average maul damage is 7.<br />
<br />
Let's compare the distributions. We've already computed 2d6 for <a href="https://www.quantifyingstrategy.com/2020/04/whats-up-with-dots-on-number-discs-in.html">something else</a>. 1d12 is pretty simple, $1/12$ for every possibility. Fig. 1 shows the probability mass functions (PMFs), while Fig. 2 shows the cumulative distribution functions (CDFs). We see some cases in which 2d6 is better, while in some cases 1d12 is better. Look at rolling at least a specific number, that's what matters, which is close to the complementary cumulative distribution function (CCDF), which is plotted in Fig. 3. Here we see that the probability of rolling towards the higher end of the damage distribution with a greataxe is greater than with a maul. Consider just the probability of rolling 12 or higher. With a greataxe the probability is $1/12$, with a maul it's $1/36$.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8ekP2yH_lQqbeD4aqZcPe0Oonm74kTxf5RgD3md9HTZoylPcBmq2IBOudIDB-xfy78IrKbfBx_EWAxuhjghnWF87qoTyYsWJM_kZRoEdHHBe_XiilfVjHixaKrVQKSJ8XbSCV9RiXV65r/s1600/dnd_weapon_pmf.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8ekP2yH_lQqbeD4aqZcPe0Oonm74kTxf5RgD3md9HTZoylPcBmq2IBOudIDB-xfy78IrKbfBx_EWAxuhjghnWF87qoTyYsWJM_kZRoEdHHBe_XiilfVjHixaKrVQKSJ8XbSCV9RiXV65r/s400/dnd_weapon_pmf.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 1: Damage PMF of Greataxe and Maul </td></tr>
</tbody></table>
<br />
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXK2EsFXmSAylfKDvSmDzslPD8gtXX4ioWnO7EBJTxX_kUWUzeeKM_7shuyzy2FsGtBCpecytyL2RHEymm1udC7eClcaYR1sY6aDtyulOK3P5cYS5dETFw-V2fT3KQJ_dNtZx8U89FJBlo/s1600/dnd_weapon_cdf.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXK2EsFXmSAylfKDvSmDzslPD8gtXX4ioWnO7EBJTxX_kUWUzeeKM_7shuyzy2FsGtBCpecytyL2RHEymm1udC7eClcaYR1sY6aDtyulOK3P5cYS5dETFw-V2fT3KQJ_dNtZx8U89FJBlo/s400/dnd_weapon_cdf.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 2: Damage CDF of Greataxe and Maul</td></tr>
</tbody></table>
<div style="text-align: start;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJCwcbgIc0-2jKzuQfdKZ0o-9-nBXTMlpLlrMT18J6PehZBqLBPrQm_ozFIngsOeUwt1SyrWBgrBNAjF-REH-mNC0PSGqFVhGCZlCbKul_C5kF7AcBTkR8XDz3DL4icC4KmB9Kxmsh31KK/s1600/dnd_weapon_ccdf.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJCwcbgIc0-2jKzuQfdKZ0o-9-nBXTMlpLlrMT18J6PehZBqLBPrQm_ozFIngsOeUwt1SyrWBgrBNAjF-REH-mNC0PSGqFVhGCZlCbKul_C5kF7AcBTkR8XDz3DL4icC4KmB9Kxmsh31KK/s400/dnd_weapon_ccdf.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">Figure 3: Damage CCDF of Greataxe and Maul</td></tr>
</tbody></table>
Now let's consider enemies with different number of hit points. We'll look at three possibilities: a goblin with 7 HP, a hobgoblin with 11 HP, and a bugbear with 27 HP. We can find the probability of eliminating each of these enemies in a single round by evaluating the CCDF at one less than the number of HP. This is impossible for the bugbear, as there's no way to roll 27 damage in a single attack with these weapons (Note: throughout this analysis I'm ignoring any bonuses that may increase the damage. I'm also ignoring whether or not you actually hit first). For the goblin, looking at the CCDF at 6, we see that the maul has a higher probability of being eliminated in a single round. For the hobgoblin we get the opposite result. The CCDF at 10 is higher for the greataxe.<br />
<br />
Looking at just the probability of elimination in the first round is a small part of the analysis. Next, we'll look at the distribution of the the round in which the target is eliminated, $R$. To determine this, we need a straightforward way to check whether or not we've eliminated a target in a given round. In this case, I found it easier to look at the CDF of elimination, that is, the probability that the target is eliminated <i>by</i> a certain round of combat. In round $r$, we've rolled damage for each weapon $r$ times. If the damage if at least equal to the target's HP, then it must have been eliminated by round $r$. We previously learned how to use convolution to compute the PMF of rolling multiple dice. We can apply this iteratively to get the PMF of rolling $r$d12 for a greataxe or $2r$d6 for a maul in total by round $r$. Performing the running sum to get the CDF from the PMF is straightforward. Then the CDF of the round of elimination, $F_R(r)$, is given by,<br />
\begin{align}<br />
F_R(r) = 1 - F_{D(r)}(h-1) ,<br />
\end{align}<br />
where $D(r)$ is the total damage by the relevant weapon by round $r$ and $h$ is the number of hit-points of the target. Running through the computations for our selected targets we get the plots in Figures 4, 5, and 6. We can see that the maul is almost universally better. The two exception points are the aforementioned eliminating a hobgoblin in 1 round, as well as the probability of eliminating a bugbear in 3 rounds.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihMBJ9kPWUvhTsluPuei8kEt2RSYrnv3ruGLcPwvPLs9YO94AQs97sekcRaTXTqgOyxlWhES1BxvlyMiC2ezoMdsKKXBLUKtbhSLC3PjOlc6ou8meFejDEjLkxckfAiHUkym68Qy-isGQZ/s1600/dnd_weapon_goblin.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" data-original-height="498" data-original-width="700" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihMBJ9kPWUvhTsluPuei8kEt2RSYrnv3ruGLcPwvPLs9YO94AQs97sekcRaTXTqgOyxlWhES1BxvlyMiC2ezoMdsKKXBLUKtbhSLC3PjOlc6ou8meFejDEjLkxckfAiHUkym68Qy-isGQZ/s400/dnd_weapon_goblin.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 4: Probabilities of eliminating a goblin by a given round </td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxyVmxnsKwgwogkH_1ZPjMlsS5GZZ3zP1meJ9aG2azGCBxwTE0kJzumZPrUsJv9CEP4Zou5ECdOmjc-d9rDHmNGBrCvNx9j_yF060u850qxoSswTM2sXvVZOCb7Cf0QeOm7BgV9U5jNMHj/s1600/dnd_weapon_hobgoblin.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxyVmxnsKwgwogkH_1ZPjMlsS5GZZ3zP1meJ9aG2azGCBxwTE0kJzumZPrUsJv9CEP4Zou5ECdOmjc-d9rDHmNGBrCvNx9j_yF060u850qxoSswTM2sXvVZOCb7Cf0QeOm7BgV9U5jNMHj/s400/dnd_weapon_hobgoblin.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 5: Probabilities of eliminating a hobgoblin by a given round</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2SwnV0nKvGhJYCxctoyA4Qd3ESB0A-5n-OQe9Dk2h2UwuZeLeIbC4K6e5SoLxK713sA268LMvo7RXvSrIOqfXwIX7JPlYfYYQF7oljViEtfFbVLOrjv5T4EJlpAY6kLq-Au0HghCT42Qf/s1600/dnd_weapon_bugbear.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2SwnV0nKvGhJYCxctoyA4Qd3ESB0A-5n-OQe9Dk2h2UwuZeLeIbC4K6e5SoLxK713sA268LMvo7RXvSrIOqfXwIX7JPlYfYYQF7oljViEtfFbVLOrjv5T4EJlpAY6kLq-Au0HghCT42Qf/s400/dnd_weapon_bugbear.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 6: Probabilities of eliminating a bugbearby a given round</td></tr>
</tbody></table>
While we risk the danger of the reductionism we saw earlier in looking at the average damage per roll for each of the two weapons, and noting that perhaps the result is obvious given the above distributions, there remains some allure in combining the above information into a single metric with which we can compare the two weapons and declare which is the best definitively, if not correctly. To accordance with this, we'll compute the expected value of the number of rounds to eliminate a target, $\mathbb{E}R$. We'll do this not just for the selected targets, but for a wide range of hit points, from 1 to 1000 (I did not compute every point in between, and started log spacing after 20 hit points to save time). To do this, two steps are required. First, we must find the CDF for each hit-point valued target. Second, we recall and use the following relationship to calculate the expected value.<br />
\begin{align}<br />
\mathbb{E} R &= \sum_{r=0}^\infty P(R > r) \\<br />
&= \sum_{r=0}^\infty 1 - F_R(r)<br />
\end{align}<br />
We can combine this with our earlier equation for $F_R(r)$ to come up with a simpler expressoin based on the CDF of the total damage up through round $r$.<br />
\begin{align}<br />
\mathbb{E} R &= \sum_{r=0}^\infty 1 - (1 - F_{D(r)}(h-1) ) \\<br />
& = \sum_{r=0}^\infty F_{D(r)}(h-1) \\<br />
\end{align}<br />
While the above sum is shown over an infinite range, we know that it is limited. In the case of the greataxe, since we do at least 1 damage per round, we need only consider up to $h$ rounds. Similarly, for the maul, which does at least 2 damage per round, we need only consider up to $\lfloor \frac{h}{2} \rfloor$ rounds. The results are plotted in Fig. 7. While it's hard to see for low values of the target's HP, it clearly shows that the maul requires fewer rounds, on average, for any number of hit points.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPlYlSXLPXsdIe-a2h16MSgPCbCEsvTQQRs2ED0sZZS65a8m-vWnA_TsaYm3265nYRd_339_y5N50w56Lq7XLrr2orHdquDO8eYOS87LCRyKdSSgvG_Vsl_DJ9WeWS22e6to9jPsVGxlY/s1600/dnd_weapon_e_rounds.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPlYlSXLPXsdIe-a2h16MSgPCbCEsvTQQRs2ED0sZZS65a8m-vWnA_TsaYm3265nYRd_339_y5N50w56Lq7XLrr2orHdquDO8eYOS87LCRyKdSSgvG_Vsl_DJ9WeWS22e6to9jPsVGxlY/s400/dnd_weapon_e_rounds.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 7: Expected number of rounds to eliminate a target vs. hit points</td></tr>
</tbody></table>
<br />
One might propose the following argument to approximate the number of rounds expected for elimination. Since we know the average damage per roll, all we must do is to take the target's HP and divide by this average damage to find the expected number of rounds to elimination. To aid in discussion of this thought, consider the plot in Fig. 8, which shows the expected number of rounds to elimination per target HP. Also plotted are asymptotes, which are equal to one divided by the average damage per round. That is, if this argument were true, the plot would coincide with these dotted lines. It is not true, and thus they do not coincide. However, they do seem to predict values which the curves are approaching asymptotically, as emphasized in Fig. 9. For a small number of hit points, the non-linear impacts of needing to roll a whole number of attacks means that the inverse of the average is a poor estimate. For example, to eliminate a target with only 1 HP, at 1 round is always needed. An attempt to incorporate this is shown in Fig. 10, which shows estimates of the $R$ per HP, by estimating $R$ as HP divided by the average damage per round, rounding up to the nearest integer number of rounds, and then dividing by HP. We can see that this shows a similar shape, but has discontinuities at various points, corresponding to when the number of rounds is rounded up to the next integer value. If we consider a target like the hobgoblin with 11 HP, there are a number of possible rounds of elimination. To determine $\mathbb{E}R$, first the distribution of $R$ is considered and then averaging is done. The plot in Fig. 10 averages first, and then tries to come up with the number of rounds. Since there is essentially non-linearity involved, we cannot change the order of the averaging without introducing error. The nonlinearity I'm talking about is this: in the round of elimination there may be some excess damage done. Going into that around you may only need to do 3 more points of damage, but it's likely that more damage will be done. Thus, this damage, while it contributes to the average damage per round, does not affect the number of rounds until elimination. As the number of hit points that a target has increases, this excess damage becomes less and less of an impact, which is why the plots approach the asymptotes. Across these plots we see that the maul is universally better than the greataxe.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiHU4xbZfbfMAxCeATobUsE99l9A9K05Rwjqxc1oqR-kgvk2HBQPFOW8kINVVLbSwUFXDqwJcCjhYSdcZq-7wxjUTAqE7pZmSLn1bwn5NDFAXaCdpjjet6GIG0rpWmuYvAFJBQfKim_oRW/s1600/dnd_weapon_e_rounds_per_hp.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiHU4xbZfbfMAxCeATobUsE99l9A9K05Rwjqxc1oqR-kgvk2HBQPFOW8kINVVLbSwUFXDqwJcCjhYSdcZq-7wxjUTAqE7pZmSLn1bwn5NDFAXaCdpjjet6GIG0rpWmuYvAFJBQfKim_oRW/s400/dnd_weapon_e_rounds_per_hp.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 8: Expected number of rounds per hit-point to eliminate a target vs. hit points </td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5yFMpwiemUXP09-kGYM4kp-CMvgx5qxxj0qbHJDaSXhRnoWVI0HMR14JxnCepeZwaevsk8Vr0L65OuuRVQL2gpdSTltuxtnSsN9R7vPgztbGZMZKWiyeLugu4cRjABycFQL4smnRqB7-U/s1600/dnd_weapon_e_rounds_per_hp_zoom.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5yFMpwiemUXP09-kGYM4kp-CMvgx5qxxj0qbHJDaSXhRnoWVI0HMR14JxnCepeZwaevsk8Vr0L65OuuRVQL2gpdSTltuxtnSsN9R7vPgztbGZMZKWiyeLugu4cRjABycFQL4smnRqB7-U/s400/dnd_weapon_e_rounds_per_hp_zoom.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 9: Expected number of rounds per hit-point to eliminate a target vs. hit points (zoomed in)</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2oi5n16l__1rIjH5I7-HyMFm9BfJTfeoJJGKZ_YGEAm2UW9us6IBXY81nk5fyyW-Ld3SE35wbzKKDZFvjKtgkwPYpwhPoA7ZJ5B-GTw2q0tbu08OMJi9Y0krHn47nJJly2HKaGOcWUg-E/s1600/dnd_weapon_e_rounds_per_hp2.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2oi5n16l__1rIjH5I7-HyMFm9BfJTfeoJJGKZ_YGEAm2UW9us6IBXY81nk5fyyW-Ld3SE35wbzKKDZFvjKtgkwPYpwhPoA7ZJ5B-GTw2q0tbu08OMJi9Y0krHn47nJJly2HKaGOcWUg-E/s400/dnd_weapon_e_rounds_per_hp2.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 10: Expected number of rounds per hit-point to eliminate a target vs. hit points compared to a crude estimate\label</td></tr>
</tbody></table>
<br />
That was a little disappointing. I was really expecting to find some scenarios where the greataxe is better. Sure, if we really need to eliminate a hobgoblin in 1 round it's better, but that's too specific to satisfy me. The consistency provided by rolling 2d6 just seems to overpower the slightly better chance of a high roll on 1d12. So what if we compare against something that we might expect to be worse. What if we compare 1d12 to 2d4? When we look at the same comparison, shown in Fig. 11, we see that for target HP less than 5, rolling 2d4 results in a faster expected elimination. Here, the higher minimum appears to prevail over the lower average damage, the latter of which wins for large target HP.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi84AK0j-f7mPDb75u7I60EJFReAEg4SdSbMcA3bfiU4sNAS0505gp-2JnwgkwKZnORLuc7T7cnn59gC4iB3fhvxgwJo4iojKv_OQo00F2fhNoPAbNWPGok3q_-XAClFwxzAnjqGG12xQk/s1600/dnd_weapon_e_rounds_per_hp3.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" data-original-height="498" data-original-width="700" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi84AK0j-f7mPDb75u7I60EJFReAEg4SdSbMcA3bfiU4sNAS0505gp-2JnwgkwKZnORLuc7T7cnn59gC4iB3fhvxgwJo4iojKv_OQo00F2fhNoPAbNWPGok3q_-XAClFwxzAnjqGG12xQk/s400/dnd_weapon_e_rounds_per_hp3.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 11: $\mathbb{E}R$ for 1d12 and 2d4</td></tr>
</tbody></table>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-52441224734892636232020-07-06T17:30:00.000-07:002020-07-06T17:30:02.293-07:00Modeling value in Century: Spice RoadWhen playing Century: Spice Road (or the Golem Edition, I imagine), it's easy to notice some patterns in the values of the cards. <br />
<br />
The Merchant cards are less clear, so let me push them aside first. Not all Merchant cards are equal. Some comparisons are hard to make and depend a lot on the situation. For example, is it better to have a card that transforms 2 saffron (red) into 2 cardamom (green), or 3 saffron into 3 cardamom? If you only have two saffron, the first may be better. With three it's likely the latter. With four saffron we're back to likely preferring the first, as we can perform the trade twice. That is, unless we only need three cardamom and need to hold onto a saffron. You could perhaps come up with some metric that attempts to incorporate all of these types of considerations. However, there's a clear counter example. There's one Merchant card that gives you three turmeric (yellow) and another that gives you four. The latter is strictly better than the first. Even if you can't always make use of the fourth turmeric, it is all that the first card is and more. This one example is all we need to show that Merchant cards are not all balanced.<br />
<br />
Now let's look at the Point cards. <br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5aG98XPhh6wpKHOKAvAZtXChWCPijrEwqAeghdN4F1fJzgYE1ZycYmLV6xg_Rs1XiYi818_LUimSUumabbX9ck26vJ5zQ7gaJYtr2fqM2c5qeDxyDh1mX2ZKZ-WLdTMQluInW1O-gdEqD/s1600/century_cards_simple.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="564" data-original-width="1378" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5aG98XPhh6wpKHOKAvAZtXChWCPijrEwqAeghdN4F1fJzgYE1ZycYmLV6xg_Rs1XiYi818_LUimSUumabbX9ck26vJ5zQ7gaJYtr2fqM2c5qeDxyDh1mX2ZKZ-WLdTMQluInW1O-gdEqD/s400/century_cards_simple.PNG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 1: Points cards</td></tr>
</tbody></table>
<br />
The pattern I noticed when looking at a bunch of these is that it appears that the number of points, $p$, follows a simple formula based on the number of turmeric (yellow), $y$, saffron (red), $r$, cardamom (green), $g$, and cinnamon (brown), $b$.<br />
\begin{align}<br />
p = y + 2r + 3g + 4b<br />
\end{align}<br />
That is, the number of points is equal to one point for each turmeric, while each higher level of spice is worth one more point each. This tracks for a large number of the Point cards (24 out of 36). Then you run into a card like the following.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3oakQvI2RdIL2EkpLb5qTb9AaGinxxQC5EohMbblTJraq2cXX2zMWETI-ZD6a7DrhLN08m5XDpmlbQMTzhAnLnB0XQms5PjQ3UCowcCr6BXjJAvL0Dh7Mfd_-XhX72Q37BfsarzC2yhJU/s1600/century_cards_complex.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="562" data-original-width="338" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3oakQvI2RdIL2EkpLb5qTb9AaGinxxQC5EohMbblTJraq2cXX2zMWETI-ZD6a7DrhLN08m5XDpmlbQMTzhAnLnB0XQms5PjQ3UCowcCr6BXjJAvL0Dh7Mfd_-XhX72Q37BfsarzC2yhJU/s400/century_cards_complex.PNG" width="238" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure 2: Another Point card</td></tr>
</tbody></table>
<br />
Here we'd predict the card to be worth 12 points.<br />
\begin{align}<br />
12 = 1 \cdot 3 + 2 \cdot 1 + 4 \cdot 3 + 4 \cdot 1<br />
\end{align}<br />
However, it's worth two additional points. Why? If you look at <a href="https://boardgamegeek.com/filepage/156544/list-century-spice-road-cards-and-their-analysis">this spreadsheet</a>, posted by "GameSnake", it becomes quite clear what the pattern is. There's a column specifying the "Spice cost", matching our analysis up to this point, as well as a "Delta" column. This clearly shows that a Point card is worth an extra point if it requires three different types of spices to claim, and two extra points if it requires four different types of spices. This makes some sense, as it may be more difficult to produce a variety of different spices than just having a good combination to produce exclusively one or two. There's no difference between cards that require only one type of spice and cards that require two types of spice. So our revised equation becomes,<br />
\begin{align}<br />
p = y + 2r + 3g + 4b + \max(n-2, 0) ,<br />
\end{align}<br />
<br />
where $n$ is the number of distinct spices needed to claim the Point card. Note that $n$ is dependent on $y$, $r$, $g$, and $b$. We could write an equation without this intermediate variable, but it'd be quite a bit more cumbersome. This equation exactly predicts the value of every Point card in the game, which you can check against in Table 1.<br />
<br />
<table border="0" cellspacing="0">
<colgroup width="78"></colgroup>
<colgroup span="2" width="99"></colgroup>
<colgroup width="68"></colgroup>
<tbody>
<tr>
<td align="left" height="20" valign="bottom"><b><span style="color: black;"><br />Spices</span></b></td>
<td align="center" valign="bottom"><b><span style="color: black;">Victory points</span></b></td>
<td align="center" valign="bottom"><b><span style="color: black;">Spice cost</span></b></td>
<td align="center" valign="bottom"><b><span style="color: black;">Delta</span></b></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYRR</span></td>
<td align="center" sdnum="1033;" sdval="6" valign="bottom"><span style="color: black;">6</span></td>
<td align="center" sdnum="1033;" sdval="6" valign="bottom"><span style="color: black;">6</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYYRR</span></td>
<td align="center" sdnum="1033;" sdval="7" valign="bottom"><span style="color: black;">7</span></td>
<td align="center" sdnum="1033;" sdval="7" valign="bottom"><span style="color: black;">7</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRRR</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYGG</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYRRR</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYYGG</span></td>
<td align="center" sdnum="1033;" sdval="9" valign="bottom"><span style="color: black;">9</span></td>
<td align="center" sdnum="1033;" sdval="9" valign="bottom"><span style="color: black;">9</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRGG</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRRRR</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYBB</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYGGG</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYYBB</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">GGGG</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRBB</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRRGG</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRGGG</span></td>
<td align="center" sdnum="1033;" sdval="13" valign="bottom"><span style="color: black;">13</span></td>
<td align="center" sdnum="1033;" sdval="13" valign="bottom"><span style="color: black;">13</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">GGBB</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRRBB</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYBBB</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">GGGGG</span></td>
<td align="center" sdnum="1033;" sdval="15" valign="bottom"><span style="color: black;">15</span></td>
<td align="center" sdnum="1033;" sdval="15" valign="bottom"><span style="color: black;">15</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">BBBB</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRBBB</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">GGGBB</span></td>
<td align="center" sdnum="1033;" sdval="17" valign="bottom"><span style="color: black;">17</span></td>
<td align="center" sdnum="1033;" sdval="17" valign="bottom"><span style="color: black;">17</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">GGBBB</span></td>
<td align="center" sdnum="1033;" sdval="18" valign="bottom"><span style="color: black;">18</span></td>
<td align="center" sdnum="1033;" sdval="18" valign="bottom"><span style="color: black;">18</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">BBBBB</span></td>
<td align="center" sdnum="1033;" sdval="20" valign="bottom"><span style="color: black;">20</span></td>
<td align="center" sdnum="1033;" sdval="20" valign="bottom"><span style="color: black;">20</span></td>
<td align="center" sdnum="1033;" sdval="0" valign="bottom"><span style="color: black;">0</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYRB</span></td>
<td align="center" sdnum="1033;" sdval="9" valign="bottom"><span style="color: black;">9</span></td>
<td align="center" sdnum="1033;" sdval="8" valign="bottom"><span style="color: black;">8</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRGB</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YGGB</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="11" valign="bottom"><span style="color: black;">11</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYRRGG</span></td>
<td align="center" sdnum="1033;" sdval="13" valign="bottom"><span style="color: black;">13</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYRRBB</span></td>
<td align="center" sdnum="1033;" sdval="15" valign="bottom"><span style="color: black;">15</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYGGBB</span></td>
<td align="center" sdnum="1033;" sdval="17" valign="bottom"><span style="color: black;">17</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">RRGGBB</span></td>
<td align="center" sdnum="1033;" sdval="19" valign="bottom"><span style="color: black;">19</span></td>
<td align="center" sdnum="1033;" sdval="18" valign="bottom"><span style="color: black;">18</span></td>
<td align="center" sdnum="1033;" sdval="1" valign="bottom"><span style="color: black;">1</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YRGB</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="10" valign="bottom"><span style="color: black;">10</span></td>
<td align="center" sdnum="1033;" sdval="2" valign="bottom"><span style="color: black;">2</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YYYRGB</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="12" valign="bottom"><span style="color: black;">12</span></td>
<td align="center" sdnum="1033;" sdval="2" valign="bottom"><span style="color: black;">2</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YRRRGB</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="14" valign="bottom"><span style="color: black;">14</span></td>
<td align="center" sdnum="1033;" sdval="2" valign="bottom"><span style="color: black;">2</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YRGGGB</span></td>
<td align="center" sdnum="1033;" sdval="18" valign="bottom"><span style="color: black;">18</span></td>
<td align="center" sdnum="1033;" sdval="16" valign="bottom"><span style="color: black;">16</span></td>
<td align="center" sdnum="1033;" sdval="2" valign="bottom"><span style="color: black;">2</span></td>
</tr>
<tr>
<td align="left" height="20" valign="bottom"><span style="color: black;">YRGBBB</span></td>
<td align="center" sdnum="1033;" sdval="20" valign="bottom"><span style="color: black;">20</span></td>
<td align="center" sdnum="1033;" sdval="18" valign="bottom"><span style="color: black;">18</span></td>
<td align="center" sdnum="1033;" sdval="2" valign="bottom"><span style="color: black;">2</span></td>
</tr>
</tbody></table>
<br />Table 1: Century: Spice Road Points cards. (data from <a href="https://boardgamegeek.com/filepage/156544/list-century-spice-road-cards-and-their-analysis">this spreadsheet</a>)<br />
<br />
Note: while I leveraged the table above, I did not read any existing analyses of the game. I imagine that others have come to similar conclusions.<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-33345796154719844812020-06-29T17:30:00.000-07:002020-06-29T17:30:05.818-07:00Which die is highest?<blockquote class="tr_bq">
You roll a d6, d8, d12, and d20 all at the same time. What is the probability the d6 results in the highest number? d8? d12? d20?</blockquote>
First, let's clarify by what we mean by "highest number''. Does that mean that the d6 is <i>greater </i>the other dice, or just that no <i>other</i> dice are greater? In other words, how do we count ties? Let's not count ties for now, and deal with them last. With four dice, they will be the most tricky. (This is due to the number of cases involved. There could be 2, 3, or 4 dice tied. Or two sets of 2 for that matter!)<br />
<br />
The faces of each of these dice are numbered 1 through the number of sides that it has. Each side has equal probability of occurring. If we label the results of the four dice as random variables $X_6$, $X_8$, $X_{12}$, and $X_{20}$, where the subscript refers to the number of sides of the die, then we can write the statement of equal probability in the following equation.<br />
\begin{align}<br />
P(X_N = x) = \begin{cases}<br />
\frac{1}{N} &\qquad x \in \mathbb{W}, 1 \leq x \leq N \\<br />
0 &\qquad \text{else}<br />
\end{cases}<br />
\end{align}<br />
Here $\mathbb{W}$ is the set of all whole numbers (i.e. 0, 1, 2, 3, etc.). Recall that the probability of rolling less than a number on such a die is proportional to said number,<br />
\begin{align}<br />
P(X_N < x) = \frac{x-1}{N} &\qquad x \in \mathbb{W}, 1 \leq x \leq N .<br />
\end{align}<br />
But perhaps I'm putting the cart before the horse. How do we approach this problem? We can write the question as,<br />
\begin{align}<br />
P(X_6 > \max(X_8, X_{12}, X_{20})) = ?<br />
\end{align}<br />
This is not a great way to write it though. It tends to make us think that we should compute the distribution of the maximum term $\max(X_8, X_{12}, X_{20})$. We can write them separately also,<br />
\begin{multline}<br />
P(X_6 > \max(X_8, X_{12}, X_{20})) \\= P((X_6 > X_8) \cap (X_6 > X_{12}) \cap (X_6 > X_{20}))<br />
\end{multline}<br />
This means we are looking for the probability that $X_6 > X_8$ <i>and</i> $X_6 > X_{12}$ <i>and</i> $X_6 > X_{20}$. Unfortunately, these events are not independent, so we can not break up the intersection easily. How do we know that they are not independent? The requirement for independence is that knowing one event does not affect the probability of the other. It holds that $P(A | B) = P(A)$ if $A$ and $B$ are independent. Consider the case when $X_6 > X_{20}$. If true, that makes it more likely that $X_6 > X_8$ as then $X_6$ is more likely to be high.<br />
<br />
Instead of using independence, let's consider that we roll the d6 first. All the rolls are independent, so this doesn't affect the probabilities. We can then consider the conditional probability,<br />
\begin{multline}<br />
P(( (X_6 > X_8) \cap (X_6 > X_{12}) \cap (X_6 > X_{20}) ) | X_6 = x) \\= P((x > X_8) \cap (x > X_{12}) \cap (x > X_{20})).<br />
\end{multline}<br />
Here, the three events are independent, since they depend on independent random variables, thus,<br />
\begin{multline}<br />
P((x > X_8) \cap (x > X_{12}) \cap (x > X_{20})) \\= \underbrace{P(x > X_8)}_{\frac{x-1}{8}} \cdot \underbrace{P(x > X_{12})}_{\frac{x-1}{12}} \cdot \underbrace{P(x > X_{20})}_{\frac{x-1}{20}}.<br />
\end{multline}<br />
We can then fill in the individual terms using a previous equation as shown above.<br />
\begin{align}<br />
P((x > X_8) \cap (x > X_{12}) \cap (x > X_{20})) = \frac{(x-1)^3}{8 \cdot 12 \cdot 20}.<br />
\end{align}<br />
We can then use the conditional probability to compute the total probability, using the following form,<br />
\begin{align}<br />
P(A) = \sum_{x \in \Omega} P(A | X=x) \cdot P(X=x),<br />
\end{align}<br />
where $A = (X_6 > X_8) \cap (X_6 > X_{12}) \cap (X_6 > X_{20})$ is an event and $X = X_6$ is a random variable. Note that this is an extension of the basic statement of conditional probability, namely that,<br />
\begin{align}<br />
P(A \cap B) = P(A|B) \cdot P(B),<br />
\end{align}<br />
where $A$ and $B$ are events. Consider a set of mutually exclusive events $B_i$, the union of which encompasses the entire sample space. That is,<br />
\begin{align}<br />
&B_i \cap B_j = \varnothing, \quad i \neq j \\<br />
&\bigcup_i B_i = \Omega .<br />
\end{align}<br />
Suppose we take the intersection of our event $A$ with the whole sample space. The resulting event is equivalent to the event $A$,<br />
\begin{align}<br />
A = A \cap \Omega ,<br />
\end{align}<br />
and thus the probabilities are the same,<br />
\begin{align}<br />
P(A \cap \Omega) = P(A | \Omega) \cdot P(\Omega) = P(A) .<br />
\end{align}<br />
Now, but substituting $\Omega$ for the union of our events $B_i$, we find a new way to write the probability of $A$. <br />
\begin{align}<br />
P(A) & = P(A \cap \Omega) \\<br />
&= P\left (A \cap \left (\bigcup_i B_i \right ) \right ) \\<br />
&=P\left( \bigcup_i \left( A \cap B_i \right) \right)<br />
\end{align}<br />
The last line above distributes the intersection across all the terms in the union. This is analogous to the distributive property of multiplication. That is, treat intersection like multiplication and union like addition when rearranging. A simple statement of the idea is that<br />
\begin{align}<br />
A \cap (B \cup C) = (A \cap B) \cup (A \cap C).<br />
\end{align}<br />
We know that all that sets $A \cap B_i$ are disjoint since $B_i$ are disjoint by construction. The probability of disjoint events add when considering their union, thus,<br />
\begin{align}<br />
P(A) &=P\left( \bigcup_i \left( A \cap B_i \right) \right) \\<br />
&=\sum_i P(A\cap B_i).<br />
\end{align}<br />
Now, we can use our earlier statement of conditional probability to rewrite this as,<br />
\begin{align}<br />
P(A) &=\sum_i P(A\cap B_i) \\<br />
&=\sum_i P(A | B_i) \cdot P(B_i).<br />
\end{align}<br />
By defining the event $B_i$ as when $X = x$, where $x \in \mathbb{Z}$, for some mapping of $i$ onto $x$ (or should it be vice-versa?), we get the equation we are looking to prove. QED. <br />
<br />
Now we can move on with the problem at hand, and compute the probability we are interested in.<br />
\begin{align}<br />
P((X_6 > X_8) \cap (X_6 > X_{12}) \cap (X_6 > X_{20})) &= \sum_{x=1}^6 \frac{(x-1)^3}{8 \cdot 12 \cdot 20}\cdot \frac{1}{6} \\<br />
&\approx 0.0195<br />
\end{align}<br />
We can similarly compute the other probabilities, but there is a slight wrinkle here. We tacitly benefited from the fact that the d6 has the lowest maximum. If we instead look at the probability that the d20 is highest, we have to consider that the d20 can roll a number not possible on the other dice. This shows up when we use the earlier equation for $P(X_N < x)$ outside the range we stated. We can extend it as follows.<br />
\begin{align}<br />
P(X_N < x) = \begin{cases}<br />
\hfill 0 \hfill & \, x < 0 \\<br />
\hfill \cfrac{x-1}{N} \hfill &\, x \in \mathbb{N}, x \leq N \\<br />
\hfill 1 \hfill & \, x > N<br />
\end{cases}<br />
\end{align}<br />
Focusing on the probability that the d8 is highest, there are thus two cases two consider: when the d8 rolls up to 6, and when it rolls above 6. <br />
\begin{align}<br />
P((x > X_6) \cap (x > X_{12}) \cap (x > X_{20})) = \begin{cases}<br />
\cfrac{(x-1)^3}{6 \cdot 12 \cdot 20}&\, x \leq 6 \\ & \\<br />
\cfrac{(x-1)^2}{12 \cdot 20} &\, x > 6 <br />
\end{cases}<br />
\end{align}<br />
From this we can compute the probability that the d8 is higher than all other dice using two summations.<br />
\begin{multline}<br />
P((X_8 > X_6) \cap (X_8 > X_{12}) \cap (X_8 > X_{20})) \\= \left (<br />
\sum_{x=1}^6 \frac{(x-1)^3}{6 \cdot 12 \cdot 20} <br />
+ \sum_{x=7}^8 \frac{(x-1)^2}{12 \cdot 20} <br />
\right ) \cdot \frac{1}{8} <br />
\end{multline}<br />
\begin{align}<br />
P((X_8 > X_6) \cap (X_8 > X_{12}) \cap (X_8 > X_{20}))&\approx 0.0638<br />
\end{align}<br />
Computing the probability for the d12 and d20 are similar, except that there are even more ranges.<br />
\begin{multline}<br />
P((X_{12} > X_6) \cap (X_{12} > X_{8}) \cap (X_{12} > X_{20})) \\= \left (<br />
\sum_{x=1}^6 \frac{(x-1)^3}{6 \cdot 8 \cdot 20} <br />
+ \sum_{x=7}^8 \frac{(x-1)^2}{8 \cdot 20} <br />
+ \sum_{x=9}^{12} \frac{(x-1)}{20} <br />
\right ) \cdot \frac{1}{12} <br />
\end{multline}<br />
\begin{align}<br />
P((X_{12} > X_6) \cap (X_{12} > X_{8}) \cap (X_{12} > X_{20}))&\approx 0.222<br />
\end{align}<br />
\begin{multline}<br />
P((X_{20} > X_6) \cap (X_{20} > X_{8}) \cap (X_{20} > X_{12})) \\= \left (<br />
\sum_{x=1}^6 \frac{(x-1)^3}{6 \cdot 8 \cdot 12} <br />
+ \sum_{x=7}^8 \frac{(x-1)^2}{8 \cdot 12} <br />
+ \sum_{x=9}^{12} \frac{(x-1)}{12} <br />
+ \sum_{x=13}^{20} 1 <br />
\right ) \cdot \frac{1}{20} <br />
\end{multline}<br />
\begin{align}<br />
P((X_{20} > X_6) \cap (X_{20} > X_{8}) \cap (X_{20} > X_{12}))&\approx 0.622<br />
\end{align}<br />
Now, let's consider the probability of a tie. If we just lump them all together, then we compute the probability relatively easily, by looking at it in terms of there <i>not</i> being a tie.<br />
\begin{align}<br />
P(\text{tie}) = 1 - P(\text{no tie})<br />
\end{align}<br />
We can construct the case when there is no tie. Consider rolling the d6 first. Any face is allowed. Now consider rolling the d8. All but one of the faces are allowed; if we roll the same as on the d6 we have a tie. Similarly for the d12, all but 2 are allowed. For the d20, all but 3 are allowed.<br />
\begin{align}<br />
P(\text{no tie}) &= \frac{6}{6} \cdot \frac{7}{8} \cdot \frac{10}{12} \cdot \frac{17}{20}\\<br />
&\approx 0.620\\<br />
P(\text{tie}) &\approx 1 - 0.620 \\<br />
&\approx 0.380<br />
\end{align}<br />
Note that when we compare this to what's left when none of the four dice are higher than all the others, the values are not equal.<br />
\begin{align}<br />
P(\text{tie for highest}) &= 1 - P(\text{d6 strictly higher}) \\ <br />
&\qquad -P(\text{d8 strictly higher}) \\<br />
&\qquad -P(\text{d12 strictly higher}) \\<br />
&\qquad- P(\text{d20 strictly higher}) \\<br />
&\approx 1 - 0.0195 - 0.0638 - 0.222 - 0.622 \\<br />
&\approx 0.0727<br />
\end{align}<br />
This is because many, most actually, of the ties are between dice which are not amongst the highest. For example, the dice may roll 6, 6, 10, 15.<br />
<br />
(I originally found this question <a href="https://boardgamegeek.com/thread/1962109/statistic-question">here </a>on BGG.)Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-67488759788442472912020-06-23T17:30:00.000-07:002020-06-23T17:30:02.243-07:00Errata: How replayable is Onitama using the 16 move cards in the base game?<br />
In our <a href="https://www.quantifyingstrategy.com/2020/05/how-replayable-is-onitama-using-16-move.html">earlier discussion of Onitama</a>, there was an error in the calculation of the number of sets of five cards which have an asymmetric card without its mirror, which we labeled $n_3$, helpfully pointed out by a reader in the comments. On reflection, the error is somewhat obvious, as we computed that there are more of these cases than the total number of ways of select five cards, $n_1$.<br />
\begin{align}<br />
n_1 &= 4368 \\<br />
n_3 &= 8008 \\<br />
n_3 &> n_1<br />
\end{align}<br />
We avoided spotting the error because we subtracted half of $n_3$ from $n_1$, and since $n_1 > n_3/2$, we still got a positive number. However, a simple check of the scale of these two numbers would have indicated the error.<br />
<br />
But what is the error? It's that we double counted many cases (I really should be saying I here, as I made the error, and you're following along at home probably spotting my error!). Recall the construction of $n_3$. We selected one of the asymmetric cards, and then allowed the remaining cards to be any of the cards except the mirror of the first card. However, that includes cases where there is an additional unmatched asymmetric card. Those cases get counted again when we get to picking the unmatched card as the first card.<br />
<br />
Correcting this gets messy. I'd still like the largely follow the flow that I used originally, so let's just recompute $n_3$ correctly. Unfortunately, the best way that I've been able to come up with involves summing over every possible number of unmatched asymmetric cards as well as looking at every possible number of matched asymmetric cards. The crux is this: if we include an asymmetric card we must know whether or not its pair is included. Given the number of unmatched asymmetric cards, $u$, and the number of matched pairs, $m$, we can find the number of ways to come up with a valid selection. First, there are $\binom{8}{u}$ ways to select $u$ unmatched asymmetric cards out of the total of 8, with $u$ from 1 to 4. The maximum is 4, because there are only 4 pairs of matches cards, so we can't get 5 unmatches ones. A fifth card would have to match. That leaves us with $16-u$ cards, but only $4- u$ pairs of matched asymmetric cards ($8-2 \cdot u$ cards in total). This means there are $\binom{4-u}{m}$ ways to select the matched pairs. If $u \geq 4$, then there's no space for matched pairs. In general, we have to keep the total number of matched and unmatched cards to 5 or less, so<br />
\begin{align}<br />
u + 2\cdot m \leq 5 .<br />
\end{align}<br />
This limits $m$ to satisfy,<br />
\begin{align}<br />
m \leq \frac{5-u}{2}<br />
\end{align}<br />
From the binomial coefficient along, we can see that $m \leq 4-u$, but the above requirement is more restrictive here, since $m$ must be an integer.<br />
\begin{align}<br />
\begin{array}{c|c|c}<br />
u &4-u&\frac{5-u}{2}\\\hline<br />
1&3&2\\<br />
2&2&1.5\\<br />
3&1&1\\<br />
4&0&0.5\\<br />
\end{array}<br />
\end{align}<br />
This leaves a remaining $5-u-2 \cdot m$ cards to be chosen from the remaining 8 symmetric cards, which there are $\binom{8}{5-u-2 \cdot m}$ to select. Putting this together we get the following when we sum over the ranges computed above.<br />
\begin{align}<br />
n_3 &= \sum_{u=1}^4 \sum_{m=0}^{\lfloor \frac{5-u}{2} \rfloor} \binom{8}{u} \cdot \binom{4-u}{m} \cdot \binom{8}{5-u-2 \cdot m} \\<br />
n_3 &= 5456<br />
\end{align}<br />
Unfortunately, I've made another mistake, since the new $n_3$ calculation is still larger than $n_1$.<br />
<br />
Perhaps you noticed that I did a poor job of selecting the number of ways to choose $u$ unmatched asymmetric cards. It holds up to $u=1$, but not above. We can't choose any of the 8 cards, as we can choose at most one of each pair. Thus, when selecting each card, we need to choose which pair to select from, of which there are $\binom{4}{u}$ ways to do, and then select which card inside each set. For each unmatched asymmetric card there are 2 ways of doing that (since there are two cards), so in total there are $2^u$ ways of selecting the $u$ cards once selecting the pairs. This provides us with a new equation for $n_3$.<br />
\begin{align}<br />
n_3 &= \sum_{u=1}^4 \sum_{m=0}^{\lfloor \frac{5-u}{2} \rfloor} \binom{4}{u} \cdot 2^u \cdot \binom{4-u}{m} \cdot \binom{8}{5-u-2 \cdot m} \\<br />
n_3 &= 4040<br />
\end{align}<br />
Finally, we've gotten a number that's less than $n_1$. It seems surprisingly large, in that almost all of the ways to select 5 cards out of 16 results in at least one unmatched asymmetric card. Let's come up with a check that our methodology is correct. If we add in the case that we get no unmatched pairs, that is $u=0$,<br />
then we should get $n_1$. Let's try that.<br />
\begin{align}<br />
n_3 + \sum_{m=0}^{\lfloor \frac{5}{2} \rfloor} \binom{4}{m} \cdot \binom{8}{5-2 m} &= \sum_{u=0}^4 \sum_{m=0}^{\lfloor \frac{5-u}{2} \rfloor} \binom{4}{u} \cdot 2^u \cdot \binom{4-u}{m} \cdot \binom{8}{5-u-2m} \\<br />
&= 4368 \\<br />
&= \binom{16}{5} \\<br />
&= n_1<br />
\end{align}<br />
This does a pretty good job of confirming that our methodology is correct, as our somewhat convoluted summation gives us the same value for $n_1$. Now we can bring this all together and calculate the total number of initial positions considering isomorphs. Recall that we had the number of ways to select 5 cards excluding isomorphs is as follows.<br />
\begin{align}<br />
n_4 &= n_1 - \frac{n_3}{2} \\<br />
&= \binom{16}{5} - \frac{1}{2} \cdot \sum_{u=1}^4 \sum_{m=0}^{\lfloor \frac{5-u}{2} \rfloor} \binom{4}{u} \cdot 2^u \cdot \binom{4-u}{m} \cdot \binom{8}{5-u-2m}\\<br />
&= 4365 - \frac{4040}{2} \\<br />
&= 2345<br />
\end{align}<br />
To get the number of initial positions with isomorphs, we need to multiply by $\frac{5!}{2 \cdot 2}$ as before.<br />
\begin{align}<br />
n_5 &= n_4 \cdot \frac{5!}{2 \cdot 2} \\<br />
&= 2345 \cdot \frac{5!}{2 \cdot 2} \\<br />
&= 2345 \cdot 30 \\<br />
&= 70350<br />
\end{align}Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9170413323750351865.post-69475165636967904572020-06-22T17:30:00.000-07:002020-06-22T17:30:03.597-07:00Onitama errata forthcomingI'm working on fixing the Onitama calculation error I made previously, but I've made some subsequent computation errors that I'm tracking down. Expect an update soon.Unknownnoreply@blogger.com0