(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
OfflineLearner.hh
1 #ifndef GRAIL_OFFLINE_LEARNER_H
2 #define GRAIL_OFFLINE_LEARNER_H
3 
4 #include <unordered_map>
5 #include <memory>
6 #include <vector>
7 
8 namespace grail
9 {
10  namespace simulation
11  {
12  class SimulatedGameNode;
13  struct IVectorizer;
14  class UniqueTreeDataset;
15  class ISimulatedGameUnit;
16 
22  {
23  public:
28  OfflineLearner(std::unique_ptr<IVectorizer> vectorizer);
29 
31  void ClearData();
32 
40  std::unique_ptr<UniqueTreeDataset> GetSamplesDataset(double minFractionOfSimulationsThreshold = 0.7);
41 
49  void FillSamplesDataset(UniqueTreeDataset& dataset, double minFractionOfSimulationsThreshold = 0.7);
50 
51  private:
52  double GetSampleMaxVisits() const;
53  void ObserveNode(const SimulatedGameNode* node);
54  bool IsLearnableSituation(const ISimulatedGameUnit& unit);
55 
56  std::unique_ptr<IVectorizer> stateObserver;
57  std::unordered_map<const SimulatedGameNode*, std::vector<float>> capturedData = {};
58 
59  friend class SimulatedGameThinkingUnit;
60  };
61  }
62 }
63 
64 #endif //GRAIL_OFFLINE_LEARNER_H
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:27
This is the main class you will use to peform the offline learning process. Assign it to the unit of ...
Definition: OfflineLearner.hh:22
std::unique_ptr< UniqueTreeDataset > GetSamplesDataset(double minFractionOfSimulationsThreshold=0.7)
Gets data gathered by OfflineLearner in the form of UniqueTreeDataset.
Definition: OfflineLearner.cpp:39
void ClearData()
Clears all data gathered for the game. You may want to call it after you already use the data but you...
Definition: OfflineLearner.cpp:17
OfflineLearner(std::unique_ptr< IVectorizer > vectorizer)
Constructs a new OfflineLearner object.
Definition: OfflineLearner.cpp:11
void FillSamplesDataset(UniqueTreeDataset &dataset, double minFractionOfSimulationsThreshold=0.7)
Gets data gathered by OfflineLearner and adds it to dataset. Pass the container you want to add data ...
Definition: OfflineLearner.cpp:46
This class should not be visible to developers at all.
Definition: SimulatedGameNode.h:24
A base class of a unit related to a rational/intelligent player. MCTS chooses actions for this kind o...
Definition: SimulatedGameThinkingUnit.hh:21
Definition: UniqueTreeDataset.hh:19