Advertisement

Air combat AI

Started by January 09, 2016 03:35 AM
4 comments, last by warhound 8 years, 10 months ago

So I'm making a project for a bit of fun and was wondering what the AI for a air combat game is like. How are they implemented, most of the time? Is there something particularly different in these AIs from other game AIs? I'm not looking for anything too complicated, but still don't want these guys to look completely stupid.

I was thinking along the lines of perhaps just having some rules of thumb, i.e. if there's someone on your tail, then turn this way, or if someone is in your sights, shoot. Any advice would be greatly appreciated. Thanks.

No one expects the Spanish Inquisition!

Air Combat is a bit vague.

Would also help a bit to know if there would be things like missiles that are seeker weapons. 2d or 3d could make a big difference on what actions can be taken. Will there be multiple planes per side during a fight or is it 1vsCPU? How many planes in the air at once?

Once you have those answers figured out you can determine the states that a plane could be in.

General States--

Enemies on radar only

Enemies visible at long range

Close Enemies

Being Fired Upon

Being Chased by Seeker

etc.

Then from each general state you can determine the action to take.

Being Fire Upon--

Move Left

Move Right

Move Up

Move Down

Increase Speed

You could also put a timer on each state so the general state or the action state is only checked every several game loops. This would be so it keeps doing something without getting too erratic by switching action every main game loop.

Advertisement

Air Combat is a bit vague.

Would also help a bit to know if there would be things like missiles that are seeker weapons. 2d or 3d could make a big difference on what actions can be taken. Will there be multiple planes per side during a fight or is it 1vsCPU? How many planes in the air at once?

Once you have those answers figured out you can determine the states that a plane could be in.

General States--

Enemies on radar only

Enemies visible at long range

Close Enemies

Being Fired Upon

Being Chased by Seeker

etc.

Then from each general state you can determine the action to take.

Being Fire Upon--

Move Left

Move Right

Move Up

Move Down

Increase Speed

You could also put a timer on each state so the general state or the action state is only checked every several game loops. This would be so it keeps doing something without getting too erratic by switching action every main game loop.

So it's a 3d game with multiple aircraft on each side. One side will have seeker weapons (homing missiles) and guns while the other side uses advanced guns of sorts (think Independence Day alien weapons) and are also more maneuverable than the other side. They've also got access to stealth fields which enable need to be recharged after being used (for a limited time obviously). I may get rid of the stealth fields. The above advice does seem simple enough to do. Of course, if other people want to chime in with their thoughts, by all means I'd love to hear. Thanks again.

No one expects the Spanish Inquisition!

The key is to have layers, situation variables, and interrupts.

The layers are the top level AI state. Moving to waypoint, tracking target on radar, landing, etc.

The situation variables are things like "target at my 3 o'clock", "target at my 6", "on ILS approach", etc.

Then you have decision tables based on the layer and situation. ( I tend to use a state machine so the decision tables become code subroutines)

To make the game more interesting, add simple fuzzy logic to add randomness.

Example


Calculate situation variables
            Aircraft at 30000 feet, airspeed 350 knots, ammo state good, fuel state good, enemy at 6 O'clock high.

Build a decision table 
           Break right                   40%
           Break left                    40%
           Immelman                      10% 
           Zoom climb                     5%
           Split S                        4%
           Panic                          1%

Randomise result and set state

          Break left selected

You then have small subroutines that actually execute the maneuver.

I can go into more detail if you would like.

you could also check how ai behaves on sims like f22 lightning 2 or 3 or f/a 18 operation iraqi freedom, (motion of ai is fixed and they always pitch, yaw roll by some defined angles, no matter what)

The key is to have layers, situation variables, and interrupts.

The layers are the top level AI state. Moving to waypoint, tracking target on radar, landing, etc.

The situation variables are things like "target at my 3 o'clock", "target at my 6", "on ILS approach", etc.

Then you have decision tables based on the layer and situation. ( I tend to use a state machine so the decision tables become code subroutines)

To make the game more interesting, add simple fuzzy logic to add randomness.

Example


Calculate situation variables
            Aircraft at 30000 feet, airspeed 350 knots, ammo state good, fuel state good, enemy at 6 O'clock high.

Build a decision table 
           Break right                   40%
           Break left                    40%
           Immelman                      10% 
           Zoom climb                     5%
           Split S                        4%
           Panic                          1%

Randomise result and set state

          Break left selected

You then have small subroutines that actually execute the maneuver.

I can go into more detail if you would like.

Thanks a lot for this. This is quite helpful actually. I think that I could definitely work from this high level understanding.

you could also check how ai behaves on sims like f22 lightning 2 or 3 or f/a 18 operation iraqi freedom, (motion of ai is fixed and they always pitch, yaw roll by some defined angles, no matter what)

I will also look into this as well. I'm not looking for anything too complicated, but certainly these would be good starting points.

Thanks again.

No one expects the Spanish Inquisition!

This topic is closed to new replies.

Advertisement