autoattack: have the best attacker go first.
commit76fe09a914d5c4121fbff8def516ba5d236d473c
authorsveinung <sveinung@a0f10bec-cc02-0410-94fc-a9cfff90b4cd>
Mon, 7 Nov 2016 12:42:27 +0000 (7 12:42 +0000)
committersveinung <sveinung@a0f10bec-cc02-0410-94fc-a9cfff90b4cd>
Mon, 7 Nov 2016 12:42:27 +0000 (7 12:42 +0000)
treecd78f08aac7567c648c863d6a246a14e95dcd370
parent2cac5b38d56bdcb3a72928d58ad9815d12894013
autoattack: have the best attacker go first.

A unit will only auto attack if its probability of success is above a
certain threshold. The threshold is currently 90% if the unit is the last
defender in a city and 25% otherwise.

A unit's probability of success against a target can depend on target
specific factors. One example of target relative unit strength is how the
classic ruleset gives a defense bonus to Pikemen when attacked by Horsemen.

Up unit now the potential attacker with the *worst* odds (above the
threshold) have attacked first.
 * saved the stronger units for more worthy potential future enemies.
   (Thanks to Jacob Nevins <jtn> for noticing.)
 * made it harder to lure strong enemy units out of the way by using
   sacrificial units. (A regular attack may, depending on the occupychance
   server setting, make the attacker move after victory is achieved)
 * made it possible to exploit target relative unit strength by moving a
   unit a strong unit in a unit stack is weak against next to the tile.
 * increased the probability of the auto attacker losing and dying.
 * decreased the probability of a follow up attack (target weakness can
   increase the probability of victory enough to have it pass the threshold)

Make the potential attacker with the *best* odds attack first.
 * makes it possible to waste a strong unit's attacks by sending weak units
   against it. (Assuming a more or less global ranking of attack strength.)
 * makes it possible to lure away strong units by using sacrificial units.
   (Assuming a more or less global ranking of attack strength.)
 * target specific factors are exploited to the autoattacker's advantage.
   This beats the advantage of the old system because attacker unit strength
   can depend on the target unit.
 * reduces the probability of the auto attacker dying during the attack.
 * increases the probability of a second auto attacker finishing of the
   target if the first auto attacker fails.

See patch #7942

git-svn-id: svn://svn.gna.org/svn/freeciv/trunk@34432 a0f10bec-cc02-0410-94fc-a9cfff90b4cd
server/unittools.c