[Commits] [wesnoth/wesnoth] f6c4f3: New method to calculate chance to stay unscathed

GitHub noreply at github.com
Thu Oct 19 15:24:58 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: f6c4f3d214f5619ece6b934d0d1003ca2f1020e7
      https://github.com/wesnoth/wesnoth/commit/f6c4f3d214f5619ece6b934d0d1003ca2f1020e7
  Author: Jyrki Vesterinen <sandgtx at gmail.com>
  Date:   2017-10-19 (Thu, 19 Oct 2017)

  Changed paths:
    M src/attack_prediction.cpp

  Log Message:
  -----------
  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.





More information about the Commits mailing list