Case Study

An essential part of navigation is the ability to avoid obstacles successfully. This accounts for many of the properties previously described. It's also a good place to start learning about game AI development because obstacle avoidance is a relatively simple task.

To understand how obstacle avoidance works, it is worthwhile to analyze the behavior in different situations. The following list is a representative selection of all the possible states that the game character may encounter. For each scenario, the situation is briefly described and the desired outcome is explained (see Figure 6.3):

Figure 6.3. Three different situations that require three different kinds of responses, ranging from quick turnaround to straight forward movement.

When no obstacles are in proximity of the animat, it can move forward normally. This can be either straight, or a wandering behavior.

In the case where walls are detected on one side, they should be turned away from slowly, in a preventive fashion.

If there is an obstacle in front, a turn should be engaged to clear the danger on one side.

For those situations where the animat is stuck in a corner, a more radical turnaround should be attempted.

This list of expected actions, together with the four criteria of motion explained previously, forms the requirements for our obstacle-avoidance behavior.