11
\$\begingroup\$

In the past, I've used simple systems like finite state machines (FSMs) and hierarchical FSMs to control AI behavior. This pattern falls apart very quickly or any complex system.

I've heard about behavior trees. They seem like the next obvious step, but I haven't seen a working implementation or really tried it yet.

What other patterns can make complex AI behaviors manageable?

\$\endgroup\$
2
  • \$\begingroup\$ I also heard there are several ways to manage state machines \$\endgroup\$
    – jokoon
    Apr 22, 2011 at 19:02
  • 1
    \$\begingroup\$ This is a pretty vague question. There are many techniques for managing "complex" AI but the best one for any given situation may be different from another situation. I've implemented fairly complex AI using nothing but behavioral action lists, but that solution woudln't work for an RTS; the techniques I've seen used in RTS games were incredibly complex yet still elegant, however they'd be all but worthless in any other kind of game. If you've got some specific kind of game or AI in mind, you might get more relevant and insightful answers if you state what that is up front. \$\endgroup\$ Nov 18, 2011 at 5:39

3 Answers 3

3
\$\begingroup\$

Behaviour trees are a really great way to manage AI, and Ai Game dev is the best place to learn about them! There are tonnes of example implementations out there on places like Codeplex, or even AIGD's own Sandbox engines implementation (which admitedly is fairly complex and can be hard to follow).

Last year at the game AI confrence there was alot of excitement about planners, but this year alot of that had fallen away. Best tip seemed to be just to start simple. The whole 20% of the work to get you 80% there thing seems to totaly hold true in most cases

\$\endgroup\$
2
\$\begingroup\$

One think I think is important is to seperate why an agent wants to acomplish something from how it does it. Goal-orientated Action Planners do this well, but there are also other solutions. This gives you great flexibility for constructing agents as you can pick and choose from a bucket of goals and a bucket of actions.

Behaviour trees are designed to ecompass the whole solution - decision making as well as actions - and as such can be hard to maintain.

\$\endgroup\$
2
\$\begingroup\$

One technique you should be familiar with in any case is the action list approach. At the simplest level, it's just a list of action objects, which each action object has its update() method called each frame. You can quickly expand on this however to allow blocking actions, multiple lanes of actions, child groups, etc. Just about anything you can build with a high-level FSM can be implemented in a more modular, flexible, and debuggable fashion with an action list using behavior actions.

Aside from being a useful technique for managing all the animation, path finding, and other miscelleneous "stuff" your characters can do, it makes it trivial to implement a priority-based decision making system by creating behavior actions.

A few notes about how to use them can be found in this slide deck: http://sonargame.com/2011/11/01/new-game-slides/

Pretty sure there's been articles about it in the AI Programming Wisdom series, too.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .