Creating Emotions as Finite States

Another component is included in the overall AI architecture to handle emotions. Internally, it is composed of two nested finite-state components, handling sensations and emotions.

Finite-State Machine for Emotions

The finite-state machine used to model the four emotions contains four states. However, each emotion is associated with two states, such that each state corresponds to two emotions. When pairs of complementary emotions are considered as dimensions, the finite-state machine can be understood as a 2D grid as shown in Figure 39.1. This enforces the restriction that two complementary emotions may not be active at the same time.

Figure 39.1. The four different mood states, each with two emotions.

graphics/39fig01.gif

The finite-state machine is fully connected, so there are transitions from each state to every other. The conditions for the transitions are left generic, and are defined by the sensations. The design of this finite-state machine is therefore frozen. All the flexibility comes from the sensations finite-state machine, which defines active emotions; transitions in this finite-state machine match the desired mood.

Each state contains specific values for each of the parameters used to control the behaviors. These are defined in Table 39.2, but can be adjusted by the designers. The parameters are defined for the turn and move actions, and the visual senses are defined as follows:

  • Accuracy indicates the randomness of an action; a value of 1.0 means the requested action is executed, a value of 0.0 means that a randomized action is picked based on the request.

  • Power is used to scale the value of actions. A 0 power means the animat is completely frozen, whereas 1 power implies the actions have their maximal value (turning and moving).

  • Delay represents the number of seconds after which an event is passed to the animat. A 0 delay means the animat perceives the object as it appears, whereas there may be almost a second delay in other cases.

  • Precision defines how the senses interpret the position of objects in space. A value of 1 indicates the position is exact, whereas 0 means that a large random value is added to distance and angle.

Table 39.2. Parameter Values That Affect the Behaviors Based on the Current Mood (Precision and power affect the actions, whereas delay and accuracy affect the senses.)
 

Surprise

Anticipation

Fear

Precision 0.7

Precision 0.9

 

Power 0.2

Power 0.4

 

Delay 0.0

Delay 1.0

 

Accuracy 0.9

Accuracy 0.2

Anger

Precision 0.0

Precision 0.1

 

Power 1.0

Power 0.9

 

Delay 0.3

Delay 0.8

 

Accuracy 0.8

Accuracy 0.3

Finite-State Automaton and Sensations

A finite-state automaton is used to process the perceptions into concise sensations that can be interpreted by the finite-state machine used for emotions. An example finite-state automaton is shown in Figure 39.2. Because these sensations are crafted by the designer (and the emotions are frozen), they implicitly affect the personality of the animats. Some creatures may be likely to react better in combat, whereas others become complacent when nothing happens. These personalities can be controlled indirectly by adjusting the sensations.

Figure 39.2. Finite-state automaton to recognize the sensations based on the stimuli.

graphics/39fig02.gif

The system could be modeled with only one finite-state automaton with five states (one start state and four states corresponding to the recognized sensations). Arbitrary intermediate nodes can be used to simplify the model as necessary. Although this approach is the simplest possible, it does not provide much diversity in the behaviors. Instead, using one finite-state automaton for each of the moods provides the flexibility to customize each of the transitions, while still keeping the complexity of the system low.

Integration

The two finite-state components are built separately, but need to work closely together to produce the final system. The stimuli from the environment are passed as events to the finite-state automaton. The sensations are passed asynchronously as messages to the finite-state machine modeling the emotions, as shown in Figure 39.3. With this approach, the emotional state is always up-to-date, driven reactively in a very efficient fashion.

Figure 39.3. Integration of the sensations and the emotions using message passing.

graphics/39fig03.gif

Similarly to biological creatures, the emotions are experienced subconsciously. In this system, the moods are essentially an underlying layer for the AI already developed. The previously developed AI architecture is therefore required as another layer to provide the intelligence.

These two layers need to interact for the mood to affect the behavior, as shown in Figure 39.4. The mood is queried by sensor and effector components that manifest the emotions (that is, vision queries or movement actions). Depending on the component, the emotions are queried on-the-fly when necessary or they are passed by messages and cached.

Figure 39.4. High-level view of the architecture with the emotions and the reactive behaviors working independently. The emotions affect the senses and actions with parameters.

graphics/39fig04.gif



AI Game Development. Synthetic Creatures with Learning and Reactive Behaviors
AI Game Development: Synthetic Creatures with Learning and Reactive Behaviors
ISBN: 1592730043
EAN: 2147483647
Year: 2003
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net