Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1047935 Posts in 42482 Topics- by 34356 Members - Latest Member: modred11

October 01, 2014, 12:18:47 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Dogfighting AI
Pages: [1]
Print
Author Topic: Dogfighting AI  (Read 723 times)
GroZZleR
Level 0
***



View Profile WWW
« on: April 20, 2013, 04:49:46 PM »

Hey all,

I'm working on a sidescrolling dogfighting game and am looking to make it more exciting.

Right now the AI follows the following pattern:

Step 1
Acquire a target.  The AI weights the "score" of the target by comparing distance and health, so it's smart enough to go for weaker enemies that are further away (within reason).

Step 2
Head towards the target, turning as necessary, until it's lined up for a strafing run.  If it fails to align with the target within 2 seconds, it bails and moves to step 4.

Step 3
Firing the guns for a couple of seconds, continuing to angle at the target.

Step 4
Turn around and fly away for a couple of seconds, then back to step 1.

This actually works pretty damn well 1 on 1 against a human.  The AI will come at me, shoot a few times, fly away and do it again.  They're quite slippery to get in behind and take out.

The problem comes when AI is battling each other, especially when they're further away from the larger clump of other fighters.  I'll often be flying across the field and see this:



They've acquired each other (due to the distance from other fighters), are attempting to line up the shot, give up, fly in the opposite directions for half a second then rinse and repeat.

I could add a check for the AI to never target something that's already targeting it, but that feels... incorrect (for lack of a better word).

Anyone done something similar?  Any advice on how to prevent "dog chasing its tail" syndrome?
Logged

Moromis
Level 0
***



View Profile WWW Email
« Reply #1 on: April 20, 2013, 10:43:07 PM »

Step 1
Acquire a target.  The AI weights the "score" of the target by comparing distance and health, so it's smart enough to go for weaker enemies that are further away (within reason).

I could add a check for the AI to never target something that's already targeting it, but that feels... incorrect (for lack of a better word).

Why not just weight the player as a higher target? In your screenshot it looks as though you are about the same distance from the AI, so the closer one, if the player had an added modifier to the "score", will break off the attack of the other AI within that time frame of step four, and then begin its attack on the player, as to feel natural.

In some ways, having the AI never target another AI might be the way to go. Basically, the gist of what I'm trying to say is, the AI want to attack the player more than the other AIs. Even though this might sound like it will make it unbalanced, as long as no more than one or two planes chase the player, it should actually only add to the player experience. Really, in these types of games (I think), the AIs main purpose is to add some realism to the battle (the chaos of battle), and pick off some of the other AI.
Logged


Live 3-6 PST

Mai sounds

Mai arts
Daid
Level 1
*



View Profile
« Reply #2 on: April 20, 2013, 11:04:16 PM »

You might want to add an override condition where it sees an possible target in front of itself and starts to shoot that, no matter the previous target.

Also, if you add some randomness to the "fly away" step you might be able to break the cycle? Also add some randomness to the 2 second "try to align" step. A bit of randomness in timing is great to break up synchronized AI cycles.
Logged

Columbo
Level 0
***


View Profile
« Reply #3 on: April 21, 2013, 12:05:11 AM »

The problem comes when AI is battling each other, especially when they're further away from the larger clump of other fighters.  I'll often be flying across the field and see this:

So, sometimes as a player you stop targeting enemies and fly to a different portion of the map?

Maybe you should get your AI to do that too, perhaps Step 4 should have a small random chance of the AI just deciding to stop targeting enemies for a bit and fly to a different region of the map.

Doing that, as well as Daid's suggestions could make the AIs feel a bit more organic.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #4 on: April 21, 2013, 12:24:11 AM »

Is it a problem with your gameplay, rather than the AI? If it's a dogfighting game, you can expect players to attempt a lot of maneovering like this too - you don't really want it to be the case that it is *possible* to circle each other indefinitely - one of the players should have an angle of attack that is superior, or the constant loops cause both planes to plummet, or something.
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #5 on: April 21, 2013, 07:16:45 AM »

Just a quick note that's a bit off topic, but you might want to look into proportional navigation.  Instead of changing angle to look at the current position of the target, you want to minimize the LOS rate to properly lead the target.
Logged
GroZZleR
Level 0
***



View Profile WWW
« Reply #6 on: April 21, 2013, 10:13:38 AM »

Lots of good responses, thanks guys.

@Moromis
It's a FFA deathmatch style game so I'm hesitant to weight the player more heavily than anything else.  Out of 16 participants, if even 4 are constantly chasing the player, that's somewhat insurmountable.  I'll try it out and see how brutal it is.

@Daid
I did add a little fuzz to the timings to help break the habit before posting.  It fixed the problem for any large clumps but left isolated 1v1 instances intact.  I like the idea of picking up new targets automatically if they're in a cone of sight check, I'll pursue that further.

@Columbo
I mostly see it happening when I die and respawn on a different side of the map.  I'll add another (random) step where they just fly off in a random direction for a bit and see how that improves things.

@BorisTheBrave
I like the manoeuvre but I don't like that they do it endlessly.  The flight mechanics are actually more top down with a sidescroller perspective.  There's no gravity or stalling or anything like that.

@Fallsburg
That would probably work a lot better.  I'll take a stab at it if I can find something less "mathy" than the wiki.  Wink
Logged

Dragonmaw
Global Moderator
Level 10
******


Notorious D.R.G.


View Profile
« Reply #7 on: April 24, 2013, 12:57:58 PM »

As an aside, that behavior is a pretty common one even amongst players. I saw it a lot when I was testing a dogfighting game. The best way to counter it, from experience, is to add in stalling and differing turn speeds. That way you can safely dis/reengage.
Logged

My religion consists of a humble admiration of the illimitable superior spirit who reveals himself in the slight details we are able to perceive with our frail and feeble mind.

-Snoop Dogg
saluk
Level 1
*


View Profile Email
« Reply #8 on: April 30, 2013, 01:32:34 PM »

Add other slightly different behaviors and have the ai get bored. If one behavior is not really accomplishing anything they might want to switch. Some alternate behaviors - try and lead a chasing opponent for some time and then loop around to get behind, looping the long way around rather than the short way, or rapid switching of targets trying to get off a few shots at each. Ideally, the ai in this situation will eventually have different behaviors than each other to stop the deadlock.

Or, a simpler approach - choose the 2nd best or 3rd best target at random every so often, rather than always choosing the best.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic