Combat_Rounds effect: to kill or to survive?

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Combat_Rounds effect: to kill or to survive?

Post by Ignatus »

Wahazar wrote:Number of rounds should depend on unit HP (those which is higher) - it should resolve problem with stream of immortal musks (20 hp) vs armor (30 hp).
That's how unlimited combat works - two can't fight more rounds then their summary (hp/enemy_fp) minus one. And against a horde of musks you could use a pile of tanks. The question is if it's a good idea at all to limit the musks' rounds.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Combat_Rounds effect: to kill or to survive?

Post by bard »

Ignatus wrote:It often would be just much more advantageous to fight a battle which is 1% lost and 99% won than one that is 100% drawn.
I agree, but it is not possible to calculate mathematically the chance to die that is worth risking in order to kill the enemy. It might depend on the cost of each unit, the chance to get veterancy, the bonus of each veterancy level, the hit points restored per turn in the defender's tile...
If it was a function used only by the AI players, then I'd find your suggestions ok. But since get_defender is going to chose automatically in the place of the player too, I'd rather prefer a simple rule of thumb that can be easy to predict.
I think, as a rule of thumb thresholds from the autoattack mechanism could be reused in this case. There, a unit will go to hunt a target that worth autoattacking if the winning chance is greater than 25%, but for sole city defender this value is risen to 90%; if the chance is less, another way of coping with the trouble is supposed to be used. Thus, what if we range defenders by P(survive)+MAX(P(win)-0.25, 0) in a safe stack and P(survive)+MAX(P(win)-0.9, 0) in a vulnerable one? (Except when the attacker is a missile, which is of no use to kill, or the defender is a king who can't afford any chance to die).
It looks a bit risky to me. Would it be useful something like: if P(survive) >= 99%, then use P(survive)+P(win). Else use only P(survive).
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Combat_Rounds effect: to kill or to survive?

Post by Ignatus »

bard wrote:
Ignatus wrote:It often would be just much more advantageous to fight a battle which is 1% lost and 99% won than one that is 100% drawn.
I agree, but it is not possible to calculate mathematically the chance to die that is worth risking in order to kill the enemy. It might depend on the cost of each unit, the chance to get veterancy, the bonus of each veterancy level, the hit points restored per turn in the defender's tile...
If it was a function used only by the AI players, then I'd find your suggestions ok. But since get_defender is going to chose automatically in the place of the player too, I'd rather prefer a simple rule of thumb that can be easy to predict.
I mind the simplicity goal. I think the functions I'm suggesting are not much more complicated then the current function, if we compare it to the increased complicity of 3.0 combat behaviour. I also would keep the current behaviour for the case P(survive)=P(win), except for gameloss units that anyway are more of concern for players. (The only mad case of current rules is that 0-strength attacker and 0-strength defender kill each other, I would just take 1mp from the former and let these clowns go.)
bard wrote:
I think, as a rule of thumb thresholds from the autoattack mechanism could be reused in this case. There, a unit will go to hunt a target that worth autoattacking if the winning chance is greater than 25%, but for sole city defender this value is risen to 90%; if the chance is less, another way of coping with the trouble is supposed to be used. Thus, what if we range defenders by P(survive)+MAX(P(win)-0.25, 0) in a safe stack and P(survive)+MAX(P(win)-0.9, 0) in a vulnerable one? (Except when the attacker is a missile, which is of no use to kill, or the defender is a king who can't afford any chance to die).
It looks a bit risky to me. Would it be useful something like: if P(survive) >= 99%, then use P(survive)+P(win). Else use only P(survive).
This would make too big meaningless jumps of the function (if you like me assume that "survive" is superset of "win"), e.g. if defender A survives 98%, wins 50% (your rating 0.98) and defender B survives 99%, wins 10% (rating 1.09). My function gives them 1.23 and 0.99 in a safe stack and 0.98 and 0.99 in a vulnerable one; to be rated over 0.99, a 98% survivor must have over 26% and 91% chance to win respectingly; maximal possible rating increments are 75% (but not more than twice) and 10%. Well, the complete ignorance of extra 40% chance to get rid of the enemy also looks poor but it is something.

The ideas behind my functions:
* If we have produced units and put them to the position then we usually need these units at this position, and we can not make decisions while we are attacked but will be able to compensate it if survive. Thus, the first goal is to maximize survival probability.
* Our enemies also need units they have produced, and at average units cost approximately the same, so for a safe stack the expected forces exchange is
P(win) - P(lose) = P(win) + P(survive) - 1
(but: if they have sent them in action, it is more probable that they have prepared to replace them, while our defended units may have just got into a sudden ambush; maybe value the attacker with some reducer?) If our stack is vulnerable, then we lose all the units and the position with the loss of the defender; but if the attacker survives, then there is some chance that it will strike again, so we still put some value into eliminating the peril. These two criteria give similar advice in an unlimited combat which is handled by actual get_defender().
* Too small winning probability should not distract us from surviving, and we use some credibility threshold; values that are barely credible only barely change the result. The threshold is used to distinguish stack vulnerability, more mathematically plausible ways to do so exist but this is the simplest.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Combat_Rounds effect: to kill or to survive?

Post by bard »

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.
This would make too big meaningless jumps of the function
You are right, 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 still think that get_defender is basically a game rule, something the player can not control and has to learn to adapt to it. I do not think this function should include estimators with different behaviour depending on the situation, even if it sometimes produce undesired results.

However, your reasoning seem right, and I'd see ok if you finally use your suggested formulas. I'm just a ruleset creator, planning to test units with limited combat rounds in my version for 3.0, thats why I was interested in this topic. I appreciate you asked for opinions here in the forums.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Combat_Rounds effect: to kill or to survive?

Post by Ignatus »

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
DN = 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.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Combat_Rounds effect: to kill or to survive?

Post by bard »

I'm liking this linear approach too. A bit complex for me, but I think the formulation is solid, if I understood...

Vulnerable tile: something between
- With 2 units: P(survive) + (1/6) * P(kill)
- With many units: P(survive)

Non-vulnerable tile:
- With 2 units: P(survive) + (1/4) * P(kill)
- With many units: P(survive) + (1/2) * P(kill)

I think I would feel safer with a value of x=1/4, so the effect of P(Kill) is halved, but your values look pretty well adjusted too.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Combat_Rounds effect: to kill or to survive?

Post by Ignatus »

The HRM ticket is opened.

Well, I think the x parameter should be left to the ruleset for better balancing, we don't change rulesets too often (just ongoing hurrying up the 3.0 datafile format probably delays it to v3.1). I'm slowly coding the functions using my formulation, just have not yet decided if I want to include in it a partial CanEscape awareness (take P(die)-P(kill)*x/(n+1.5a+0.5) instead of P(die)-P(kill)*x/(n+a) for an escaping unit in a vulnerable stack). Now, I need expressions for further levels of the selection.

As the second level, we now have the defender's cost. In an unlimited combat, cheaper defender with similar winning chance has bigger expected shields exchange, and in a vulnerable stack we at least preserve fresh a presumably more useful unit if we win. In generalized combat (again CanEscape omitting), the expected shields exchange (that we want to maximize) is
DC = y*Ca*P(kill) - P(die)*Cd
Here y is relative cost of producing a shield; this can much vary but for simplicity we can presume that at average yx. Cd is the price of all defenders in a vulnerable stack or of selected defender in a safe one. Then, from the formulation for equivalent winning chance that we presume equal, we can get that in a vulnerable stack we have to maximize
P(die)*((n+a)Ca-Cd),
that for expensive stacks leads to the expected idea of minimizing P(die); but if our average unit costs less then the attacker we should maximize it instead (because corresponding P(kill) rises fast enough to make it good). For a safe stack, we have to maximize
----Edit:the rest of the post is not true----
P(die)*((1+a/n)Ca-Cd)
(i.e., if we have among selected in the previous step some units that cost less than the attacker, we select one of them, and then generally want bigger P(die), but this may vary).

The third sorting stage now relies on a "defense rating" that equals to the expected damage a defender would cause to an attacker with infinite health and strength/firepower equal to the real one; at constant surviving possibility, this brings forth the defender which sells its life the most expensive. This seems not always good even in an unlimited combat: we don't want to damage a missile, it won't live anyway, we'd better want some unit that will retain more hits surviving meeting with it. I continue thinking about it.
Last edited by Ignatus on Thu Nov 08, 2018 9:41 am, edited 1 time in total.
Wahazar
Elite
Posts: 362
Joined: Mon Jul 02, 2018 1:49 pm

Re: Combat_Rounds effect: to kill or to survive?

Post by Wahazar »

How such kill/survive idea would work with "fly if you can, if defender killed" instead killstackall mechanism?
Augmented2 ruleset/modpack for freeciv2.6: http://forum.freeciv.org/f/viewtopic.php?f=11&t=91047
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Combat_Rounds effect: to kill or to survive?

Post by Ignatus »

Wahazar wrote:How such kill/survive idea would work with "fly if you can, if defender killed" instead killstackall mechanism?
Just we for each unit that can escape add to the expected number of units dying if defender loses n its probability of not escaping killstack (for 3.0, either 1 or 0.5); the exception is the actual defender who always dies if killed. Then, the price of the field is paid if all the defender perish, so for one-battle horizont of planning its expected value in the losing case is a * product(all probabilities to die) (if the escaped units don't physically leave the field, of course). In a safe stack we can look ahead what happens if we shall lose the units as fast, this is where I have took a/UnitsOnTile, here nothing changes.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Combat_Rounds effect: to kill or to survive?

Post by cazfi »

Hans Lemurson wrote:One thing to keep in mind is that when you remove "to the death" from battles, the result is that the winner of a battle has lower unit losses than he would otherwise. You could, for example, destroy a fortifed Tank with endless waves of Musketeers and not suffer any deaths.
Tank should still be clearly more powerful than a single Musketeer -> it will win enough rounds to actually kill the Musketeer. Assuming ruleset author has not set combat rounds to ridiculous values. Battles are not to death only in those situations where the parties are about equally powerful -> both winning about 50% of rounds -> neither winning most of the rounds.
Post Reply