Grail (C++)  1.1.1
A multi-platform, modular, universal engine for embedding advanced AI in games.
Aggregator.hh
1 #ifndef GRAIL_AGGREGATOR_H
2 #define GRAIL_AGGREGATOR_H
3 
4 #include "../Evaluator.hh"
5 
6 #include <cassert>
7 #include <limits>
8 #include <memory>
9 #include <vector>
10 
11 namespace grail
12 {
13  namespace utility
14  {
15  template <typename ContextType>
20  class Aggregator : public Evaluator<ContextType>
21  {
22  public:
27  Aggregator(const std::vector<std::shared_ptr<Evaluator<ContextType>>>& childEvaluators)
28  : childEvaluators{childEvaluators}
29  {
30  }
31 
32  Aggregator(const Aggregator<ContextType>&) = default;
33  Aggregator(Aggregator<ContextType>&&) = default;
34 
35  virtual ~Aggregator() = default;
36 
37  Aggregator& operator =(const Aggregator<ContextType>&) = default;
38  Aggregator& operator =(Aggregator<ContextType>&&) = default;
39 
40  protected:
41  virtual void DebugDump(const std::map<const void*, std::size_t>& nodeMapping,
42  EvaluationDebugData& debugData) const override
43  {
44  for(const auto& childEvaluator : childEvaluators)
45  {
46  debugData.AddChildNode(nodeMapping.at(childEvaluator.get()));
47  }
48  }
49 
50  std::vector<std::shared_ptr<Evaluator<ContextType>>> childEvaluators{};
51  };
52  }
53 }
54 #endif //GRAIL_EVALUATOR_H
grail::utility::Aggregator::DebugDump
virtual void DebugDump(const std::map< const void *, std::size_t > &nodeMapping, EvaluationDebugData &debugData) const override
DebugDump - Called from EvaluateContext, which generates additional debug data for each evaluator....
Definition: Aggregator.hh:41
grail::utility::Aggregator
The Aggregator class - Base class for an Evaluator aggregating multiple other Evaluators' scores into...
Definition: Aggregator.hh:20
grail::EvaluationDebugData
The EvaluationDebugData class - debug data describing singular evaluator.
Definition: EvaluationDebugData.h:19
grail::utility::Evaluator
The Evaluator class - base class being able to evaluate given context and output the result.
Definition: Evaluator.hh:20
grail::EvaluationDebugData::AddChildNode
void AddChildNode(std::size_t childNodeIndex)
AddChildNode - add node as leaf/child to this data node.
Definition: EvaluationDebugData.cpp:10
grail::utility::Aggregator::Aggregator
Aggregator(const std::vector< std::shared_ptr< Evaluator< ContextType >>> &childEvaluators)
Aggregator - Constructor.
Definition: Aggregator.hh:27