Consideration

Consideration is a type of Evaluator. It represents a subset of the given Context’s state, which which may be passed to other types of Evaluators. For example, the user may connect Consideration to Curve to pass the resulting value through some function. Contexts can take form of basically any data type. No Evaluator can be connected to Consideration.

Custom considerations

User should override Consideration<Context> class to make custom Considerations.

By doing so, they should provide
  • the Consideration’s evaluation method - a method returning floating point value representing this Consideration.

  • Consideration’s name(C++ only) - not neccessary, but it is really useful to make debug logs easily readable.

Example implementation

  • C++

  • C#

class HealthConsideration : public grail::Consideration<const grail::AIControlledEntity*>
{
public:
  HealthConsideration() = default;

  virtual std::string GetDisplayName() const override
  {
    return "Health Consideration";
  }

protected:
  // snapshot should not be modified inside this method
  virtual float Evaluate(const grail::AIControlledEntity* contextEntity, UtilityEvaluatorSnapshot* snapshot) const override
  {
    return contextEntity->GetBlackboard().GetValue<float>("health"); // return current health points
  }

};
public class HealthConsideration : Grail.Consideration<Grail.AIControlledEntity>
{
  public HealthConsideration()
  {
  }

  // snapshot should not be modified inside this method
  protected override float Evaluate(Grail.AIControlledEntity contextEntity, UtilityEvaluatorSnapshot snapshot)
  {
    return contextEntity.Blackboard.GetValue<float>("health"); // return current health points
  }
}

API Reference