JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
  Previous Section Next Section

Crafting Tactical Behaviors

Tactical behaviors are high-level components composed of primitive actions. Defining commonly used behaviors not only assists human engineers in developing strategies, but also simplifies the task of learning AI.

Reusing and Customizing Capabilities

Because most behaviors exhibit common functionality, each will depend on the components developed throughout this book (for instance, moving, shooting, or selecting weapons). This is shown in Figure 45.1. Although the behaviors depend on common functionality, the parameters passed to these components are customized as necessary.

Figure 45.1. Hierarchy of dependencies with AI modules that are customized to provide specific functionality. The explore behavior relies on wandering movement, looking around, and selecting a weapon for rapid retaliation.


Some of the behaviors do not depend on existing capabilities because they are trivial to handle without modularity (for instance, looking around). In the other cases, customization can happen in multiple ways:

  • Runtime parameters— The interface is used to pass the custom information.

  • Initialization data— Information is stored in XML and loaded from disk.

  • Wrapper component— A simple component is used to simplify and customize the capability.

The tactical behaviors themselves can be created freely with any technique. Most behaviors discussed in this book are well suited to managing the functionality of nested components in a hierarchy. For example, finite-state machines consider nested states as dependent functions; rule-based systems depend on functionality to provide the body of production rules; scripts or native programming languages can be used.

Despite each of the child components being customizable, we'll assume that each of the behaviors can be called without any parameters (an Explore() function, in this case). Nevertheless, the behaviors can—and often will—be context dependent; the parameters will be gathered implicitly by the behaviors (for instance, query of the environment).

Sample Behaviors

Using the behaviors of human players as examples will assist the development of the AI. Neutral behaviors are analyzed first:

  • Explore— Attempt to cover as much terrain as possible using sight, assisted by movement.

  • Investigate— Move toward a point of interest in space and check the area.

  • Gather— Collect armor and items that provide health as needed.

  • Wander— Randomly patrol around a particular area.

In deathmatch games, offensive behaviors are needed to score points:

  • Attack— Fire projectiles at the enemy.

  • Hunt— Pursue enemies while assaulting them with weapons.

Naturally, there are defensive counterparts to these behaviors:

  • Dodge— Move out of the line of fire.

  • Evade— Avoid incoming projectiles and flee from the enemy.

  • Retreat— Move to safety away from a danger zone.

It should be possible to combine these behaviors to produce satisfactory deathmatch strategies.

      Previous Section Next Section

    JavaScript EditorAjax Editor     JavaScript Editor