bard wrote:P(survive)+MAX(P(win)-0.25, 0)
If I understood right, this formula would allow to chose as defender a unit with 66% to kill and 33% to die (I think those numbers would be possible for units with low remaining hp), over a unit with 99% to survive and 0% to kill. Choosing as defender units with more than 10% to die looks too risky to me, specially if there are available units with limited combat rounds that you can also use in your turn to kill enemy units with 0% to die.
Yes, you understood right. But, in fact, I now don't like this thresold formulation (it often does not value bigger winning chance with same survival one). The autoattack case is too different, your weak unit can expect that enemy's strong one just won't attack, and here we are already attacked and just select who will be responsible for dealing with it.
Another alternative would be: P(survive) + P(win)/10, so the effect of P(win) is similar to your suggestion, but without thresholds. It'd be like saying: it is worth to lose 1% to survive if you win 10% to kill.
I am going to a similary linear formulation, just a bit different. The expected units exchange, looking from the defender's side, is
D
N =
x * P(kill) -
n * P(die),
where P(die) is 1-P(survive),
x is amendment for how much the enemy unit is useful after the fight (0 for missiles),
n is the number of units lost with the defender (goes to infinity if a king is under strike, let's put it 2500 for just some flexibility); and we get maximal DN if we find maximal variant of
P(survive) + (
x /
n) * P(kill).
Let's introduce here some value
t for owning tile itself, I think it can be 1 for just a tile and 2 for one with a city or base (city costs more but can replace defenders). Then
n is 1+
t/UnitsOnTile for a non-vulnerable stack and UnitsOnTile+
t a vulnerable one (let's not check for CanEscape flag for simplicity). For a normal unit we can set (looking at the ceiling)
x=0,5 since if the attacking side has sent a unit into a dubious operation, they maybe don't value it much; there could be more credible formula
x=1-0,5*P(kill), but we approximate it with a line for again simplicity, and greater "safety". I thought about compiling Freeciv so that different players can have different
x and run some autogames to see which one likely wins, but AI's dumbness in attack coordination probably will diverge the result from suitable against humans.