Overview
Hierarchical state machines are born as solutions to the flaws with standard finite-state machines. The biggest issue is complexity of the representation. With classical finite-state machines, it is difficult to express the following examples:
"During any attacking or wandering behavior, run away if the enemy boss appears." "When a flash grenade is thrown, enter dodge mode!" "The attack behavior consists of the tasks of finding, following, and shooting at the enemy." "The camping behavior is independent from weapon management."
The flat nature of finite-state machines does not allow these concepts to be expressed. The four following criteria can be identified from such examples [Harel87]:
Clustering— The first example indicates the need to group together all states for attacking and wandering. The compound state itself is known as a superstate. General transitions— In the second case, there's a need to express a transition from any state, so that the behavior is overridden. Refinement of states— Some behaviors in the finite-state machine are defined as a combination of other simpler activities. The third case is an example of this. Independence and orthogonality— The fourth point illustrates that components of a system are not always directly connected.
The first three properties can be captured using a hierarchical model. The last property is about concurrency instead, and can be considered separate.
|