Post by Dutch Owen on Sept 2, 2019 15:20:08 GMT -5
Captains,
This section is going to go in the final manual but I think of it as "in development" here. No doubt some of this will change and as it does I'll try to keep this documentation updated.
Most programs that implement some form of combat AI try and keep exactly how it works a secret. Not here. I want to share this with everyone for at least two reasons. First, I think of FSCAI as a cooperative development. I'm sure many of you will have good ideas on how to supplement this logic and improve it. All ideas are welcome - although not all can be implemented within the constraints of development effort and the limited ability to "think" when running on a machine with a flight simulator taking up 95% of the processor leaving 5% at most for us.
How do A.I. Pilots Think?
Well, they don't. But they do follow rules. Here's what they are. (The following only applies to pilots. Ground units use somewhat different logic. Also the targeting sections here do not apply to wing-men of the user. They obey his orders and don't select their own air targets. However once engaged they follow the rules documented here.)
Who is an A.I. Pilot?
For our purposes it's an airplane in flight that has been weaponized by FSCAI and is controlled either by the simulator (FSX,P3D) itself on a flight plan or on an FSX mission (or a P3D scenario) - or, an airplane in flight controlled by the script of an FSCAI mission.
How does he find targets?
When in flight and not engaged he is constantly scanning for enemies - once per second. If his airplane has a radar he uses it, if he has ground sensors he uses those, and he always keeps his eyes open and his head on a swivel. His ability to see an enemy by radar is limited to the radar's range and scanning azimuth (cone). The same with any ground sensors. For the Mark I eyeball he is limited either to the ambient visibility range where he is, or if it's CAVU he's limited to a maximum visibility range that extends between 5 and 10 nautical miles depending on his skill rating. He cannot see anything if he's in a cloud, and he cannot see an enemy if the enemy is in a cloud. There is usually a zone behind the aircraft where the pilot cannot see easily - this varies by aircraft but any enemy in that zone won't be quickly seen even if within visibility range. Every so often a pilot "checks six" and goes to trouble to look behind him. Less skilled AI pilots don't do this as often as skilled ones. It's possible to sneak up on these rookies from the rear if done quickly. An ace will see you.
Note: there are no practical "line of sight" computations possible in FSX/P3D. Therefore we have no way of detecting obstacles between the AI pilot and an enemy. He can therefore magically see through clouds or even terrain between him and another object.
When an enemy is first seen the pilot's first action is to target him. He then checks with his teammates to see if anyone else is targeting that same enemy. If so, he checks to see if he can target anyone else, and if so, will switch targets. AI pilots try to find a target that no one else is targeting and only if they can't will they gang up on one enemy. They will not target any enemy that already has two friendlies on him even if they have no other target to choose from.
What happens then?
That depends on if the enemy located is in the air or on the ground. Once an AI has targeted an airborne enemy (remember that can be an unfriendly AI or the user airplane if it's on another team) the pilot will go immediately into an engagement mode called PURSUIT. If it's a ground target we compute a position called the IP (Initial Position) and the aircraft starts to fly to the IP location.
We will discuss air and ground targets separately because they are very different.
Air: PURSUIT
The heart of the ACM logic in FSCAI is the PURSUIT function. Everything else is just a variation that will lead back to PURSUIT.
PURSUIT commands the attacker to fly towards the enemy; turning, climbing or descending as necessary. Speed is set as a function of distance from the target - the closer we are the closer we fly to the target's airspeed, the further we are the faster we go to close the distance. Depending on the angle between the attacker and the target a certain amount of lead is figured as the point the attacker is aiming for, but zero lead is sometimes appropriate.
Once per second the positions of the attacker and target are re-evaluated to see if anything has changed. These are the possible results of the evaluation:
- FIRE: We are within the range and other parameters of the currently equipped weapon and can shoot.
- CHASE: We are generally behind the target and closing but not within weapon range yet.
- TRANSITION: We are in a gray area between an offensive position and defensive one.
- BREAK: The target is generally behind us but no within weapon range (compliment of CHASE)
- EVADE: The target is behind the attacker and within his weapon range of us (compliment of FIRE)
- MERGE: if the attacker and target are merging head-on
- POST-MERGE: when the attacker and defense exit MERGE as they pass one another.
- END: the target is out of range and we are not closing even at maximum speed.
Depending on this status the pilot may choose to stay in PURSUIT or change temporarily to another maneuver.
If the status is FIRE then the weapons will be fired (guns or a missile) and since we are behind the target airspeed will be slowed to prevent an overshoot. We remain in PURSUIT.
If the status is CHASE or TRANSITION we simply remain in PURSUIT which will always try to keep us flying towards the target. Always.
If the status is BREAK or EVADE we need to go defensive, and the pilot will semi-randomly chose an appropriate maneuver. There are currently six possibilities: go high vertical to the left or right, continue a horizontal turn to the left or right, or go low vertical to the left or right. If it's EVADE we will always go vertical. No matter what is chosen if it's not to remain in PURSUIT it will be executed as a temporary change and when complete the pilot will return to PURSUIT in hopes of getting into offensive position again.
If we are MERGING then the pilot will fire any weapon he can when in range. If it's a gun he will fire in short bursts until passing in POST-MERGE. If it's a missile he will not fire a second until he evaluates the result of the first shot, and so on. Rarely in a jet MERGE does he get off more than two missiles, often only one.
When we pass into POST-MERGE the pilot makes the same decisions as he would for a status of BREAK.
If the status is END we disengage: they are running away and we can't catch them.
How Does it All End?
The above repeats until the end conditions are reached. One is the END status above. The other is damage. The AI pilot does not quit until his target either escapes him or his target is disabled or destroyed or the AI himself is disabled. (Unless he is engaged by a more dangerous opponent, then he will switch targets to his attacker.) What exactly do we mean by disabled and destroyed?
When FSCAI starts up all weaponized aircraft are considered to be a full health (100%). When they are shot that health will take a hit, with the amount of the hit depending entirely on the potency rating of the weapon that did the hit versus any mitigation rating of the object that took the hit. Potency ratings are supplied in the database for each weapon and range from 1 to 200. A potency of one, if not mitigated, would do 1% damage per hit and thus require 100 hits to destroy an object, and 50 hits to disable it. A potency of 200, the max, would do 100% damage in just one hit even with a mitigation rating of 100 on the target - thus a potency of 200 is a guaranteed kill. This is rare and would be used only for the biggest bombs. An air-to-air missile would typically have a potency of 100 meaning if it hits directly it will destroy the aircraft. A bullet might have a low potency of 10, meaning it would take 5 bullet hits to disable an aircraft and 10 to destroy it. That's how potency and damage works.
If you see an aircraft that's smoking but still flying reasonably well it has been disabled. If you see it smoking and it's spinning towards the ground it's been destroyed.
An AI pilot will disengage once his target is smoking - that is, it's 50% or above in damage. Any aircraft that's 50 percent or above will disengage from its target if it has one, and it will not target anything else. It will steer towards home if possible. It's out of the fight. AI will not target it anymore. As a user you have the option to continue to shoot it until it goes down but there is no point and this could cost you, as another enemy could be closing on you as you try and finish off the first unnecessarily. (This has cost many real-life pilots their lives.) The AI pilot will also disengage in the unfortunate circumstance that he's expended all the ammo in all his weapons.
This ends the discussion on air targeting and engagement.
Ground Targets: IP, Inbound, Run-in, Outbound.
An AI aircraft targets a ground object based on simple rules. If more than one is detected (by eye or sensor) then the closest air defense target is selected. If there is no air defense target seen then the closest non-air-defense target is selected for attack.
As already mentioned as soon as the attacker targets a ground object an Initial Point is calculated that's determined by the speed of the attacker and the elevation of the defender. A ground attack consists of a series of phases which the attacker will repeat until the target is at least disabled. If when the IP is first set the attacker is within weapon range he will immediately go to the phase RUN-IN. If he is not within weapon range already he will fly to the IP and once there he will start the INBOUND phase.
It's important to realize that in all phases except OUTBOUND there is a once-per-second check of weapons to see if they are in range, and if so, the RUN-IN phase will be selected.
INBOUND phase: We fly directly from the IP to the target. If our weapon of choice is a missile or a bomb we will remain level at the IP altitude. If it's rockets or guns, we will calculate a point at which a 1000 FPM glide would get us directly on the target and when that point is reached we will start the glide to the target. Whenever we can fire a weapon we go to RUN-IN.
RUN-IN phase: We are approaching the target within range of a weapon. When all parameters are met the munitions will be released according to the Burst parameter in the Database. If the weapon is missile or a gun then the RUN-IN is continued with the possibility of another shot. If the weapon is a bomb or rocket the attacker will transition immediately to OUTBOUND after munitions are released. He will always transition to OUTBOUND once he is past the target. If at any point a better weapon gets within range during run-in the pilot will select that better weapon.
OUTBOUND phase: The attacker flies back to the IP. If at any point in this (or any) phase the target is disabled or destroyed he will search for another ground target and if none is found he will disengage, otherwise the ground targeting (and a new IP) starts all over again with a new target. Once the attacker either reaches the IP itself or any distance beyond the distance from the IP to the target he will transition to the INBOUND phase. This process will repeat relentlessly until the target is disabled or destroyed or the attacker runs out of ammo (or, if a wingman, is given another order by the flight leader.)
Weapon Selection.
Currently up to eight weapons can be attached to an AI aircraft. (In the future we may expand that limit but we are resistant to doing it because AI aircraft in FSCAI should be generic simplified versions of the real thing and not have too many weapons hanging off them, even if the real aircraft could have many more than eight.)
The first two "slots" have a special meaning. For any aircraft role that will target another aircraft (Fighters and Fighter/Bombers) the first slot is the "primary air-to-air weapon". For a fighter/bomber or an Attack-role aircraft, the second slot is the "primary air-to-ground" weapon. For aircraft that don't target other aircraft except in defensive mode (bombers or transport roles) all weapons are equal.
Except some weapons are more equal than others. The order of the weapons is important. Those listed first will be used first, given that their parameters are met. Therefore in the database preferred weapons should be listed before lesser weapons. For example in an attack aircraft that can fire guided air-to-ground missiles and also use bombs, rockets, and guns it would usually be best to list the missiles first since they are the most accurate and deadly (and therefore the best to use against air defense targets which are always the first to be selected when there's a choice.) Then bombs, first guided ones then unguided. Then rockets, then last a gun for strafing.
Regardless, the AI pilot will select the "best" weapon as the first he has in his list that has ammo and is within range and other parameters. He doesn't think beyond that. it's up to the one who created the aircraft in the FSCAI database to list the weapons in priority order. Don't put guns in the primary air-to-air when you have a missile available.
This is the end of the explanation.
Comments are welcome!
Thank you for reading all that.
Dutch
This section is going to go in the final manual but I think of it as "in development" here. No doubt some of this will change and as it does I'll try to keep this documentation updated.
Most programs that implement some form of combat AI try and keep exactly how it works a secret. Not here. I want to share this with everyone for at least two reasons. First, I think of FSCAI as a cooperative development. I'm sure many of you will have good ideas on how to supplement this logic and improve it. All ideas are welcome - although not all can be implemented within the constraints of development effort and the limited ability to "think" when running on a machine with a flight simulator taking up 95% of the processor leaving 5% at most for us.
How do A.I. Pilots Think?
Well, they don't. But they do follow rules. Here's what they are. (The following only applies to pilots. Ground units use somewhat different logic. Also the targeting sections here do not apply to wing-men of the user. They obey his orders and don't select their own air targets. However once engaged they follow the rules documented here.)
Who is an A.I. Pilot?
For our purposes it's an airplane in flight that has been weaponized by FSCAI and is controlled either by the simulator (FSX,P3D) itself on a flight plan or on an FSX mission (or a P3D scenario) - or, an airplane in flight controlled by the script of an FSCAI mission.
How does he find targets?
When in flight and not engaged he is constantly scanning for enemies - once per second. If his airplane has a radar he uses it, if he has ground sensors he uses those, and he always keeps his eyes open and his head on a swivel. His ability to see an enemy by radar is limited to the radar's range and scanning azimuth (cone). The same with any ground sensors. For the Mark I eyeball he is limited either to the ambient visibility range where he is, or if it's CAVU he's limited to a maximum visibility range that extends between 5 and 10 nautical miles depending on his skill rating. He cannot see anything if he's in a cloud, and he cannot see an enemy if the enemy is in a cloud. There is usually a zone behind the aircraft where the pilot cannot see easily - this varies by aircraft but any enemy in that zone won't be quickly seen even if within visibility range. Every so often a pilot "checks six" and goes to trouble to look behind him. Less skilled AI pilots don't do this as often as skilled ones. It's possible to sneak up on these rookies from the rear if done quickly. An ace will see you.
Note: there are no practical "line of sight" computations possible in FSX/P3D. Therefore we have no way of detecting obstacles between the AI pilot and an enemy. He can therefore magically see through clouds or even terrain between him and another object.
When an enemy is first seen the pilot's first action is to target him. He then checks with his teammates to see if anyone else is targeting that same enemy. If so, he checks to see if he can target anyone else, and if so, will switch targets. AI pilots try to find a target that no one else is targeting and only if they can't will they gang up on one enemy. They will not target any enemy that already has two friendlies on him even if they have no other target to choose from.
What happens then?
That depends on if the enemy located is in the air or on the ground. Once an AI has targeted an airborne enemy (remember that can be an unfriendly AI or the user airplane if it's on another team) the pilot will go immediately into an engagement mode called PURSUIT. If it's a ground target we compute a position called the IP (Initial Position) and the aircraft starts to fly to the IP location.
We will discuss air and ground targets separately because they are very different.
Air: PURSUIT
The heart of the ACM logic in FSCAI is the PURSUIT function. Everything else is just a variation that will lead back to PURSUIT.
PURSUIT commands the attacker to fly towards the enemy; turning, climbing or descending as necessary. Speed is set as a function of distance from the target - the closer we are the closer we fly to the target's airspeed, the further we are the faster we go to close the distance. Depending on the angle between the attacker and the target a certain amount of lead is figured as the point the attacker is aiming for, but zero lead is sometimes appropriate.
Once per second the positions of the attacker and target are re-evaluated to see if anything has changed. These are the possible results of the evaluation:
- FIRE: We are within the range and other parameters of the currently equipped weapon and can shoot.
- CHASE: We are generally behind the target and closing but not within weapon range yet.
- TRANSITION: We are in a gray area between an offensive position and defensive one.
- BREAK: The target is generally behind us but no within weapon range (compliment of CHASE)
- EVADE: The target is behind the attacker and within his weapon range of us (compliment of FIRE)
- MERGE: if the attacker and target are merging head-on
- POST-MERGE: when the attacker and defense exit MERGE as they pass one another.
- END: the target is out of range and we are not closing even at maximum speed.
Depending on this status the pilot may choose to stay in PURSUIT or change temporarily to another maneuver.
If the status is FIRE then the weapons will be fired (guns or a missile) and since we are behind the target airspeed will be slowed to prevent an overshoot. We remain in PURSUIT.
If the status is CHASE or TRANSITION we simply remain in PURSUIT which will always try to keep us flying towards the target. Always.
If the status is BREAK or EVADE we need to go defensive, and the pilot will semi-randomly chose an appropriate maneuver. There are currently six possibilities: go high vertical to the left or right, continue a horizontal turn to the left or right, or go low vertical to the left or right. If it's EVADE we will always go vertical. No matter what is chosen if it's not to remain in PURSUIT it will be executed as a temporary change and when complete the pilot will return to PURSUIT in hopes of getting into offensive position again.
If we are MERGING then the pilot will fire any weapon he can when in range. If it's a gun he will fire in short bursts until passing in POST-MERGE. If it's a missile he will not fire a second until he evaluates the result of the first shot, and so on. Rarely in a jet MERGE does he get off more than two missiles, often only one.
When we pass into POST-MERGE the pilot makes the same decisions as he would for a status of BREAK.
If the status is END we disengage: they are running away and we can't catch them.
How Does it All End?
The above repeats until the end conditions are reached. One is the END status above. The other is damage. The AI pilot does not quit until his target either escapes him or his target is disabled or destroyed or the AI himself is disabled. (Unless he is engaged by a more dangerous opponent, then he will switch targets to his attacker.) What exactly do we mean by disabled and destroyed?
When FSCAI starts up all weaponized aircraft are considered to be a full health (100%). When they are shot that health will take a hit, with the amount of the hit depending entirely on the potency rating of the weapon that did the hit versus any mitigation rating of the object that took the hit. Potency ratings are supplied in the database for each weapon and range from 1 to 200. A potency of one, if not mitigated, would do 1% damage per hit and thus require 100 hits to destroy an object, and 50 hits to disable it. A potency of 200, the max, would do 100% damage in just one hit even with a mitigation rating of 100 on the target - thus a potency of 200 is a guaranteed kill. This is rare and would be used only for the biggest bombs. An air-to-air missile would typically have a potency of 100 meaning if it hits directly it will destroy the aircraft. A bullet might have a low potency of 10, meaning it would take 5 bullet hits to disable an aircraft and 10 to destroy it. That's how potency and damage works.
If you see an aircraft that's smoking but still flying reasonably well it has been disabled. If you see it smoking and it's spinning towards the ground it's been destroyed.
An AI pilot will disengage once his target is smoking - that is, it's 50% or above in damage. Any aircraft that's 50 percent or above will disengage from its target if it has one, and it will not target anything else. It will steer towards home if possible. It's out of the fight. AI will not target it anymore. As a user you have the option to continue to shoot it until it goes down but there is no point and this could cost you, as another enemy could be closing on you as you try and finish off the first unnecessarily. (This has cost many real-life pilots their lives.) The AI pilot will also disengage in the unfortunate circumstance that he's expended all the ammo in all his weapons.
This ends the discussion on air targeting and engagement.
Ground Targets: IP, Inbound, Run-in, Outbound.
An AI aircraft targets a ground object based on simple rules. If more than one is detected (by eye or sensor) then the closest air defense target is selected. If there is no air defense target seen then the closest non-air-defense target is selected for attack.
As already mentioned as soon as the attacker targets a ground object an Initial Point is calculated that's determined by the speed of the attacker and the elevation of the defender. A ground attack consists of a series of phases which the attacker will repeat until the target is at least disabled. If when the IP is first set the attacker is within weapon range he will immediately go to the phase RUN-IN. If he is not within weapon range already he will fly to the IP and once there he will start the INBOUND phase.
It's important to realize that in all phases except OUTBOUND there is a once-per-second check of weapons to see if they are in range, and if so, the RUN-IN phase will be selected.
INBOUND phase: We fly directly from the IP to the target. If our weapon of choice is a missile or a bomb we will remain level at the IP altitude. If it's rockets or guns, we will calculate a point at which a 1000 FPM glide would get us directly on the target and when that point is reached we will start the glide to the target. Whenever we can fire a weapon we go to RUN-IN.
RUN-IN phase: We are approaching the target within range of a weapon. When all parameters are met the munitions will be released according to the Burst parameter in the Database. If the weapon is missile or a gun then the RUN-IN is continued with the possibility of another shot. If the weapon is a bomb or rocket the attacker will transition immediately to OUTBOUND after munitions are released. He will always transition to OUTBOUND once he is past the target. If at any point a better weapon gets within range during run-in the pilot will select that better weapon.
OUTBOUND phase: The attacker flies back to the IP. If at any point in this (or any) phase the target is disabled or destroyed he will search for another ground target and if none is found he will disengage, otherwise the ground targeting (and a new IP) starts all over again with a new target. Once the attacker either reaches the IP itself or any distance beyond the distance from the IP to the target he will transition to the INBOUND phase. This process will repeat relentlessly until the target is disabled or destroyed or the attacker runs out of ammo (or, if a wingman, is given another order by the flight leader.)
Weapon Selection.
Currently up to eight weapons can be attached to an AI aircraft. (In the future we may expand that limit but we are resistant to doing it because AI aircraft in FSCAI should be generic simplified versions of the real thing and not have too many weapons hanging off them, even if the real aircraft could have many more than eight.)
The first two "slots" have a special meaning. For any aircraft role that will target another aircraft (Fighters and Fighter/Bombers) the first slot is the "primary air-to-air weapon". For a fighter/bomber or an Attack-role aircraft, the second slot is the "primary air-to-ground" weapon. For aircraft that don't target other aircraft except in defensive mode (bombers or transport roles) all weapons are equal.
Except some weapons are more equal than others. The order of the weapons is important. Those listed first will be used first, given that their parameters are met. Therefore in the database preferred weapons should be listed before lesser weapons. For example in an attack aircraft that can fire guided air-to-ground missiles and also use bombs, rockets, and guns it would usually be best to list the missiles first since they are the most accurate and deadly (and therefore the best to use against air defense targets which are always the first to be selected when there's a choice.) Then bombs, first guided ones then unguided. Then rockets, then last a gun for strafing.
Regardless, the AI pilot will select the "best" weapon as the first he has in his list that has ammo and is within range and other parameters. He doesn't think beyond that. it's up to the one who created the aircraft in the FSCAI database to list the weapons in priority order. Don't put guns in the primary air-to-air when you have a missile available.
This is the end of the explanation.
Comments are welcome!
Thank you for reading all that.
Dutch