Game Development Reference
In-Depth Information
The behavior tree node
Behavior trees are composed solely of different types of nodes. Based on the node type, the
behavior tree will interpret child nodes as actions and evaluators. As we'll need to distin-
guish each node instance type from one another, we can create an enumeration of all sup-
ported node types: actions, conditions, selectors, and sequences.
Creating an instance of a behavior tree node merely sets the node type and the name of the
node:
BehaviorTreeNode.lua :
BehaviorTreeNode = {};
BehaviorTreeNode.Type = {
ACTION = "ACTION",
CONDITION = "CONDITION",
SELECTOR = "SELECTOR",
SEQUENCE = "SEQUENCE"
};
function BehaviorTreeNode.new(name, type)
local node = {};
-- The BehaviorTreeNode's data members.
node.action_ = nil;
node.children_ = {};
node.evaluator_ = nil;
node.name_ = name or "";
node.parent_ = nil;
node.type_ = type or BehaviorTreeNode.Type.ACTION;
end
Search WWH ::




Custom Search