Evaluator<Context>

Evaluator is an object whose role is to provide a score deduced by considering data stored inside a Context or the score of other dependent Evaluators. Contexts can take the form of any built-in or user-defined data type. Most often AIControlledEntity or pair of AIControlledEntity and Blackboard are passed as evaluator Context.

Evaluators can be connected to create tree-like structure which must be paired up with the Blueprint object in order to be passed to the Selector.

There are 3 types of built-in evaluators provided:

Example

Let’s consider connecting HealthConsideration with the current value of 10 to curve representing function y=x^2, which give us the result of 100.
Next, we connect it to AverageAggregator along with StaminaConsideration (with current value of 50), to get the result of 75.
However, we’d prefer to get a score normalized to the range <0;1>, so we connect above mentioned aggregator to a curve y=x/100 with upperbound of 1 and lowerbound of 0.
The final score is 0.75 and that will be used as an evaluation result of object paired up with evaluator tree designed in this example.

Exemplar Evaluator Tree
  • C++

  • C#

auto healthConsideration = std::make_shared<HealthConsideration>();
auto quadraticCurve = std::make_shared<grail::evaluator::PowerFunction<ContextType>>(healthConsideration, 1, 0, 2); // y = (1x+0)^2

auto staminaConsideration = std::make_shared<StaminaConsideration>();

auto averageAggregator = std::make_shared<grail::evaluator::AverageAggregator<ContextType>>(
  std::vector<std::shared_ptr<grail::evaluator::Evaluator<ContextType>>>
  {
    quadraticCurve, staminaConsideration
  });

auto divideBy100 = std::make_shared<grail::evaluator::LinearFunction<ContextType>>(averageAggregator, 0.01, 0);// y = 0.01x + 0
auto normalizationCurve = std::make_shared<grail::evaluator::DoubleSidedBound<ContextType>>(divideBy100, 0, 1);// bounding result to range <0;1>
var healthConsideration = new HealthConsideration();
var quadraticCurve = new PowerFunction<ContextType>(healthConsideration, 1, 0, 2) // y = (1x+0)^2

var staminaConsideration = new StaminaConsideration();

var averageAggregator = new AverageAggregator<ContextType>(
  new List<Evaluator<ContextType>>()
  {
    quadraticCurve, staminaConsideration
  });

var divideBy100 = new LinearFunction<ContextType>(averageAggregator, 0.01, 0); // y = 0.01x + 0
var normalizationCurve = new DoubleSidedBound<ContextType>(divideBy100, 0, 1); // bounding result to range <0;1>

API Reference