Building a decision tree
Building a decision tree starts with instantiating an instance of a decision tree, creating each branch within our tree, connecting the conditional branches, and adding actions:
SoldierLogic.lua
:
function SoldierLogic_DecisionTree(userData) local tree = DecisionTree.new(); return tree; end
Creating branches
The tree we'll be creating combines each of the actions and evaluators we implemented previously and gives our agents the ability to pursue, flee, move, shoot, idle, reload, and die.
First we'll create each branch instance that our decision tree will contain before adding any evaluators or actions.
SoldierLogic.lua
:
function SoldierLogic_DecisionTree(userData) local tree = DecisionTree.new(); local isAliveBranch = DecisionBranch.new(); local criticalBranch = DecisionBranch.new(); local moveFleeBranch = DecisionBranch.new(); local enemyBranch = DecisionBranch.new(); local ammoBranch = DecisionBranch.new...