Flylib.com

Books Software

 
 
 

AI Game Development: Synthetic Creatures with Learning and Reactive Behaviors - page 32

Summary

AI development is fundamentally an engineering task:

  • The requirements and design goals must be quantified .

  • The traditional approach to game AI is highly controllable, closely integrated with the game engine.

Recent developments in modern games have improved upon this, notably by borrowing modern ideas from AI. This trend progresses toward embodied animats with learning capabilities:

  • Genuine embodiment can improve behaviors and reduce the need to "fake" behaviors individually.

  • Embodiment is good practice because it formalizes the interfaces between body and brain, providing guidelines to separate the AI from the logic and simulation.

  • Learning comes in a variety of different flavors, appropriate in many situations.

  • Learning can be done online or offline, in supervised or unsupervised forms.

Achieving this can be surprisingly difficult:

  • Much background knowledge is required; programming skills are assumed in this book.

  • There are guidelines for the AI development process, but this is a rough sketch that needs customizing.

  • Iteration and testing is the backbone of success in AI, just as in game development.

The next chapter covers reactive techniques and AI architectures, showing how they can help improve game development.

Chapter 3. Reactive Approach

Key Topics

  • Definitions

  • Behaviors: Planning Versus Reactive

  • Reactive Techniques in Game Development

  • Architectures

The AI techniques and behaviors used in this book share a common trait: They are all reactive components . The reactive approach is ideally suited to computer games because it's so simple and efficient. The predictability is also a tremendous advantage for design and testing. Contrary to popular belief, mostly reactive systems can be made to be extremely competent, rivaling approaches based on planning. This chapter shows how to achieved this in the design of the AI system, combining reactive components together.

This chapter covers the following topics:

  • The definition of the term reactive , in mathematical and practical terms

  • The difference between reactive techniques and planning, and two different approaches to solving similar problems

  • The numerous benefits of reactive AI in games

  • Reactive architectures that combine reactive behaviors and techniques

Reactive techniques are the most successful in the field of AI and have been demonstrated in a great majority of computer games. Before this discussion turns to the benefits and pitfalls of this approach, we need to understand the capabilities of reactive AI.

Definitions

The term reactive has two meanings. The first sticks to the formal description -not too common during practical applications. The second is a much slacker meaning, allowing for small deviations from the theory.

Reactive by Definition

Whether behaviors or techniques, all AI components take an input and produce an output. For reactive AI, there is a particular property about the output; given a specific input, it will always be the same.

This can be interpreted as a function in the mathematical sense (see Figure 3.1). Each configuration in the domain (input) corresponds to only one configuration in the codomain (output). Naturally, these functions can take multiple input values and return multiple outputs, but this can be understood as one single configuration on the input and output.

Figure 3.1. A reactive mapping from the input to the output. The mapping is deterministic, because no ambiguity exists. All the inputs are assigned to one output only, but outputs may correspond to multiple inputs ( many-to-one function).

graphics/03fig01.gif

Often, these functions are known as many-to-one . None of the inputs correspond to multiple outputs, so there is no ambiguity. Each output is fully predictable for this reason. Such components are therefore known as a deterministic .

Practically speaking, a reactive behavior always does the same thing in the same situation. A reactive component makes the same decisions, and outputs the same predictions for identical input conditions, which is particularly appropriate for computer games . Designers and producers tend to prefer predictable results.

Reactive in Practice

In theory, a reactive component would have absolutely no sense of state ; it has no memory, however small. If it did, the mapping between domain and codomain would not be deterministic; an output that depends on a state variable potentially varies output based on the same input.

Strictly speaking, internal feedback is not reactive either for the same reason. If the preceding output is used to determine the next value, the same input could also lead to a different output. Both these examples reflect nondeterminism .

Using a small trick, it's also possible to consider these techniques as reactive (see Figure 3.2). If we consider the internal state, or the feedback connection, as another input, the mapping is once again reactive! There is no longer any ambiguity when the internal variables that would make the component nondeterministic are instead exposed as inputs.

Figure 3.2. A nondeterministic component can be interpreted as reactive if the internal state values are considered as an input. The state also may be updated reactively.

graphics/03fig02.gif

So in practice, components with a small sense of state or feedback connections are considered as reactive. Even when a small random factor is used to perform the mapping, it can be considered as reactive, too; the random number could be interpreted as an additional input.