Grail (C++)  1.1.1
A multi-platform, modular, universal engine for embedding advanced AI in games.
ISimulatedGameAction.hh
1 #ifndef GRAIL_SIMULATED_GAME_ACTION_H
2 #define GRAIL_SIMULATED_GAME_ACTION_H
3 
4 #include <iostream>
5 #include <memory>
6 #include <string>
7 #include "SimulatedGameRuntime.hh"
8 
9 namespace grail
10 {
11  namespace simulation
12  {
15  {
16  template <typename PointerType>
17  std::size_t operator()(const PointerType& p) const
18  {
19  return p->HashForLearning();
20  }
21  };
22 
25  {
26  template <typename PointerType>
27  bool operator()(const PointerType& p1, const PointerType& p2) const
28  {
29  return p1->EqualsForLearning(*p2);
30  }
31  };
32 
33  class ISimulatedGameUnit;
34 
40  {
41  public:
42  virtual ~ISimulatedGameAction();
43 
50  virtual ISimulatedGameUnit* Apply(ISimulatedGameUnit& currentUnit,
51  SimulatedGameRuntime& runtimeControl) const = 0;
52 
54  virtual std::string ToString() const;
55 
58  virtual std::unique_ptr<ISimulatedGameAction> CloneForLearning() const;
59 
62  virtual size_t HashForLearning() const;
63 
66  virtual bool EqualsForLearning(const ISimulatedGameAction& other) const;
67 
68  friend std::ostream& operator<<(std::ostream& os, const ISimulatedGameAction& action);
69  };
70  }
71 }
72 #endif //GRAIL_SIMULATED_GAME_ACTION_H
grail::simulation::ISimulatedGameAction
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:39
grail::simulation::ISimulatedGameAction::ToString
virtual std::string ToString() const
Returns a text representation of an action - used only for printing and debugging purposes.
Definition: ISimulatedGameAction.cpp:11
grail::simulation::ISimulatedGameAction::EqualsForLearning
virtual bool EqualsForLearning(const ISimulatedGameAction &other) const
Definition: ISimulatedGameAction.cpp:26
grail::simulation::EqualsForOfflineLearning
Helper that provides a EqualsForLearning() method. Used with ISimulatedGameAction only by OfflineLear...
Definition: ISimulatedGameAction.hh:24
grail::simulation::HashForOfflineLearning
Helper that provides a HashForLearning() method. Used with ISimulatedGameAction only by OfflineLearni...
Definition: ISimulatedGameAction.hh:14
grail::simulation::ISimulatedGameAction::CloneForLearning
virtual std::unique_ptr< ISimulatedGameAction > CloneForLearning() const
Definition: ISimulatedGameAction.cpp:16
grail::simulation::ISimulatedGameAction::HashForLearning
virtual size_t HashForLearning() const
Definition: ISimulatedGameAction.cpp:21
grail::simulation::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::simulation::SimulatedGameRuntime
An interface that is used to terminate simulation in MCTS and set scores to players....
Definition: SimulatedGameRuntime.hh:15
grail::simulation::ISimulatedGameUnit
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:26