Game Development Reference
In-Depth Information
Evaluators
Evaluators are the principal method of handling conditional checks in our decision struc-
tures. While actions perform the eventual behaviors that our agents exhibit, it's the respons-
ibly of evaluators to determine which action is allowed to run at what time.
Creating an evaluator object simply wraps a function call that returns true or false when the
userData table is passed into the function:
Evaluator.lua :
function Evaluator.Evaluate(self)
return self.function_(self.userData_);
end
function Evaluator.new(name, evalFunction, userData)
local evaluator = {};
-- data members
evaluator.function_ = evalFunction;
evaluator.name_ = name or "";
evaluator.type_ = Evaluator.Type;
evaluator.userData_ = userData;
-- object functions
evaluator.evaluate_ = Evaluate;
return evaluator;
end
Search WWH ::




Custom Search