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 Logic
Tweaking the AI of game characters is a big part of an AI programmer’s
job. If the project is particularly large, this can prove to be a very frustrat-
ing experience as each change to the code may involve a lengthy
recompile. Fortunately, this can be avoided by utilizing a scripting lan-
guage. I don’t mean by this that scripting languages should be used to write
speed-critical portions of AI code — such as the code required to do a
graph search, for example — but that scripts may be used to write the deci-
sion logic of your game agents. For example, if your agent uses a finite
state machine, rather than hard-coding the states, you can expose the inter-
face of your agent class (and any other relevant classes) to the scripting
language and write scripts for each state, enabling the agent’s flow of logic
to be easily adjusted. This means you can tweak until your heart bursts
without any of the usual inconvenience of sitting around waiting for
recompiles. Far Cry and Unreal Tournament are a couple of examples of
games that use scripts in this way.
Scripting in Lua
Over the last five years a scripting language called Lua has increased in
popularity with game developers and has been used to provide scripting for
many notable games including:
n
Escape from Monkey Island
n
MDK 2
n
Grim Fandango
n
Baldurs Gate
n
Impossible Creatures
To Script, or Not to Script, That Is the Question | 255
Scripting in Lua
Screenshot 6.5. Black & White
Ó Lionhead Studios Limited
Content removed due to copyright restrictions

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