ABSTRACT

Finite-state machines are an architectural structure used to encapsulate the behavior of discrete states within a system and are commonly used in games for AI, animation, managing game states, and a variety of other tasks. This chapter discusses how to use transition objects to create encapsulated, reusable objects for managing transitions. This allows designers to compose the overall behavior of an enemy by selecting the appropriate states, choosing transitions for those states, and setting the necessary parameters. The chapter has only touched on the surface of finite-state machine architecture. It is very simple and light-weight, yet flexible enough to allow a considerable amount of power and control. This architecture can be applied directly to AI needs, but there are a few takeaways that can apply to any architecture. The power of the transition objects to decouple the states from one another comes from a common programming design pattern called the strategy pattern.