(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
LeafDecisionNode.h
1 #ifndef GRAIL_LEAF_DECISION_NODE_H
2 #define GRAIL_LEAF_DECISION_NODE_H
3 
4 #include "DecisionNode.h"
5 #include <memory>
6 #include <iostream>
7 
8 namespace grail
9 {
10  namespace simulation
11  {
15  template <class TDecisionType>
16  class LeafDecisionNode : public DecisionNode<TDecisionType>
17  {
18  public:
19  LeafDecisionNode(std::unique_ptr<const TDecisionType> decision);
20 
21  const TDecisionType* Predict(std::vector<float>&) const final
22  {
23  return decision.get();
24  }
25 
26  void Print(std::unordered_map<int, std::string>&, const std::string& indent = "") const override
27  {
28  std::cout << indent << "Decision: " << *decision.get() << std::endl;
29  }
30 
31  DecisionNodeType GetNodeType() const final
32  {
33  return DecisionNodeType::LEAF;
34  }
35 
36  private:
37  std::unique_ptr<const TDecisionType> decision;
38 
39  template <class T> friend struct IDecisionTreeSerializer;
40  };
41 
42  template<class TDecisionType>
43  inline LeafDecisionNode<TDecisionType>::LeafDecisionNode(std::unique_ptr<const TDecisionType> decision) :
44  decision { std::move(decision)}
45 
46  {
47 
48  }
49  }
50 }
51 
52 #endif //GRAIL_LEAF_DECISION_NODE_H
Class for internal usage. Decision tree node that correspond to actual decisions. They are always lea...
Definition: LeafDecisionNode.h:17
Class for internal usage. Decision tree node base type.
Definition: DecisionNode.h:21
A base class for an object that is passed to Serialize() and Deserialize() methods of DecisionTree....
Definition: IDecisionTreeSerializer.hh:21