Sign in to follow this  
codeman_nz

Fighter control system

Recommended Posts

codeman_nz    255

Hi everyone,

 

I want to create a system which controls fighters in combat (i.e. aerial combat).  How would I go about that?  Would I use some kind of flocking system?

 

Thanks.

Share this post


Link to post
Share on other sites
alvaro    21263
Probably not. I thought about this type of game many years ago, and my plan was to make the decisions be about maneuvers that the pilot can perform. You can find a list here. You can then try to have some probabilistic model of what the other planes will do and try to compute a utility (i.e., a score) for the resulting positions after each hypothetical maneuver you may take. The action with the highest expected utility should be chosen.

You can also have something a bit dumber that will have a list of condition-maneuver pairs that you can check sequentially. When one of the conditions is satisfied, pick the associated maneuver.

Anyway, I never implemented any of it, so I am not sure how good you can make it look. But if you are completely lost, it's probably a reasonable place to start.

Share this post


Link to post
Share on other sites
LorenzoGatti    4449
I don't think flocking is likely to be a commonly useful fighter behaviour. The closest realistic situations are approaching objectives in formation before combat, which is more constrained than random flocking (there is a designated leader and fixed positions), and pursuit of enemies, which is going to be far more complex than trying to go where the enemy is (with coordinated team positioning, choices between aligning weapons to shoot and steering to reduce distance, evasive maneuvers, accounting for multiple weapon ranges, etc.) and carefully combined with other general behaviours.

Share this post


Link to post
Share on other sites
wodinoneeye    1689

This in its full extent is a problem of handling uncertainty, and planning and taking actions which result in optimizing future utility of the situation.  You want to be put into the best position for a firing solution while at the same time avoiding being vulnurable.  SInce you dont know what the enemy object will do you have to move to positions offering the best future possibilities.

 

It of course is even greater complexity if cooperation of multiple objects is desired.

Share this post


Link to post
Share on other sites
Jon Alma    406

This will possibly repeat some of the feedback already given but a lot of this will depend on what type of game you are creating.  If you are aiming at a flight simulator (or something close) then there a variety of maneuvers (such as the  Immelmann turn) that could be implemented (and which flight simmers would probably hope to see).  If on the other hand you are developing a real time strategy game then you can probably get away with simpler movement AI that gives the impression of real flight without overloading the processor with AI management (critical as the number of units for the AI to control in a RTS game is likely to be higher than in a flight sim).  

 

Personally (for a RTS) I started with simple flocking / collision avoidance code (which quickly gave me something good to look at and work from) before then adding unit targeting (flight to a waypoint or target another aircraft).  From there I added formation flying (flight towards a constantly updated waypoint which is actually a position in a formation).  

 

What really helped was having a two layer AI, the first dealing with the tactical situation (movement in the next few loops of the game logic concentrating on avoiding other aircraft and the ground, working out what is the best way to orientate towards the waypoint / target, rotating turrets and firing weapons ... oh and crashing which is fairly simple AI occasionally involving parachutes) and a higher level AI dealing with the 'strategic' situation (choosing a target or the next waypoint, responding to being attacked, deciding whether to run for it if damaged, checking if there is any fuel left, etc).  Despite taking a while to get right (and it still needs some final polishing) this two layer approach (coupled with a third, squadron level logic) really made the organisation of the AI pretty easy to conceptualise and break down.  While the AI is the big overhead in my code I can now effectively handle dogfights between anything up to (and beyond) 80 aircraft without the lights starting to flicker and brown-out. 

 

If performance is poor there are two things that can be done,

 

  • Simplify the AI for out of sight objects (simplify collision detection or even ignore it,  don't actually fire weapons and track projectiles but just apply damage to the target, etc) - if the player cannot see the AI being more stupid then it isn't really a problem (although initially I did have problems with quick switches from one unit to another distant unit resulting in the player admiring aircraft happily flying upside down in formation ... tweaks to the simple AI and the application of a few loops worth of complex AI during the switch helped there).
  • Only process each unit's AI every few game loops (I actually have a game setting where the AI can be applied for every unit during each and every game loop ... which is fine for higher end machines, or every second, third, fourth, etc loop ... meaning that I can effectively cut the processor overhead by half, etc ... at the cost of an increasing number of poor collision detection decisions, etc as the frequency of the AI being applied for each unit drops).  Having something playable, but not as elegant on a lower end machine is in my view better than having the Rolls Royce solution that is unplayable due to the game effectively freezing up.

?

Share this post


Link to post
Share on other sites
Norman Barrows    7179

maneuver based AI can be too predictable if it doesn't change quickly enough. 2 seconds into a maneuver, I know what the enemy is doing, and can position myself for the kill. Real pilots don't assess the situation, select a maneuver, then blindly execute it, then reassess the situation. The situation is reassessed continuously, and maneuvers are adjusted appropriately on a continual basis. For this reason, i prefer a more dynamic AI that works at a lower level, simply dictating turn and accel rates, vs entire maneuvers. a layered strategy is then applied: 1. collision avoidance. 2. evasive maneuvers. 3. maneuver for kill. The ai then degenerates to simple rules like "badguy left, turn left", "badguy above, climb", etc. maneuvers can then be layered on top of this: "badguy behind and above, do Immelmann". this would kick off a "script" that would do a half loop followed by a half roll. but you don't just execute the "script". each "frame" you assess the situation. if you should continue the Immelmann, you continue running the "script", if not, you stop the Immelmann and do something else. the situation should be re-assessed, and the maneuver changed if needed, at least once per second to be sufficiently responsive. And an experienced pilot will notice that one second lag in decision making on the part of the AI. A good pilot will take advantage of it to get a leg up on the AI. A really good pilot will be disgusted by it as being too slow to react to the player in a timely manner. A full one second head start on your opponent is WAY too much of an advantage for a really good pilot.

Share this post


Link to post
Share on other sites
conq    735

maneuver based AI can be too predictable if it doesn't change quickly enough. 2 seconds into a maneuver, I know what the enemy is doing, and can position myself for the kill. Real pilots don't assess the situation, select a maneuver, then blindly execute it, then reassess the situation. The situation is reassessed continuously, and maneuvers are adjusted appropriately on a continual basis. For this reason, i prefer a more dynamic AI that works at a lower level, simply dictating turn and accel rates, vs entire maneuvers. a layered strategy is then applied: 1. collision avoidance. 2. evasive maneuvers. 3. maneuver for kill. The ai then degenerates to simple rules like "badguy left, turn left", "badguy above, climb", etc. maneuvers can then be layered on top of this: "badguy behind and above, do Immelmann". this would kick off a "script" that would do a half loop followed by a half roll. but you don't just execute the "script". each "frame" you assess the situation. if you should continue the Immelmann, you continue running the "script", if not, you stop the Immelmann and do something else. the situation should be re-assessed, and the maneuver changed if needed, at least once per second to be sufficiently responsive. And an experienced pilot will notice that one second lag in decision making on the part of the AI. A good pilot will take advantage of it to get a leg up on the AI. A really good pilot will be disgusted by it as being too slow to react to the player in a timely manner. A full one second head start on your opponent is WAY too much of an advantage for a really good pilot.

 

You're imposing gameplay components onto a broad idea. Take for example, a very fast paced flight game, where an immelmann can be completed in just 1/2 a second.

That's enough time for you to recognize the move, and bein reaction, but not line up your sights.

 

On the opposite spectrum, an AI that doesn't have a cheat sheet of effective moves is going to have situations where it makes very stupid choices.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this