Updating decision evaluators
With a centralized data structure in place, we can refactor the decision evaluators in order to reference the blackboard directly. Removing the enemy evaluation from the SoldierEvaluators_CanShootAgent
function solves a critical flaw in our previous implementation, which is the fact that no conditional evaluation should modify the agent. Logic evaluators should only make true or false calculations in a passive manner and never mutate the state of an agent:
SoldierEvaluators.lua
:
function SoldierEvaluators_CanShootAgent(userData) local enemy = userData.blackboard:Get("enemy"); if (enemy ~= nil and Agent.GetHealth(enemy) > 0 and Vector.Distance( userData.agent:GetPosition(), enemy:GetPosition()) < 3) then return true; end; return false; end function SoldierEvaluators_HasAmmo(userData) local ammo = userData.blackboard:Get("ammo"); return ammo ~= nil and ammo > 0;...