1 #ifndef GRAIL_SIMULATED_GAME_H
2 #define GRAIL_SIMULATED_GAME_H
4 #include "SimulatedGameActionMetadata.hh"
5 #include "SimulatedGameObserverForGUI.h"
6 #include "ISimulatedGameUnit.hh"
7 #include "SimulatedGameHelper.h"
10 #include <unordered_map>
19 class SimulatedGameThinkingUnit;
20 class SimulatedGameStochasticUnit;
21 class ISimulatedGameAction;
22 class SimulatedGameNode;
41 SimulatedGame(
int teamCount = 2,
double maxScore = 1.0,
double explorationBoost = 1.0,
size_t freezeVisitsTreshold = std::numeric_limits<size_t>::max(), RandomGenerator::result_type seed = std::random_device{}());
54 void AddUnits(std::vector<std::shared_ptr<SimulatedGameThinkingUnit>> units);
89 std::vector<std::pair<const ISimulatedGameUnit*, const ISimulatedGameAction*>>
GetExpectedPlayout()
const;
101 std::unordered_map<const ISimulatedGameUnit*, std::vector<const ISimulatedGameAction*>>
GetExpectedPlans();
119 void DebugPrintPlan(std::unordered_map<
const ISimulatedGameUnit*, std::vector<const ISimulatedGameAction*>>& plan)
const;
120 void DebugPrintPlanWithMetadata(std::unordered_map<
const ISimulatedGameUnit*, std::vector<SimulatedGameActionMetadata>>& plan)
const;
121 void DebugPrintFullPlayout(std::vector<std::pair<const ISimulatedGameUnit*, const ISimulatedGameAction*>>& playout)
const;
140 std::vector<std::shared_ptr<SimulatedGameThinkingUnit>> thinkingUnits;
141 std::vector<std::shared_ptr<SimulatedGameStochasticUnit>> stochasticUnits;
143 RandomGenerator rand_gen;
144 std::unique_ptr<SimulatedGameNode> rootNode;
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
The main interface class for the SimulatedGame reasoner based on the MCTS algorithm....
Definition: SimulatedGame.hh:29
void AddUnits(std::vector< std::shared_ptr< SimulatedGameThinkingUnit >> units)
Adds new regular units to the game.
Definition: SimulatedGame.cpp:237
void SetStartingUnit(SimulatedGameThinkingUnit &unit)
Gets or sets the unit that acts first in the starting state of the game.
Definition: SimulatedGame.cpp:84
const ISimulatedGameAction * GetStartingUnitBestAction() const
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:244
std::unordered_map< const ISimulatedGameUnit *, std::vector< const ISimulatedGameAction * > > GetExpectedPlans()
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:264
std::vector< SimulatedGameActionMetadata > GetStartingUnitActionsWithMetadata() const
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:279
SimulatedGameThinkingUnit & AddUnit(std::shared_ptr< SimulatedGameThinkingUnit > unit)
Adds a new regular unit to the game.
Definition: SimulatedGame.cpp:192
const SimulatedGameActionMetadata GetStartingUnitBestActionMetadata() const
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:251
void RemoveUnit(const SimulatedGameThinkingUnit *unit)
Removes a regular unit from the game Might be useful when the game object is reused for different sit...
Definition: SimulatedGame.cpp:206
void ClearStatistics()
This method invalidates the tree built for the game. If any offline learners were attached,...
Definition: SimulatedGame.cpp:89
virtual size_t Run(size_t milisecondsTotal, size_t maxIterationCount, SimulatedGameObserverForGUI *observer=nullptr)
Performs simulations of the game. Pass the available time for computations and the maximum number of ...
Definition: SimulatedGame.cpp:128
SimulatedGame(int teamCount=2, double maxScore=1.0, double explorationBoost=1.0, size_t freezeVisitsTreshold=std::numeric_limits< size_t >::max(), RandomGenerator::result_type seed=std::random_device{}())
Constructs a new SimulatedGame object. This object can be reused.
Definition: SimulatedGame.cpp:170
std::unordered_map< const ISimulatedGameUnit *, std::vector< SimulatedGameActionMetadata > > GetExpectedPlansWithMetadata()
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:272
std::vector< std::pair< const ISimulatedGameUnit *, const ISimulatedGameAction * > > GetExpectedPlayout() const
Call this method after certain number of iterations performed (by calling Run() first).
Definition: SimulatedGame.cpp:256
This class should not be visible to developers at all.
Definition: SimulatedGameNode.h:24
Definition: SimulatedGameObserverForGUI.h:22
A base class of a unit in SimulatedGame that peforms actions according to some probability distributi...
Definition: SimulatedGameStochasticUnit.hh:22
A base class of a unit related to a rational/intelligent player. MCTS chooses actions for this kind o...
Definition: SimulatedGameThinkingUnit.hh:21
Definition: SimulatedGameHelper.h:17