Thursday, June 21, 2012

Musing about AI in Battlestar

These are just thoughts on AI to this point.

First, the AI routine needs to incorporate a timer mechanism.  The two basic update features an update by frame and an update at an interval.  Update at an interval is already an integral part of the game design and is set at ten update per second.  That is subject to change; however, it won't explode to a timeframe more conductive to manuevers.  In addition, it won't vary (which is a likely need for manuevers) during an actual mission.

Second, there are a large number of factors that go into selecting the "best" target.  The previous prototype had a simple AI, mostly to test features.  It consisted of a check against the DradisList (under a different name in the previous prototype) and checked the range and direction (in relation to the fighter).  Based off of these factors (distance and how in front the target was - distance being a slightly larger weight) it selected a target.  This created a very predictible flight pattern.  In this prototype, I want to create a more realistic and complex AI process.

Each fighter will need a standard stance: aggressive, balanced and defensive.  These will give different weight to different options.  An aggressive stance will more likely take an attack option; while a defensive stance will concentrate on avoiding damage.  Stances can change over the course of a mission; however, they can also stay static depending on the needs of the mission. 

In addition, each fighter should have a mission target option (represented by a game object related variable).  Fighters will have an option to ignore fighters (depending on circumstance) and attack the mission target.  Mission targets are more likely to be engaged with missiles, and the attack vector should be longer (i.e. engage at a distance) than a fighter versus fighter scenario.  I'm not sure if I advocate a mission target then looking for a target of opprotunity or weighing each target while using a single selection routine.

Fighter engagements need to be based on the current circumstances in the battlespace.  Factors could be:

Is there a target behind me?  How do I handle a trailing target?

Is there a target in front of me with a reasonable distance? 

Are there other factors like a closing fighter that need to be addressed?

Are there objects that I'm about to hit?  Which way is the best direction to travel if there are?

Am I about to travel into a "fire zone"?  Is it worth going into a "fire zone"?

A "fire zone" is the generally the area between to capital ships while both ships are firing on each other.  The bullets and missiles in this area are generally considered hazards, and BSG has traditionally handled this as a no-fly zone.

Third, if a fighter selects an attack pattern or a defensive manuever, how long should the fighter keep that engagement?  If it gets hit, will it continue pursuit?  Or will it turn and engage the offending target?  Or, will it execute evasive manuevers?  If I'm following a target with high hopes of destroying, do I worry about a trailing fighter behind me?  Do I continue with the engagement?  Do switch targets?  Do perform evasive manuevers and look for another target when I'm safe? 

If I engage a target and destroy, it's an easy call to go back to the selection process.  If I get hit, going back to the selection / decision process is pretty clear.  If someone is following me, I probably should go back to the decision process. 

Fourth, avoidance routines should always be on.  It breaks immersion when a Cylon raider (or a colonial viper for that matter) rams a capital ship for no reason.  There should be a forward raycast for each ship with a distance check for a hit.  Depending on the ship, it should perform an avoidance routine at certain distances.  However, should it go back to a decision process or attempt to reengage it's previous target? 

Fifth, fighters need to perform some form of "formation" flight.  Basically, fighters should also follow an ally to provide cover.  This is a difficult thing to emulate.  It's also a difficult thing to add to the decision process.  In addition, it might be difficult to calculate how long a fighter stays in formation.  It's been said in the fighter community (real world and many fictional worlds) to never abandon your wingman.  How far does that need to be taken to provide a fun but somewhat realistic game. 

So many considerations...  I have a headache now. 

1 comment:

  1. great blog - not sure what a DradisLIst is but I get the general idea.  My overall recommendation would of course be to take my fall game programming course in which we will work through the Millington/Funge book "Artificial Intelligence for Games" :-)

    but more specific immediate advice is to start with simple routines and a small amount of randomization without worrying about higher level "rationality"

    the ghosts in pacman are a great example, they basically move toward the player, but something like a 1/3 of the time they don't - I think the key thing for your flight AI is to select targets probabilistically (rather than determinisitically) according to the distance (and other) criteria

    either which way I worry that you'll burn a lot of energy tweaking this at the high level, when the critical thing for others starting to play it is the right sort of AI for novices ... I'll play your game again next week - would be great if we could get a whole training sequence online ...

    ReplyDelete