Grail (C++)  1.2.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
C45GameActionCounter.h
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_C45_GAME_ACTION_COUNTER_H
4 #define GRAIL_C45_GAME_ACTION_COUNTER_H
5 
6 #include <cmath>
7 #include <unordered_map>
8 #include "../ISimulatedGameAction.hh"
9 
10 namespace grail
11 {
12 namespace simgames
13 {
14 namespace learn
15 {
18  {
19  public:
20  void clear();
21 
22  double getTotalSampleCount() const;
23 
24  size_t geKeyCount() const;
25 
26  const ISimulatedGameAction* frequentValue() const;
27 
28  void observeKey(const ISimulatedGameAction* key);
29 
30  double calculateEntropy() const;
31 
32  int getCount(const ISimulatedGameAction* key) const;
33 
34  private:
35  std::unordered_map<const ISimulatedGameAction*, int, HashForOfflineLearning, EqualsForOfflineLearning>
36  sampleCountByKey;
37  double totalSamples = 0;
38  };
39 }
40 }
41 }
42 
43 #endif //GRAIL_C45_GAME_ACTION_COUNTER_H
grail::simgames::learn::C45GameActionCounter
The whole class should be INTERNAL; part of the private interface.
Definition: C45GameActionCounter.h:17
grail::simgames::ISimulatedGameAction
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:41