3 #ifndef GRAIL_CONSIDERATION_H
4 #define GRAIL_CONSIDERATION_H
6 #include "Evaluator.hh"
7 #include "../GrailCore/AIEntity.hh"
8 #include "../GrailCore/Blackboard.hh"
9 #include "../GrailCore/EntityBlackboardPair.hh"
15 template <
typename ContextType>
22 template <
typename FunctionContextType>
35 virtual data::EvaluatorType GetEvaluatorType()
const override final {
return data::EvaluatorType::CONSIDERATION; }
37 virtual std::string GetDisplayName()
const {
return "unnamed_consideration"; }
41 if(std::find(considerations.begin(), considerations.end(),
this) == considerations.end())
43 considerations.push_back(
this);
53 virtual float Evaluate(
const ContextType& context)
const = 0;
55 virtual void DebugDump(
const std::map<const void*, unsigned int>&,
58 debugData.SetMetadata(GetDisplayName());
74 void CacheEvaluation(
const ContextType& context)
82 using DefaultConsideration = Consideration<const AIEntity*>;
83 using UtilityConsideration = Consideration<EntityBlackboardPair>;
85 template <
typename ContextType>
86 void CacheConsiderationEvaluations(std::shared_ptr<Evaluator<ContextType>> evaluator, ContextType context)
88 std::vector<Consideration<ContextType>*> considerations{};
89 evaluator->GetDependentConsiderations(considerations);
90 for(
auto& consideration : considerations)
92 consideration->CacheEvaluation(context);
97 #endif //GRAIL_CONSIDERATION_H