Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by gania, 8 years ago) (diff)

AI

TracNav(TracNav/TOC_Development)?

Overview

Current AI is implemented in the hierarchy of classes FormationController, ArtificialController, AIController, WaypointController and WaypointPatrolController.

New set of classes are being created in this: ticket:263.

The basic features of new AI are:

  • Fighting: AI tries to dodge bullets
  • Flying: AI flies in divisions of 4 spaceships
  • Actionpoints: Just like waypoints, actionpoints can be set in XML file.

==Structure== When alone, every AI class does the same. To make AI fight smart, different AI Controllers are to be assigned to several spaceships:

DivisionController makes 4 spaceships fly in formation. It manages most of the logics of the division, which consists of 1 DivisionController, 1 SectionController and 2 Wingmen.

==Fighting== When fighting, DivisionController fights in pair with its WingmanController and SectionController in pair with its Wingman. Those two sections of two ships try to attack different targets in order to achieve maximum damage output.

AI tries to separate Wingman in Leader into attacker and defender, so that enemies waste their time trying to kill one while another finishes them off.

==Formations== In XML file different formation types can be set to DivisionController: WALL, FINGER4 and DIAMOND. Although they don't have a great effect on a gameplay, one might find DIAMOND or FINGER4 to look nicer than a simple WALL.

==Actionpoints== Actionpoints are implemented as state machines in their own class called ActionpointController, which is a parent class of Division-, Section-, and WingmanController. Basic states are:

*NONE: spaceship tries to pop the next actionpoint from the stack *FIGHTALL: spaceship fights all the enemies on the map (if DivisionController, its division fights together with it) until all the enemies are dead. *ATTACK: attacks a specific target until target is dead. *PROTECT: follows a specific target until no protection required (when that spaceship dies). *FLY: flies to a specific point.

More than one Actionpoint can be attached to a controller, resulting in a slightly complex behaviour, for example, following code would result in a spaceship firstly attacking a spaceship with a name "attack", then trying to protect a human player, if none is spawned or human dies, it protects a spaceship with a name "protect", then it fights all enemies on the map:

<SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
      <templates>
        <Template link=spaceshipassff />
      </templates>
      <controller>
        <DivisionController team=0 formationMode="finger4">
          <actionpoints>
            <Actionpoint position="0,0,0" action="FLY" /> 
            <Actionpoint position="-1000,750,-500" action="ATTACK" attack="attack" />
            <Actionpoint position="-1000,750,-500" action="PROTECt" protectMe=true />
            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="protect" /> 
            <Actionpoint position="-1000,750,-500" action="FIGHTALL" />
           </actionpoints>
        </DivisionController>
      </controller>
</SpaceShip>