Game Development Reference
In-Depth Information
Branches
Branches in a decision tree consist of a conditional evaluator that determines which child is
executed. It is the responsibility of the evaluator to return a value that ranges from 1 to the
maximum number of children in the branch. Even though we'll only be creating binary de-
cision trees, the structure itself can branch out to any number of children, as shown in the
following diagram:
An example of a decision tree branch
Our decision branch class will have basic assessors such as adding additional children as
well as setting the evaluator function used during branch calculation.
DecisionBranch.lua :
DecisionBranch = {}
DecisionBranch.Type = "DecisionBranch";
function DecisionBranch.new()
local branch = {};
-- The DecisionBranch's data members.
branch.children_ = {};
branch.evaluator_ = nil;
branch.type_ = DecisionBranch.Type;
-- The DecisionBranch's accessor functions.
Search WWH ::




Custom Search