(C++)  1.0.0
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 "SimulatedGameRuntime.hh"
5 #include <string>
6 #include <iostream>
7 #include <memory>
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 
34  class ISimulatedGameUnit;
35 
41  {
42  public:
43  virtual ~ISimulatedGameAction();
44 
51  virtual ISimulatedGameUnit* Apply(ISimulatedGameUnit& currentUnit, 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
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:41
virtual std::string ToString() const
Returns a text representation of an action - used only for printing and debugging purposes.
Definition: ISimulatedGameAction.cpp:12
virtual ISimulatedGameUnit * Apply(ISimulatedGameUnit &currentUnit, SimulatedGameRuntime &runtimeControl) const =0
Applies the effects of the action and returns the next Unit to make an action.
virtual size_t HashForLearning() const
Definition: ISimulatedGameAction.cpp:22
virtual bool EqualsForLearning(const ISimulatedGameAction &other) const
Definition: ISimulatedGameAction.cpp:27
virtual std::unique_ptr< ISimulatedGameAction > CloneForLearning() const
Definition: ISimulatedGameAction.cpp:17
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:27
An interface that is used to terminate simulation in MCTS and set scores to players....
Definition: SimulatedGameRuntime.hh:16
Helper that provides a EqualsForLearning() method. Used with ISimulatedGameAction only by OfflineLear...
Definition: ISimulatedGameAction.hh:25
Helper that provides a HashForLearning() method. Used with ISimulatedGameAction only by OfflineLearni...
Definition: ISimulatedGameAction.hh:15