O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

AI Implementation
To imbue a bot with the illusion of intelligence we need to employ quite a
list of skills and abilities. Let’s walk through them and discuss how each is
implemented by the Raven bot AI.
Decision Making
For their decision-making processes Raven bots use an architecture based
around the arbitration of goals. The behavior necessary for a bot to win a
game is decomposed into several high-level goals such as “attack,” “find
health,” or “chase target.” Goals can be nested and it’s common for
high-level goals to be composed of two or more subgoals. For instance, the
“find health” goal is composed of the subgoals “find path to closest active
health item” and “follow path to item.” In turn, the goal “follow path” can
be decomposed into several “move to position” type goals.
Every time the decision-making component of a bot’s AI is updated,
each of the high-level goals is evaluated for its suitability given the bot’s
current status and the one with the highest score is selected as the current
goal. The bot will then decompose this goal into its constituent subgoals
and attempt to satisfy each one in turn.
This type of decision-making architecture is covered in detail in
Chapter 9.
Movement
For low-level movement the Raven bots make use of the steering behaviors
seek, arrive, wander, wall avoidance, and separation. There is no colli
-
sion detection or response between the bots and world geometry; the bots
rely entirely on wall avoidance and separation steering behaviors to nego
-
tiate their environment. (I’m not advocating that you should use this
approach in your own projects — your game will probably require much
stricter collision detection — but it’s adequate for the demos that accom
-
pany this book. It’s also a rather good demonstration of just how effective
steering behaviors can be if used correctly.)
Steering behaviors are implemented in the usual way described in previ
-
ous chapters. The
Raven_Bot class inherits from a MovingEntity and
instantiates its own instance of the familiar steering behavior object. AI
components that influence a bot’s movement use the interface to this
instance to control the movement of the bot.
Path Planning
The bots in Raven must be able to plan paths through their environment in
order to move to a target location or toward an instance of a game item
Raven: An Overview | 315
AI Implementation

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required