You are on page 1of 12

Goal-Oriented

Behavior
Goal-Oriented Behavior
• So far we have focused on approaches that react: a set of
inputs is provided to the character, and a behavior selects an
appropriate action.
• There is no implementation of desires or goals. The character
merely reacts to input.
• It is possible, of course, to make the character seem like it has
goals or desires, even with the simplest decision making
techniques. A character whose desire is to kill an enemy will
hunt one down, will react to the appearance of an enemy by
attacking, and will search for an enemy when there is a lack of
one. The same character may also have the apparent desire
to stay alive, in which case it will take account of its own
protection, reacting to low health or the presence of danger.
• The underlying structure may be reacting to input, but the character
doesn’t need to appear that way. In our experience, this is a fundamental
misunderstanding that academic AI folk often have about game AI: it
doesn’t matter what is controlling the character, as long as it looks right.

• There are techniques we can use to make the character more flexible in its
goal seeking, however, and in some game genres this is a useful approach.
It is particularly visible in people simulation games, such as The Sims
[Maxis Software, Inc., 2000].

• In a game such as The Sims, there is no overall goal to the game. In other
titles such as Ghost Master [Sick Puppies Studio and International Hobo
Ltd., 2003], there is a definite aim (you try to scare the inhabitants out of
a house using various ghosts and supernatural powers).

• In this kind of game a wide range of different actions is available to


characters. Actions might include boiling the kettle, sitting on a sofa, or
talking to another character. The action itself is represented by a canned
animation.
• Characters need to demonstrate their emotional and physical
state by choosing appropriate actions. They should eat when
hungry, sleep when tired, chat to friends when lonely, and hug
when in need of love. We could simply run a decision tree that
selects available actions based on the current emotional and
physical parameters of the character. In a game such as The
Sims, this would lead to a very big decision tree. There are
literally hundreds of parameterized actions to choose from for
every character.
• A better approach would be to present the character with a suite
of possible actions and have it choose the one that best meets its
immediate needs.
• This is goal-oriented behavior (GOB), explicitly seeking to fulfill
the character’s internal goals. Like many algorithms in this book,
the name can only be loosely applied.
• GOB may mean different things to different people, and it is
often used either vaguely to refer to any goal seeking decision
maker or to specific algorithms similar to those here. We’ll use it
as a general term. We’ll look at a very simple GOB framework
and a utility-based GOB decision maker. We’ll also look at goal-
oriented action planning (GOAP), an extension to the basic GOB
system that can plan sequences of actions to achieve its goal.

• In this section we will look at a utility-based decision making


system that can choose from a range of actions based on its
current goals.
Goals
• A character may have one or more goals, also called motives.
There may be hundreds of possible goals, and the character
can have any number of them currently active. They might
have goals such as eat, regenerate health, or kill enemy. Each
goal has a level of importance (often called insistence among
GOB aficionados) represented by a number. A goal with a high
insistence will tend to influence the character’s behavior
more strongly.
• The character will try to fulfill the goal or to reduce its
insistence. Some games allow goals to be completely satisfied
(such as killing an enemy). Other games have a fixed set of
goals that are always there, and they simply reduce the
insistence when the goal is fulfilled (a character might always
have a goal of “get healthy,” for example, but at a low
insistence when they are already healthy). A zero value for
insistence is equivalent to a completely satisfied goal.
• We could easily implement goals without insistence values,
but it makes it more difficult to choose which goals to focus
on. We’ve chosen to use real numbers rather than Booleans,
because the resulting algorithms are no more complex. If your
game has thousands of characters with hundreds of goals, it
might be worth just using on/off goals and saving storage
space. In a game like The Sims, the character’s physical and
emotional parameters can be interpreted as goal values. A
character might have a hunger motive: the higher the hunger
value, the more eating becomes a pressing goal.
Actions
• In addition to a set of goals, we need a suite of possible
actions to choose from. These actions can be generated
centrally, but it is also common for them to be generated
by objects in the world.
• InThe Sims world, a kettle adds a “boil kettle” action and
an empty oven adds an “insert raw food” action to the
list of possibilities. In an action game an enemy might
introduce an “attack me” action, while a door might
expose a “lock” action.
• The actions available depend on the current state of the
game. The empty oven might check if the character is
carrying raw food before positing its “insert” action. An
oven containing raw food does not allow more food to
be added; it exposes a “cook food” action. Similarly, the
door exposes an “unlock” action if it is already locked or
maybe an “insert key” action first before unlocking
isallowed.
Performance
• The algorithm is O(n + m) in time, where n is the
number of goals, and m is the number of possible
actions. It is O(1) in memory, requiring only
temporary storage. If goals are identified by an
associated zero-based integer (it is simple do, since
the full range of goals is normally known before the
game runs), then the getGoalChange method of the
action structure can be simply implemented by
looking up the change in an array, a constant time
operation.

You might also like