Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
ISimulatedGameAction.hh
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_SIMULATED_GAME_ACTION_H
4 #define GRAIL_SIMULATED_GAME_ACTION_H
5 
6 #include <iostream>
7 #include <memory>
8 #include <string>
9 #include "SimulatedGameRuntime.hh"
10 
11 namespace grail
12 {
13 namespace simgames
14 {
17  {
18  template <typename PointerType>
19  std::size_t operator()(const PointerType& p) const
20  {
21  return p->HashForLearning();
22  }
23  };
24 
27  {
28  template <typename PointerType>
29  bool operator()(const PointerType& p1, const PointerType& p2) const
30  {
31  return p1->EqualsForLearning(*p2);
32  }
33  };
34 
35  class ISimulatedGameUnit;
36 
42  {
43  public:
44  virtual ~ISimulatedGameAction();
45 
52  virtual ISimulatedGameUnit* Apply(ISimulatedGameUnit& currentUnit,
53  SimulatedGameRuntime& runtimeControl) const = 0;
54 
56  virtual std::string ToString() const;
57 
60  virtual std::unique_ptr<ISimulatedGameAction> CloneForLearning() const;
61 
64  virtual size_t HashForLearning() const;
65 
68  virtual bool EqualsForLearning(const ISimulatedGameAction& other) const;
69 
70  friend std::ostream& operator<<(std::ostream& os, const ISimulatedGameAction& action);
71  };
72 }
73 }
74 #endif //GRAIL_SIMULATED_GAME_ACTION_H
grail::simgames::ISimulatedGameAction::EqualsForLearning
virtual bool EqualsForLearning(const ISimulatedGameAction &other) const
Definition: ISimulatedGameAction.cpp:28
grail::simgames::SimulatedGameRuntime
An interface that is used to terminate simulation in MCTS and set scores to players....
Definition: SimulatedGameRuntime.hh:17
grail::simgames::ISimulatedGameAction::HashForLearning
virtual size_t HashForLearning() const
Definition: ISimulatedGameAction.cpp:23
grail::simgames::ISimulatedGameAction
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:41
grail::simgames::HashForOfflineLearning
Helper that provides a HashForLearning() method. Used with ISimulatedGameAction only by OfflineLearni...
Definition: ISimulatedGameAction.hh:16
grail::simgames::ISimulatedGameAction::Apply
virtual ISimulatedGameUnit * Apply(ISimulatedGameUnit &currentUnit, SimulatedGameRuntime &runtimeControl) const =0
Applies the effects of the action and returns the next Unit to make an action.
grail::simgames::EqualsForOfflineLearning
Helper that provides a EqualsForLearning() method. Used with ISimulatedGameAction only by OfflineLear...
Definition: ISimulatedGameAction.hh:26
grail::simgames::ISimulatedGameUnit
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:28
grail::simgames::ISimulatedGameAction::ToString
virtual std::string ToString() const
Returns a text representation of an action - used only for printing and debugging purposes.
Definition: ISimulatedGameAction.cpp:13
grail::simgames::ISimulatedGameAction::CloneForLearning
virtual std::unique_ptr< ISimulatedGameAction > CloneForLearning() const
Definition: ISimulatedGameAction.cpp:18