Description
I play a war turn-based game, where attacks only have two variables that are visible before a strike: The attacker's military strength $f_{a}$ and the defender's military strength $f_{d}$. Whether an attack is successful or not is determined by a series of $3$ rolls.
Each roll the attacker and defender will be given a random (uniform) multiplier $r_{a}$ and $r_{d}$ respectively, where $$0.4<r<1.0$$For a roll to be successful this must hold: $$f_{a}r_{a}>f_{d}r_{d}$$ At the end of all $3$ rolls the resulting Victory Type will be determined as follows:
| Rolls Won | $3$/$3$ | $2$/$3$ | $1$/$3$ | $0$/$3$ |
|---|---|---|---|---|
| Victory Type | Immense Triumph (I) | Moderate Victory (M) | Pyrrhic Victory (P) | Utter Failure (U) |
Casualties are also calculated through the rolls, in each roll the attacker's and defender's casualties are given respectively by $$c_{a} = 0.01·f_{d}r_{d} \,\,\,\,\,\,\,\,\,\,\,\, c_{d} = 0.018337·f_{a}r_{a}$$ Importantly, casualties are only applied after all rolls, therefor all rolls are independent events. At the end of the 3 rolls, the number of casualties is rounded to the nearest integer.
What I have worked out
My knowledge in statistics isn't great, but through experimentation and some intuition I managed to (after a while) find that for a given $f_{a}$ and $f_{d}$ where $f_{a} < f_{d}$ the probability of a successful roll can be given by: $$P(f_{a}r_{a}>f_{d}r_{d})=\int_{0}^{1}{\frac{1}{0.6}\int_{0.4}^{max(\frac{f_{a}}{f_{d}}x,\,\,0.4)}{\frac{1}{0.6}\,dt}\,dx}$$ Which can be simplified to: $$P(f_{a}r_{a}>f_{d}r_{d})=\frac{25}{9}\left ( \frac{2f_{d}}{25f_{a}} + \frac{f_{a}}{2f_{d}} - \frac{2}{5} \right )$$ And thus, if $p$ is the probabilty of a successful roll, the probabilities for each victory type given $f_{a} < f_{d}$ are as follows: $$I=\begin{pmatrix}3\\3\end{pmatrix}p^{3}(1-p)^{0}$$ $$M=\begin{pmatrix}3\\2\end{pmatrix}p^{2}(1-p)^{1}$$ $$P=\begin{pmatrix}3\\1\end{pmatrix}p^{1}(1-p)^{2}$$ $$U=\begin{pmatrix}3\\0\end{pmatrix}p^{0}(1-p)^{3}$$
What I haven't worked out
So all of this leads me to my question, I have been trying to figure out what the expected number of casualties is for a specified victory type, that is, given $f_{a}$ and $f_{d}$ where $f_{a} < f_{d}$ what are the $E(C_{a}\mid I)$, $E(C_{d}\mid I)$, $E(C_{a}\mid M)$, $E(C_{d}\mid M)$ and so on...
So far I understand that if I were to set $r_{a}=1$ this would be true (or at least I think): $$E(C_{a}\mid I) = 3\int_{0.4}^{\frac{f_{a}}{f_{d}}}{\frac{1}{\frac{f_{a}}{f_{d}}-0.4}\,\frac{f_{d}r_{d}}{100}\,dr_{d}}$$ However given that the bounds of $r_{a}$ are dependent on $r_{d}$ and vise versa, since all the possible rolls that would result in a successful roll must follow these: $$0.4<r_{d}<\frac{f_{a}}{f_{d}}r_{a}$$ $$\frac{f_{d}}{f_{a}r_{d}}0.4<r_{a}<1$$ I have not been able to figure out how to calculates these expected values when both $r_{a}$ and $r_{d}$ are free to take all possible values they can.
Double checking
If anyone knows the solution, I wrote a little Python script that ran through the same scenario $1\times 10^{8}$ times where $f_{a}=3000$ and $f_{d}=4500$ and these were the results:
| Victory Type | Immense Triumph (I) | Moderate Victory (M) | Pyrrhic Victory (P) | Utter Failure (U) |
|---|---|---|---|---|
| Total Outcomes | $325513$ | $5608873$ | $32249407$ | $61816207$ |
| Total Attackers Casualties | $21321676$ | $429922319$ | $2831691198$ | $6117015520$ |
| Average Attackers Casualties | $65.5018$ | $76.6504$ | $87.8060$ | $98.9549$ |
| Total Defenders Casualties | $46393770$ | $739083939$ | $3902378593$ | $6814545685$ |
| Average Defenders Casualties | $142.5251$ | $131.7705$ | $121.0062$ | $110.2388$ |
So whatever the right formula is, when $f_{a}=3000$ and $f_{d}=4500$ the expected casualties should match the averages computed above.
First, for convenience we can eliminate the need for considering ${max(...)}$, in any case by simply limiting ourselves to having ${1 < \frac{f_d}{f_a}<2.5}$. This will help make calculations more concrete. ${1 < \frac{f_d}{f_a}}$ comes from our constraint ${f_a<f_d}$ while ${\frac{f_d}{f_a}<2.5}$ comes from our desire to have an actual game where ${b}$ isn't certain to win.
Next we will define ${s=\frac{f_d}{f_a}}$, for visual convenience.
I will use ${E(C_d | M)}$ as an example of the method to calculate the desired dependent probabilities. Let's define ${X_i}$ as the ${i}$-th roll for the defender and ${Y_i}$ as the ${i}$-th roll value for the attacker. Since we are given ${M}$ we know that the the attacker won exactly ${2}$ times, and we are ambivalent to which of the trials were wins due to independence. I will therefore assume that we know the roll sequence is Win, Win, Lose.
An attacker win means that ${s*X_i <Y_i<1}$ and ${0.4 < X_i < s^{-1}}$.Thus for roll ${i}$ we can calculate the probability of the attacker winning as ${\int_{0.4}^{s^{-1}} \int_{sx}^1 \frac{25}{9}dydx=\frac{25}{9}\int_{0.4}^{s^{-1}}(1-sx)dx = \frac{25}{9}*\frac{1}{2}*(s^{-1}-0.4)*(1-s*0.4)}$.
The probability of the attacker losing is ${1-\frac{25}{9}*\frac{1}{2}*(s^{-1}-0.4)*(1-s*0.4)}$.
Now we are interested in the density function of ${X_i}$ and ${Y_i}$, given a win. By Bayes Law this will be ${\frac{f_{X_i,Y_i}(x,y)}{P(win)}}$. Recall ${f_{X_i,Y_i}(x,y) = \frac{1}{0.6}\frac{1}{0.6}=\frac{25}{9}}$ by independence and uniformity. It's important to realize that ${\frac{f_{X_i,Y_i}(x,y)}{P(win)}}$ is a density function for the possible roll values.
Since we're given the ${1_{st}}$ roll is a win for the attacker. We have:
${\frac{f_{X_1,Y_1}(x,y)}{P(win)} = \frac{\frac{25}{9}}{\frac{25}{9}*\frac{1}{2}*(s^{-1}-0.4)*(1-s*0.4)}=\frac{1}{\frac{1}{2}*(s^{-1}-0.4)*(1-s*0.4)}=z}$. Notice ${z}$ is just a constant that depends on ${s}$ because we have chosen a uniform distribution.
Therefore: ${E(Y_1|win) = \int_{0.4}^{s^{-1}}\int_{1.5x}^1 z*y\,dy\,dx}$. An integral that will be easy for you to compute. Likewise ${Y_2}$ is a win for the attacker, ${E(Y_2|win)=E(Y_1|win)}$.
Now we are also given that roll 3 is a loss for the attacker. This means our bounds will be different. They are ${0.4<X_3<s^{-1} \cap 0.4<Y_3<s*X_3}$ and ${s^{-1}<X_3<1 \cap 0.4<Y_3<1}$. The density function will be similar to the winning case ${\frac{f_{X_3,Y_3(x,y)}}{1-P(win)}=\frac{\frac{25}{9}}{1-\frac{25}{9}*\frac{1}{2}*(s^{-1}-0.4)*(1-s*0.4)}=l}$. (Again we just plop in a constant because the uniform distribution makes it easy).
Using the above dependent density we can calculate ${E(Y_3|loss)=\int_{0.4}^{s^{-1}}\int_{0.4}^{sx}l*y\,dy\,dx + \int_{s^{-1}}^{1}\int_{0.4}^{1}l*y\,dy\,dx }$.
Finally, we put it all together and calculate ${E(C_d | M)=0.018337*f_a*[E(Y_1|win) + E(Y_2|win)+E(Y_3|loss)]}$.
If you follow this operation precisely with ${s=\frac{4500}{3000}=1.5}$ and ${f_a=3000}$, you will get an answer of about ${132.3}$, which largely agrees with your simulated value of ${131.8}$.