1 #ifndef GRAIL_SIMULATED_GAME_REASONER_H
2 #define GRAIL_SIMULATED_GAME_REASONER_H
6 #include "../../GrailCore/AIEntity.hh"
7 #include "../../GrailCore/Reasoner.hh"
8 #include "../SimulatedGame.hh"
9 #include "../ISimulatedGameUnit.hh"
10 #include "../ISimulatedActionTranslator.hh"
11 #include "../ISimulatedGameStateTranslator.hh"
12 #include "../../GrailCore/Plan.hh"
16 struct SimulatedGameReasonerSnapshot;
20 class SimulatedGameSnapshotObserver;
34 SimulatedGameReasoner(std::unique_ptr<simulation::ISimulatedGameStateTranslator> worldStateTranslator,
35 std::unique_ptr<simulation::ISimulatedActionTranslator> actionTranslator,
36 std::size_t iterationsPerFrame, std::size_t maxIterations = 1000, std::size_t maxRecalculationIterations = 1000);
73 std::unique_ptr<ISnapshotGenerator> CreateSnapshotGenerator(
size_t)
override;
80 std::unique_ptr<simulation::SimulatedGame> game;
81 std::unique_ptr<Behavior> fallbackBehavior;
83 std::unique_ptr<simulation::ISimulatedGameStateTranslator> worldStateTranslator;
84 std::unique_ptr<simulation::ISimulatedActionTranslator> actionTranslator;
87 std::size_t iterationsPerFrame{};
88 std::size_t maxIterations{};
89 std::size_t maxRecalculationIterations{};
90 std::size_t maxRecalculationIterationsLeft{};
91 std::size_t iterationCounter{};
93 const std::size_t minIterationsPerRun = 2;
95 std::shared_ptr<simulation::ISimulatedGameUnit> pairedAbstractUnit{};
96 std::unique_ptr<simulation::SimulatedGameSnapshotObserver> snapshotObserver{};
97 bool isGameDataReady =
false;
98 bool isComputing =
false;
99 bool isRecalculating =
false;
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:39
The Reasoner class - Entity's "brain", assigns them behaviors chosen by user-defined algorithms.
Definition: Reasoner.hh:20
Definition: SimulatedGameReasoner.hh:24
size_t GetDebugSnapshotFirstIteration() const
If the debug data is collected, this method will return the first iteration number from which the dat...
Definition: SimulatedGameReasoner.cpp:133
size_t GetDebugSnapshotLastIteration() const
If the debug data is collected, this method will return the last iteration number up to which the dat...
Definition: SimulatedGameReasoner.cpp:138
const simulation::SimulatedGame & getGame() const
Gets the SimulatedGame object that is currently created by the ISimulatedGameStateTranslator.
Definition: SimulatedGameReasoner.cpp:87
void SetDebugSnapshotLastIteration(size_t iterationNumber)
You may limit the number of debug data collected to only data produced by simulations with numbers be...
Definition: SimulatedGameReasoner.cpp:127
virtual void SelectBehavior(AIEntity &entity) override
selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.
Definition: SimulatedGameReasoner.cpp:31
SimulatedGameReasoner(std::unique_ptr< simulation::ISimulatedGameStateTranslator > worldStateTranslator, std::unique_ptr< simulation::ISimulatedActionTranslator > actionTranslator, std::size_t iterationsPerFrame, std::size_t maxIterations=1000, std::size_t maxRecalculationIterations=1000)
Constructs a new SimulatedGameReasoner
Definition: SimulatedGameReasoner.cpp:13
SimulatedGameReasonerSnapshot ProduceDebugSnapshot()
This method returns debug snapshot of data collected so far by SimulatedGameSnapshotObserver....
Definition: SimulatedGameReasoner.cpp:153
void SetFallbackBehavior(std::unique_ptr< Behavior > _fallbackBehavior)
Set a fallback behavior if no valid behaviors are produced from actions returned by SimulatedGame....
Definition: SimulatedGameReasoner.cpp:82
bool IsComputing() const
Returns true is the reasoner has not finished computations (i.e. there are still simulations to perfo...
Definition: SimulatedGameReasoner.cpp:143
void SetSnapshotProduction(bool shouldProduce)
Calling this function makes the reasoner collect debug data. The GrailDebugger will call it automatic...
Definition: SimulatedGameReasoner.cpp:113
void SetDebugSnapshotFirstIteration(size_t iterationNumber)
You may limit the number of debug data collected to only data produced by simulations with numbers be...
Definition: SimulatedGameReasoner.cpp:121
void RequestRecalculation(AIEntity &entity)
As documented, the ISimulatedActionTranslator translates the actions computed by SimulatedGame to beh...
Definition: SimulatedGameReasoner.cpp:92
A data structure used by PlannerReasoner to execute a sequence of behaviors.
Definition: Plan.hh:16
The main interface class for the SimulatedGame reasoner based on the MCTS algorithm....
Definition: SimulatedGame.hh:30
Definition: SimulatedGamesSnapshots.h:95