(C++)  1.1.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::SimulatedGameReasoner Class Referencefinal
Inheritance diagram for grail::SimulatedGameReasoner:
Collaboration diagram for grail::SimulatedGameReasoner:

Public Member Functions

 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 More...
 
virtual void SelectBehavior (AIEntity &entity) override
 selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity. More...
 
void SetFallbackBehavior (std::unique_ptr< Behavior > _fallbackBehavior)
 Set a fallback behavior if no valid behaviors are produced from actions returned by SimulatedGame. Please note that ISimulatedActionTranslator translates actions onto behaviors.
 
const simulation::SimulatedGamegetGame () const
 Gets the SimulatedGame object that is currently created by the ISimulatedGameStateTranslator.
 
void RequestRecalculation (AIEntity &entity)
 As documented, the ISimulatedActionTranslator translates the actions computed by SimulatedGame to behaviors. It constructs a plan (of such behaviors). Call this method at anytime if you want to stop applying behaviors (it will terminate the current one and clear all future ones). This should be called when the state desynchronizes, so the future plan should be invalidated. The method will make the reasoner perform additional simulations if computational budget allows for it. More...
 
void SetSnapshotProduction (bool shouldProduce)
 Calling this function makes the reasoner collect debug data. The GrailDebugger will call it automatically.
 
void SetDebugSnapshotFirstIteration (size_t iterationNumber)
 You may limit the number of debug data collected to only data produced by simulations with numbers between [First, Last]. This method sets: First = iterationNumber.
 
void SetDebugSnapshotLastIteration (size_t iterationNumber)
 You may limit the number of debug data collected to only data produced by simulations with numbers between [First, Last]. This method sets: Last = iterationNumber.
 
size_t GetDebugSnapshotFirstIteration () const
 If the debug data is collected, this method will return the first iteration number from which the data is collected.
 
size_t GetDebugSnapshotLastIteration () const
 If the debug data is collected, this method will return the last iteration number up to which the data is collected.
 
bool IsComputing () const
 Returns true is the reasoner has not finished computations (i.e. there are still simulations to perform).
 
std::unique_ptr< ISnapshotGeneratorCreateSnapshotGenerator (size_t) override
 
SimulatedGameReasonerSnapshot ProduceDebugSnapshot ()
 This method returns debug snapshot of data collected so far by SimulatedGameSnapshotObserver. The GrailDebugger will call it.
 
- Public Member Functions inherited from grail::Reasoner
 Reasoner (const Reasoner &)=default
 
 Reasoner (Reasoner &&)=default
 
Reasoneroperator= (const Reasoner &)=default
 
Reasoneroperator= (Reasoner &&)=default
 

Constructor & Destructor Documentation

◆ SimulatedGameReasoner()

grail::SimulatedGameReasoner::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

Parameters
gameStateTranslatorObject that instantiates SimulatedGame based on the current state of the actual game
actionTranslatorObject that translates actions from SimulatedGame (the result) onto plan consisting of behaviors in the actual game
iterationsPerFrameThe maximum number of iterations (simulations) per one game frame
maxIterationsThe number of iterations to be performed before getting results - translating actions onto behaviors. This tells the reasoner "think for maxIterations before making decisions"
maxRecalculationIterationsWhen you call the RequestRecalculation function, the reasoner will use this pool of additional iterations.

Member Function Documentation

◆ RequestRecalculation()

void grail::SimulatedGameReasoner::RequestRecalculation ( AIEntity entity)

As documented, the ISimulatedActionTranslator translates the actions computed by SimulatedGame to behaviors. It constructs a plan (of such behaviors). Call this method at anytime if you want to stop applying behaviors (it will terminate the current one and clear all future ones). This should be called when the state desynchronizes, so the future plan should be invalidated. The method will make the reasoner perform additional simulations if computational budget allows for it.

◆ SelectBehavior()

void grail::SimulatedGameReasoner::SelectBehavior ( AIEntity entity)
overridevirtual

selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity.

Parameters
entity

Implements grail::Reasoner.


The documentation for this class was generated from the following files: