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

Summing Up
This chapter has presented a flexible and powerful goal-based agent archi
-
tecture. You have learned how an agent’s behavior can be modeled as a set
of high-level strategies, each of which is comprised of a nested hierarchy
of composite and atomic goals. You’ve also learned how agents can arbi
-
trate between those strategies to select the most appropriate one to pursue
given the current game state.
Although it shares many similarities, this type of architecture is far more
sophisticated than a state-based design and will require some practice
before you are able to use it confidently. As usual, I’m going to end the
chapter with a few ideas you can play around with to help improve your
understanding.
Practice Makes Perfect
1. Decent human FPS players get a “feel” for when a particular item is
about to respawn. Indeed it’s not unknown for some deathmatch play-
ers to play with an alarm clock by the side of their monitor! The
Raven bots, however, currently haven’t a clue when an item is going
to respawn. Create a termination condition for the Dijkstra’s search
algorithm that calculates if an inactive (invisible) item type will
respawn in the time it takes to reach it, thereby enabling a bot to pre-
empt it.
2. The Raven bots have no defensive strategy. At the moment they just
attempt to hunt down an item type if they do not feel strong enough to
attack and hope this will lead them out of harm’s way. You will notice
when you watch the demo that this behavior often gets them into trou
-
ble since they make no attempt to dodge shots when pursuing an item.
Write the logic and any extra goals required to enable bots to detect
such situations and to dodge from side to side while still pursuing an
item type.
3. Add character scripting to Raven and create one or two scripted
sequences. This is a great exercise and will reinforce many of the
things you’ve learned so far. You don’t need to script anything com
-
plex. For instance, you could do something similar to the genie
example described earlier. Create a script from the players point of
view that goes like this: When the player stands in a certain position, a
bot enters the location from somewhere “out of view” (of course, this
isn’t really possible given the top-down nature of Raven, but you
know what I mean), stops in front of the player, says “Follow Me,”
and then leads the player to a random location.
414 | Chapter 9
Summing Up

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