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

The gameplay is similar to a Quake-style deathmatch. When commenc
-
ing a game, several AI controlled bots are spawned that run around the map
attempting to make as many kills as possible and picking up weapons and
health as needed. If a bot is killed, it immediately respawns with full health
from a random spawn point and the position where it was killed is marked
by a “grave” for several seconds.
A bot can be selected by right-clicking on it once. When selected, a red
circle will be drawn around the bot and additional AI-related information
will be drawn to the screen depending on what options are set in the menu.
Right-click on a selected bot, and you will “possess” it — it will be
under your control. A possessed bot is encircled in blue and can be moved
by right-clicking on the part of the map you’d like it to travel to. The navi
-
gation AI of the bot will automatically provide assistance by planning the
shortest path to the chosen location. The aim of the bot is controlled by the
mouse. Because a bot is able to aim independently of the direction of its
movement, a possessed bot will always face in the direction of the mouse
cursor. A left click will fire the bot’s current weapon in the direction of the
mouse cursor. (For ranged weapons, such as the rocket launcher, the target
is the cursor position.) You can change weapons (provided the bot is carry-
ing more than one) by pressing the keys “1” to “4”. A bot is released from
your control by right-clicking on a different bot or by pressing the “X” key.
Ü
NOTE Although when you play the game you can see all the other bots
clearly, each bot’s AI is only able to see other bots that are within its field of
view and not obscured by walls. This makes the design of the AI much more
interesting. The FOV is set in the Raven/params.lua file.
Overview of the Game Architecture
In this section we’ll examine the key classes that comprise the game frame
-
work. Figure 7.1 shows an overview of how the high-level objects
interrelate.
296 | Chapter 7
Overview of the Game Architecture

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