JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
  Previous Section Next Section


The animat's moods are implicit and are not easy to identify at first glance. Nonetheless, the emotions certainly have an effect on the gaming experience over time. The changes in the animat's behaviors can be understood with observation and insights into the underlying model—although printing out the emotional state in the debugger also helps.

Despite the AI behaviors being identical, this emotional model provides more diversity in the behaviors. In terms of the shooting behaviors, the emotions have a similar effect to the context-dependent aiming errors—but applied throughout the AI in a biologically plausible fashion. This leads to unexpected situations arising, which makes the game more interesting. In no cases were the behaviors unacceptable in terms of realism, although the skills of the animats occasionally seemed rather poor (because of the negative effect of the emotions degrading the senses and actions).

That said, the emotional model is incredibly simple to adjust. The values of the manifestations are stored in a configuration files and modifiable with a text editor, which allows easier experimentation. The precision or delay attributes can be changed by the game logic, or even by the players themselves, to adjust the skill dynamically.

Technically speaking, the system showcases the benefits of a modular approach to AI. The existing modules providing the intelligent behaviors remained completely unchanged, and the emotions are inserted as an additional layer in the architecture. The emotional layer is completely independent from the reactive behaviors. This design pattern provides the base of a better model, which is explained in Chapter 42.

This system suffers technically because of the limitations of finite-state machines. The transitions are Boolean; the mood changes states completely or it stays the same. As a consequence, the emotions are essentially black and white, with no shades of gray possible—although this is not immediately obvious in the behaviors. The emotions are also very predictable, and remain the same throughout the game.

There are minor issues with emotions changing too quickly. Because mood changes can be triggered by sensations, a quick succession of stimuli could cause rapid changes in mood. Luckily, the way the animats emotions are portrayed (degradation of the senses) does not cause unrealistic behaviors. In general, a low frequency of updates to the emotions can be used to prevent such oscillations (for instance, manually driven rather than by events).

From a design point of view, the improvement in realism is already noticeable, but choosing only four emotions limited the full potential of the technology. It would be particularly challenging to implement more emotions with the finite-state machine, because the number of transitions necessary would grow exponentially.

Practical Demo

The animat demonstrating the ideas in this chapter is called Moody and can be found on the web site along with the other examples at Based on the AI of the previous parts, the architecture includes two kinds of finite-state components to implement the emotions. These emotions are portrayed by degrading the senses and effectors.

      Previous Section Next Section

    JavaScript EditorAjax Editor     JavaScript Editor