Game Development Reference
AI is used primarily for decision making in NPCs that allow them to find their
way around maps and interact intelligently with other players. Occasionally,
novel uses such as machine learning are employed to create characters that
can learn from the game environment and the player, such as the creatures in
Black & White .
Artificial intelligence algorithms require a lot of computational processing.
In the past, after all the animation and special effects were placed in a game,
only about 10% of the computer's processing capabilities remained for AI. This
has stunted the development of AI in games for quite a while. However, with
advances in technology, more and more AI is creeping in.
Some examples of AI in games include:
• F.E.A.R. A first person shooter (FPS) in which the player must outsmart
supernatural beings. It uses planning algorithms that allow characters to
use the game environment in a smart way, such as hiding behind objects
or tipping them over. Squad tactics are also used to present formidable
enemies that can lay down suppression fire and perform flanking
• Halo. An FPS in which the player must explore an extraterrestrial
environment while holding back aliens. The aliens can duck for cover
and employ suppression fire and grenades. Group tactics also cause
enemy troops to retreat when their leader is killed.
• The Sims. A god view game in which the player controls a household of
virtual people called Sims. This game introduced the concept of smart
objects that allowed inanimate objects in the environment to provide
information to the characters on how they should be used. The Sims
themselves are driven by a series of basic desires that tell them when
they are hungry, bored, tired, and so on.
• Black & White. This god view game has the player in the role of an actual
god overseeing villages of little people while trying to dominate the
villages of other gods. The player is given a creature in the form of a
gigantic animal such as a tiger. This creature is programmed with an AI
technique called belief-desire-intention, which makes the character act
based on what it might need or want at any particular time.
Artificial intelligence is a theoretically intensive field grounded in applied
mathematics, numerical computing, and psychology. This chapter provides but
a scrapping of what the domain has to offer games. It is a gentle introduction
designed to give you an appreciation for the field and to fuel your desire to
experiment with its use in your own games.
5.2 Line of Sight
The simplest method for programming an NPC to follow the player and
thus provide it with modest believable behavior is using the line of sight.
Put simply, the NPC sees the player, turns to face the player, and travels