Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New method to calculate chance to stay unscathed
@mattsc spotted that attack prediction sometimes gives incorrect results for chance to stay unscathed when the other unit can die during the battle. The old calculation algorithm worked by determining the chance that the unit survives each unit unscathed, and multiplying the probabilities together. However, that method of probability calculations works only if the attacks are independent, i.e. the probability of surviving *this* attack unscathed doesn't depend on the chance of being already unscathed. And that's not the case if either combatant can kill the other one. If combatant A has killed combatant B, combatant B can't strike it any more and therefore combatant A is more likely to *be* unscathed. Inversely, if A is unscathed, it's more likely that B is dead. As a result, if A is unscathed, A is also more likely to *stay* unscathed. The old method couldn't take that into account and therefore produced incorrect results. In my local tests, this new algorithm appears to produce correct results. Only rounding errors (and drain ability) separate it from the HP distribution tables.
- Loading branch information