Book Image

Learning Game AI Programming with Lua

By : David Young
Book Image

Learning Game AI Programming with Lua

By: David Young

Overview of this book

Table of Contents (16 chapters)
Learning Game AI Programming with Lua
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with AI Sandbox
Index

Creating evaluators


Creating evaluators relies on simple functions that perform isolated operations on the agent's userData table. Typically, most evaluators will only perform calculations based on userData instead of modifying the data itself, although there is no limitation on doing this. As the same evaluator might appear within a decision structure, care must be taken to create consistent decision choices.

Tip

Evaluators that modify userData can easily become a source of bugs; try to avoid this if at all possible. Actions should modify the agent's state, when evaluators begin to modify the agent's state as a decision structure is processed; it becomes very difficult to tell how and why any eventual action was chosen, as the order of operations will affect the outcome.

Constant evaluators

First, we'll need to create the two most basic evaluators; one that always returns true, and another that always returns false. These evaluators come in handy as a means of enabling or disabling actions...