ABSTRACT

The behavior tree algorithm implemented in the sample code is straightforward and assumes only the knowledge of a tree data structure. Each node in the tree is a behavior, with some precondition defining when that behavior should run and an action defining what the agent should do to perform that behavior. The Behavior and BehaviorTree classes can be taken “as is” and extended as needed. The LuaWrapper could also be taken as written, but ideally an engine would include functionality for reloading the Lua state at runtime, in order to take advantage of being able to rewrite behaviors and test them without restarting or recompiling the game. While the benefits of having script-defined behaviors are manifest, there are particular concerns that should be kept in mind if using the approach. The Behavior class itself can be improved to allow for faster processing of the tree.