Chapter 41. Hierarchical State Machines

Complex behaviors are difficult to create as regular finite-state machines. Tasks can generally be decomposed into increasingly detailed subtasks. (For instance, playing deathmatch relies on the capability to gather items, attack, and defend.) This approach is reminiscent of AI architectures in general—as discussed throughout this book. In the case of finite-state machines, individual finite-state machines are designed in the normal fashion, but these are accumulated in layers by nesting finite-state machines within each other. Thanks to abstraction and modularity, hierarchical finite-state machines (HFSMs) significantly reduce the complexity of the asset development pipeline. Hierarchies, however, do not increase the computational power of the system.

This chapter covers the following topics:

The problems with finite-state machines that are resolved using hierarchies.

The different types of hierarchies commonly used with finite-state machines, notably nested states and nested finite-state machines

Semantics that formalize the interaction between levels in the hierarchy. The system is simulated according to these principles.

The advantages and disadvantages of HFSM.

The technology presented in this chapter is used in the next chapter to improve the model of animat emotions.