Air combat discussion

Yeah, increasing the number of rounds seems like a good way to go since the odds of a hit each round depend on strength. I ran the numbers for fighters doing 20 damage, bombers 4 with 11 rounds ... some important changes:

Fighter v fighter:

Rookie fighter vs rookie fighter
- Odds of one fighter "perfecting" the other now 3% (was 25%)

Combat 5 fighter vs rookie fighter
- Com 5 now wins 73% (was 65%)
- Com 5 "perfects" 8% of the time (36%)

Combat 1 fighter vs rookie fighter
- Com 1 now wins 56% (54%)

50% Com 5 fighter vs rookie fighter
- Damaged plane survives 13% of the time (7%), but other plane is not shot down

Rookie jet fighter vs rookie fighter
- Jet wins 86% (74%)
- Jet "perfects" 13% (44%)

Take-away message: As expected, the odds of a fighter surviving undamaged drop dramatically. Wounded planes remain easy to take out, though veterans tend to survive a second attack more often.

Fighter v bomber:

Rookie fighter v rookie bomber
- Bomber survives 53% (34%)
- Fighter "perfects" 1% (16%), median damage sustained ~28% (20%)

Com 5 fighter v rookie bomber
- Bomber survives 27% (19%)
- Fighter "perfects" 3% (25%), median damage ~16% (15%)

Jet fighter v rookie bomber
- Bomber survives 13% (11%)
- Fighter "perfects" 6% (33%), median damage ~12% (10%)

Take-away: Bombers survive more, fighters more likely to take some damage but magnitude of damage sustained on average hasn't changed much (at all really, except for quantization).

Well, what do you all think? Are these reasonable numbers?

If you think about the units not as single entities but squadrons, then these changes to combat seem to make sense to me. Note that the AI always rests damaged fighters currently, which might need to be adjusted if we implemented this (healthiest fighter, if over 75%, still patrols or something).
 
I think you should just make the Air Combat more logical. Make air combat calculate the same way was other unit combats, with a 5 hit maximum.

As is it feels like the solution is a jerry rig, just fix the main cause of it being broken.
 
If you think about the units not as single entities but squadrons, then these changes to combat seem to make sense to me. Note that the AI always rests damaged fighters currently, which might need to be adjusted if we implemented this (healthiest fighter, if over 75%, still patrols or something).

I had expected the frequency of bombers being shot down to remain approximately the same, but I didn't check the numbers like you did. It probably has to do with the higher strength of the bomber which I didn't really take into account. If you wish the bombers to go down a bit more frequently, then you could go with 12 rounds of combat. Note that this will also decrease the survival chance of wounded verteran fighters against healthy rookie fighters.

Half of the rookie bombers surviving interception by rookie fighters is ok with me, but it is different from the original game where it was only a third.
 
Alright, here's what I decided to go with ... Since it's a pretty significant change I created a flag to turn the new combat mechanics on or use the original method.

The main gameplay issue with air combat was that veteran fighters were very short lived ... they had only a small advantage over rookies. In terms of combat mechanics, this stemmed from two reasons: per round damage being very high (50% for a fighter) and per round damage being independent of strength.

Roland's proposal addressed the first issue, turning down per round damage so that units had to win more rounds, thereby increasing the dependence on strength. I decided to also make damage change with strength, so it's now:

RoundDamage = 30*interception*(firepower ratio)/100

where the firepower ratio works like ground combat and takes into account health and relative strength of units (bombers are given an interception rating of 20, as they effectively got before).

There are two benefits of this approach: health is now of the same importance as in ground combat, previously a wounded plane was easier to kill than a wounded land unit. Second, strength plays a double roll just like with ground combat so there can be fewer rounds (less "average" results). All the numbers below are for 9 rounds of combat, which is looking pretty good.

Right now the change only applies to air v air combat, not land or sea interceptions ... I haven't run the numbers to see how it would work.

Some numbers: new% (bts%, roland%)
(Note: numbers for damaged planes are different than before ... I forgot to consider that it takes fewer hits to kill a damaged plane)

Fighter v fighter:

Rookie fighter v rookie fighter
- Perfect victory 6% (25%, 3%)

Com 5 v rookie
- Com 5 victory 90% (65%, 73%) (this is now like land combat numbers)
- Com 5 perfect odds 22% (36%, 8%)
- Rookie perfect odds 1% (16%, 1%)

Com 5 at 75% health v rookie
- Com 5 victory 56% (36%, 22%)

