This is in response to Dash’s comments about how to compute the probability terms used in his calculator.
P(n units getting k hits, if p is the probability of 1 unit getting one hit) = (n choose k)p^k(1-p)^(n-k).
Since axis & allies has non-homogenous forces (i.e. infantry + armor + bombers), these terms need to be further combined with complicated algorithms.
There’s a simplification to this problem, if we assume fixed order of loss.
Let p(i) == the probability of the ith unit getting a hit. (e.g. for attacking inf ==> 1/6, attacking armor 3/6, etc…)
Let p(i) be defined in the reverse order of loss. This can be initialized trivially.
Let P(i, j) == the probability that i units gets j hits. This is the matrix that we’re trying to fill in.
The following recurrence relation holds:
P(i, j) = P(i-1, j-1) * p(i) + P(i-1, j) * (1-p(i))
We then just need to define the initial conditions:
P(0, 0) = 1
P(0, j) = 0 for all j > 0
P(i, 0) = P(i-1, 0) * (1 - p(i))
We can now fill in P(i, j) for all i, j and compute all of the probability terms that will be needed for the attackers.
The beauty of this formulation:
- No powers
- No factorials
- No special logic needed to handle non-homogenous forces.
- Complexity to compute all probability terms needed is O(n^2) :).
- All of the subproblems solved are needed and will be used.
Unfortunately, I believe updating the probabilities themselves is O(n^4). So the computation of the probability terms themselves shouldn’t really be the bottleneck if they are precomputed.
- Mitchell