Mincemeat said:
Hi,
Just wondering if Eddie would like to divulge a bit on how the current AI works at the moment, and any roadmaps for its development going forward.
If any future AI state machines can be lua scripted, I think it will be a godsend to the mod makers...
So the AI now is pretty dumb. Basically, it is attack unless we need to recharge guns or we have very little shields.
Code:
void ship::moveAI()
{
shouldavoid = World::getWorld().getObjectToAvoid(this, avoidlocation);
if(shouldavoid)
{
avoidCollisionAiState(avoidlocation);
}
else if(goal == SHIPGOAL_ATTACK)
{
if(shouldRecharge() )
{
avoidFighterAIState();
}
else
{
attackAIState();
}
}
else if(goal == SHIPGOAL_FORMWING)
{
formationAIState();
}
}
There's much work to add on the AI. Right now I have a
path followingAI that isn't being used yet. Basically, you draw a series of lines in space, and the AI will follow it. This will be used to implement higher level maneuvers.
For higher level maneuvers, first you have to figure out what state you're in. Once you figure out the state, you choose an appropriate high level maneuver. Here are my notes on this
collision avoidance
CHUNK "ATTK" // I can attack
{
cstring "attack" // just point to them and shoot
cstring "chaseattack" // try to attack from behind
cstring "attackflee" // attack quickly, then afterburn away, repeat
cstring "componentattack" // oval around capship, the afterburn away
cstring "turretattack"
}
CHUNK "MISL" // missiles after me
{
cstring "launchchaff"
}
CHUNK "GUNS" // guns after me
{
cstring "rolloutavoid" // alternate combinations of rolling
cstring "pitchavoid"
}
CHUNK "AVDF" // avoid their fighter, may be in front, but we want to avoid due to low armor/energy
{
cstring "pitchavoid" // alternate combinations of vertical motions
cstring "yawavoid" // alternate combinations of horizontal motions
cstring "flee"
}
CHUNK "AVDC" // avoid capship
{
cstring "capshipflee"
}
CHUNK "CHAS" /// they're definitely behind us
// they're targeting me, distance < mindistance, they're behind
{
cstring "loop" // a circle, pull up
cstring "flee"
cstring "yoyo"
cstring "barrelroll" // do a corkscrew. Roll while pulling up
}
If anyone has any better ideas on what these high level maneuvers look like, or any concrete AI suggestions let me know. I haven't implemented any of these high level ideas yet, except path following.
Once I get them going, probably path construction, goal switch, docking, will be scriptable, but that's only after I've gotten the basic maneuver choices coded up.
The low level AI is based on the work of Craig Reynolds called
Steering Behaviors.
I'm relatively happy with collision avoidance now, the formation flying is ok, but I still need to get them the banking aligned a bit more.