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

Selectors


Selectors are the first type of nodes that can have children within the behavior tree. A selector can have any number of children, but will only execute the first child that is available for execution. Essentially, selectors act as if, if…else, and else structures within behavior trees. A selector will return true if at least one child node is able to run; otherwise, the selector returns false:

SoldierLogic.lua:

local function CreateSelector()
    return BehaviorTreeNode.new(
        "selector", BehaviorTreeNode.Type.SELECTOR);
end