Author: sveinung Date: Mon Nov 7 13:44:50 2016 New Revision: 34433 URL: http://svn.gna.org/viewcvs/freeciv?rev=34433&view=rev Log: 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 Modified: branches/S2_6/server/unittools.c Modified: branches/S2_6/server/unittools.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=34433&r1=34432&r2=34433&view=diff ============================================================================== --- branches/S2_6/server/unittools.c (original) +++ branches/S2_6/server/unittools.c Mon Nov 7 13:44:50 2016 @@ -2961,12 +2961,16 @@ return unit_transport_depth(*q1) - unit_transport_depth(*p1); } + /* Put the units with the highest probability of success first. The up + * side of this is that units with bonuses against the victim attacks + * before other units. The downside is that strong units can be lead + * away by sacrificial units. */ if (p1uwc < q1uwc) { - return -1; /* q is better */ + return +1; /* q is better */ } else if (p1uwc == q1uwc) { return 0; } else { - return 1; /* p is better */ + return -1; /* p is better */ } } @@ -3019,7 +3023,8 @@ } unit_list_iterate_end; } adjc_iterate_end; - /* The unit list is now sorted according to win chance against punit */ + /* Sort the potential attackers from highest to lowest success + * probability. */ autoattack_target = unit_tile(punit); /* global variable */ if (unit_list_size(autoattack) >= 2) { unit_list_sort(autoattack, &compare_units); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits