(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
SimulatedGameObserverForGUI.h
1  #ifndef GRAIL_SIMULATED_GAME_OBSERVER_FOR_GUI_H
2 #define GRAIL_SIMULATED_GAME_OBSERVER_FOR_GUI_H
3 
4 #include "SimulatedGameActionMetadata.hh"
5 #include "../GrailData/GrailDebugInfo/SimulatedGamesSnapshots.h"
6 #include <vector>
7 #include <memory>
8 #include <unordered_map>
9 #include <limits>
10 
11 namespace grail
12 {
13  namespace simulation
14  {
15  class SimulatedGameThinkingUnit;
16  class SimulatedGameStochasticUnit;
17  class ISimulatedGameAction;
18  class ISimulatedGameUnit;
19  class SimulatedGameNode;
20 
22  {
23  public:
26 
30  bool IsInitialized() const;
31 
32  void OnGameStart(const std::vector<std::shared_ptr<SimulatedGameThinkingUnit>>& thinkingUnits, const std::vector<std::shared_ptr<SimulatedGameStochasticUnit>>& stochasticUnits);
33  void OnIterationStart(size_t iterationNumber);
34  void OnUCTAction(const ISimulatedGameAction& chosenAction, const SimulatedGameNode& node);
35  void OnMonteCarloAction(const ISimulatedGameAction& chosenAction, const ISimulatedGameUnit& activeUnit);
36  void OnIterationEnd(const std::vector<float>& scores);
37 
39  void SetMinIteration(size_t iteration);
40 
42  size_t GetMinIteration() const;
43 
45  void SetMaxIteration(size_t iteration);
46 
48  size_t GetMaxIteration() const;
49 
50  private:
51  int GetUnitUID(const ISimulatedGameUnit* unit);
52 
53  SimulatedGameReasonerSnapshot gameSnapshot;
54  SimulatedGameIterationSnapshot currentIteration;
55  std::unordered_map<const ISimulatedGameUnit*, int> idMap = {};
56  bool isInitialized = false;
57  size_t minIteration = 0;
58  size_t maxIteration = std::numeric_limits<size_t>::max();
59  unsigned long globalIterationIndex = 0;
60  };
61  }
62 }
63 #endif //GRAIL_SIMULATED_GAME_OBSERVER_FOR_GUI_H
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:41
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:27
This class should not be visible to developers at all.
Definition: SimulatedGameNode.h:24
Definition: SimulatedGameObserverForGUI.h:22
SimulatedGameReasonerSnapshot & GetSnapshot()
Returns serialized snapshot of SimulatedGameReasoner.
Definition: SimulatedGameObserverForGUI.cpp:11
bool IsInitialized() const
Returns true if the observer is initialized and ready to gather data.
Definition: SimulatedGameObserverForGUI.cpp:16
size_t GetMaxIteration() const
Gets the maximum number of iteration that will be gathered during the debugging.
Definition: SimulatedGameObserverForGUI.cpp:36
size_t GetMinIteration() const
Gets the minimum number of iteration that will be gathered during the debugging.
Definition: SimulatedGameObserverForGUI.cpp:26
void SetMaxIteration(size_t iteration)
Sets the maximum number of iteration that will be gathered during the debugging.
Definition: SimulatedGameObserverForGUI.cpp:31
void SetMinIteration(size_t iteration)
Sets the minimum number of iteration that will be gathered during the debugging.
Definition: SimulatedGameObserverForGUI.cpp:21
Definition: SimulatedGamesSnapshots.h:95
Definition: SimulatedGamesSnapshots.h:75