Com 5 at 50% health v rookie
- Com 5 victory 11% (3%, 0%)

Rookie jet v rookie fighter
- Jet wins 95% (74%, 86%)
- Jet perfects 30% (44%, 13%)
- Fighter perfects 0% (11%, 0%)

You can see the extra strong dependence on health for the prior models where round damage depended linearly on health. I'll post bomber numbers tomorrow.
 
Alright, now the new bomber numbers:

I had remembered bomber strength as 18, it's now correctly 16 for these numbers ... fighters are weaker than bombers which is necessary for bombers to survive some non-zero fraction of the time. Stealth bombers are weaker than jet fighters but survive based on their 50% evasion rating.

Rookie fighter v rookie bomber
- Fighter wins 59% (71%, 55%)
- Fighter perfects 3% (18%, 1%)
- Bomber wins 0% (0%, 0%)

Com 5 fighter v rookie bomber
- Fighter wins 80% (85%, 80%)
- Fighter perfects 8% (28%, 4%)
- Bomber wins 0% (0%, 0%)

Com 1 fighter at 80% health v rookie bomber
- Fighter wins 51% (21%, 5%)
- Fighter perfects 2% (6%, 0%)
- Bomber wins 0% (0%, 0%)

Com 1 fighter at 50% health v rookie bomber
- Fighter wins 9% (2%, 0%)
- Fighter perfects 0% (1%, 0%)
- Bomber wins 48% (18%, 0%)
- Bomber perfects 9% (18%, 0%)

Com 5 fighter at 50% health v rookie bomber
- Fighter wins 42% (4%, 0%)
- Fighter perfects 2% (2%, 0%)
- Bomber wins 11% (11%, 0%)
- Bomber perfects 3% (11%, 0%)

Com 5 fighter at 50% health v Com 5 bomber
- Fighter wins 7% (1%, 0%)
- Fighter perfects 0% (1%, 0%)
- Bomber wins 54% (20%, 0%)
- Bomber perfects 11% (20%, 0%)

Take-away message: Bombers survive more often, almost always deal some damage to intercepting fighters. Veteran fighters are now much more likely to win their second interception and have a good chance against rookies on their third interception. Bombers, especially veterans, are now better at taking out heavily wounded fighters ... if you send a fleet at one city you're more likely to come out with shooting down the fighter (and also getting more hits on your target as a result).

That said, fighters are still the best way to take out enemy fighters. To complement these changes the AI now always moves its fighters first. Currently the AI doesn't keep attack fighters around once it can build bombers, it switches them all to defense. As a partial fix to this I've made it so the AI will use extra defensive fighters on offense when it's winning a war, but they still base themselves defensively ... it helps, but more could certainly be done by creating an "air escort" AI type to explicitly go after enemy fighters.
 
It looks good, the numbers look good and it's a thought through formula. Some people might think that the changes are too radical for a mod that is mainly changing the AI. But I think it is necessary since the bug related to fighter combat promotions was removed and that changed aerial combat. By the way, you never mentioned the number of combat rounds that you used with this formula.

There's one number that I don't really like: the chance of a jet fighter versus a fighter. It's the result of the big jump in strength values in air units, it's similar to two consecutive technology jumps in land units. When the effect of combat promotions are kept as they are (10% per combat promotion) and the strength difference is meant to have a bigger effect on air combat, then this is unavoidable.

(The alternative would be a combat promotion that has more effect on aerial combat than on bombing damage. This should be clearly documented of course.)

What's the chance of 2 (3) fighters defeating a single defending jet fighter (assuming that the jet fighter keeps intercepting)?

When you apply the same formula on land interceptors, then it's important to choose the number of combat rounds correctly. In the original game, land interceptors aren't very lethal because of their limited amount of damage compared to the number of combat rounds. I think it's important to keep land interceptors less lethal than fighters. Land interceptors stop the bombing run, inflict damage on the bomber and can battle land units and helicopters. Aerial interceptors defeat the bomber but can't battle land units directly, they can't defend cities against land based attackers. Still, land based interceptors (with interception promotions) should sometimes destroy the bomber.
 
Oops ... I have now added the fact that there are 9 combat rounds to the above description.

It's certainly true that there's a much bigger jump in strength for fighters than any other pair of neighboring units. Here are some stats for sending multiple fighters to take out a Jet:

