grail (C  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Grail.SimulatedGameReasoner Class Reference

The reasoner that encalpsulates the SimulatedGame technique which is based on Monte Carlo Tree Search. More...

Inheritance diagram for Grail.SimulatedGameReasoner:
Collaboration diagram for Grail.SimulatedGameReasoner:

Public Member Functions

 SimulatedGameReasoner (in ISimulatedGameStateTranslator gameStateTranslator, in ISimulatedActionTranslator actionTranslator, uint iterationsPerFrame, uint maxIterations=1000, uint maxRecalculationIterations=1000)
 Constructs a new SimulatedGameReasoner More...
 
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 shouldProduceData)
 Calling this function makes the reasoner collect debug data. The GrailDebugger will call it automatically. More...
 
override void SelectBehavior (AIEntity entity)
 Runs reasoner's selection algorithm and assigns chosen behavior to provided entity. More...
 
SimulatedGamesReasonerSnapshot ProduceDebugSnapshot ()
 This method returns debug snapshot of data collected so far by SimulatedGameObserverForGUI. The GrailDebugger will call it. More...
 
override ISnapshotGenerator CreateSnapshotGenerator (int entityId)
 
void ClearDebugData ()
 

Properties

SimulatedGame Game [get]
 Gets the SimulatedGame object that is currently created by the ISimulatedGameStateTranslator. More...
 
Behavior FallbackBehavior [set]
 Set a fallback behavior if no valid behaviors are produced from actions returned by SimulatedGame. Please note that ISimulatedActionTranslator translates actions onto behaviors. More...
 
bool IsComputing = false [get]
 Returns true is the reasoner has not finished computations (i.e. there are still simulations to perform). More...
 
uint? DebugSnapshotFirstIteration [get, set]
 You may limit the number of debug data collected to only data produced by simulations with numbers between [First, Last]. This method gets or sets the @First limit.
 
uint? DebugSnapshotLastIteration [get, set]
 You may limit the number of debug data collected to only data produced by simulations with numbers between [First, Last]. This method gets or sets the @Last limit.
 

Detailed Description

The reasoner that encalpsulates the SimulatedGame technique which is based on Monte Carlo Tree Search.

Constructor & Destructor Documentation

◆ SimulatedGameReasoner()

Grail.SimulatedGameReasoner.SimulatedGameReasoner ( in ISimulatedGameStateTranslator  gameStateTranslator,
in ISimulatedActionTranslator  actionTranslator,
uint  iterationsPerFrame,
uint  maxIterations = 1000,
uint  maxRecalculationIterations = 1000 
)
inline

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

◆ ProduceDebugSnapshot()

SimulatedGamesReasonerSnapshot Grail.SimulatedGameReasoner.ProduceDebugSnapshot ( )
inline

This method returns debug snapshot of data collected so far by SimulatedGameObserverForGUI. The GrailDebugger will call it.

Returns

◆ RequestRecalculation()

void Grail.SimulatedGameReasoner.RequestRecalculation ( AIEntity  entity)
inline

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()

override void Grail.SimulatedGameReasoner.SelectBehavior ( AIEntity  entity)
inlinevirtual

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

Parameters
entity

Implements Grail.Reasoner.

◆ SetSnapshotProduction()

void Grail.SimulatedGameReasoner.SetSnapshotProduction ( bool  shouldProduceData)
inline

Calling this function makes the reasoner collect debug data. The GrailDebugger will call it automatically.

Parameters
shouldProduceData

Property Documentation

◆ FallbackBehavior

Behavior Grail.SimulatedGameReasoner.FallbackBehavior
set

Set a fallback behavior if no valid behaviors are produced from actions returned by SimulatedGame. Please note that ISimulatedActionTranslator translates actions onto behaviors.

◆ Game

SimulatedGame Grail.SimulatedGameReasoner.Game
get

Gets the SimulatedGame object that is currently created by the ISimulatedGameStateTranslator.

◆ IsComputing

bool Grail.SimulatedGameReasoner.IsComputing = false
get

Returns true is the reasoner has not finished computations (i.e. there are still simulations to perform).


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