1st rookie fighter vs rookie jet
- Fighter does 21% damage per hit, 5 hits to kill
- Odds of 0 - 5 hits: 30%, 30%, 20%, 11%, 5%, 5%
- Expected damaged to jet: 31%

2nd rookie fighter vs rookie jet at 70% health
- Fighter does 23% damage per hit, 4 hits to kill
- Odds of 0 - 4 hits: 20%, 25%, 21%, 14%, 20%
- Expected damage to jet: 69%

3rd rookie fighter vs rookie jet at 31% health
- Fighter does 26% damage per hit, 2 hits to kill
- Odds of 0 - 2 hits: 6%, 10%, 84%

So, with between rookies 2 fighters have an okay chance at winning while with 3 the odds are pretty good.

If the fighters have some experience then things look better ... a Combat II fighter can expect to do 39% damage so a pair will win more than 1/2 the time. For Combat IV expected damage leaps to 55% so a pair will win most of the time.

------------------

Yeah, I'm with you on land interceptors ... they should generally not be a threat to healthy bombers or fighters without promotions.
 
Okay... here's another air-related question. The piece of code below is from 3.17. This function has been significantly augmented by the Better AI team. I just need some help interpreting the original code, please! :)

Code:
void CvUnitAI::AI_defenseAirMove()
{
	CvCity* pCity;

	if (getDamage() > 0)
	{
		getGroup()->pushMission(MISSION_SKIP);
		return;
	}
	

	if ((GC.getGameINLINE().getSorenRandNum(2, "AI Air Defense Move") == 0)) - question: Why this random check?
	{
		pCity = plot()->getPlotCity();

		if ((pCity != NULL) && pCity->AI_isDanger()) - question: If the city is in danger?...
		{
			if (AI_airStrike()) - question: ...carry out airstrike on a unit?...
			{
				return;
			}
		}
		else - question: ...but if the city is NOT in danger?...
		{
			if (AI_airBombDefenses()) - question: ...carry out airbomb defenses?...
			{
				return;
			}

			if (AI_airStrike()) - question ...or carry out an airstrike?
			{
				return;
			}
			
			if (AI_getBirthmark() % 2 == 0) - question: What is this?
			{
				if (AI_airBombPlots())
				{
					return;
				}
			}
		}


Thanks!! :D
 
1. Randomness is used in many places where it is either difficult for the programmer to define the single best action for the unit or too time-consuming to determine enough information to make the right decision. It also makes the AI unpredictable, as a human player would be. In cases like this one, it's often possible to find ways to improve the logic with a bit of thought and time.

2. Yes, if there is any enemy unit within 2 spaces I think.

3. Yes, airstrike hits units.

4. Correct, if either the unit is not in a city (highly unlikely for planes with this AI type) or the there are no enemy units within two squares.

5. Yes, it would look for enemy cities to bomb defenses (I believe it only does this if it has attackers nearby).

6. Yes, it would then look for units to hit.

7. Yeah, those are funny. Basically, the programmer didn't want every plane to air bomb plots, instead of using a random number they decided to make it a consistent random decision ... only planes with an even birthmark (like an id number) will consider bombing plots. I think the reasoning here is that an odd numbered plane in a safe city will keep destroying enemy plots, if they used a random dice toss every turn it would eventually go through to the following logic which I believe may set it to airpatrol. In vanilla bts defensive planes don't wake up from patrolling unless attacked. So, if the situation remained constant, half the AIs planes would continue to bomb plots and half would be air patrol. If they used a dice toss, 1/2 would go on air patrol the first time, then it'd be 3/4, then 7/8, etc.

Hope that helps ...
 
Thanks for the help, I am satisfied that I managed to read the code and not severely misunderstand the code! :D In the Better AI, as far as I can see, there's a much improved routine for determining "danger" to a city/base, and some more diverse behaviour for different circumstances. I like how you have commented on a lot of the code! :goodjob:
 
Would it be possible for some help on how to implement this new air combat code for those of us not using the Better AI mod?
 
You'll need to merge over the air combat source code from BBAI to your mod and recompile the DLL.

In particular, you'll need the changes in CvUnit::airMaxCombatStr and CvUnit::resolveAirCombat. They're marked with comments.

Thanks. To sum up this discussion, to make promotions more meaningful it was deemed to increase the number of combat rounds and reduce the damage each round - this has the side effect that you will end up with more damaged air units - requiring a mod to the AI to allow damaged air units the ability to enter intercept mode.
 
Top Bottom