Grail (C#)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Grail.SimulatedGames.Reasoners.SimulatedGameReasoner Class Reference

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

Inheritance diagram for Grail.SimulatedGames.Reasoners.SimulatedGameReasoner:
Collaboration diagram for Grail.SimulatedGames.Reasoners.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 StageBehavior (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 SimulatedGameSnapshotObserver. 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 [get]
 Returns true is the reasoner has not finished computations (i.e. there are still simulations to perform). More...
 
uint DebugSnapshotFirstIteration = false [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 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 limit.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ SimulatedGameReasoner()

Grail.SimulatedGames.Reasoners.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.SimulatedGames.Reasoners.SimulatedGameReasoner.ProduceDebugSnapshot ( )
inline

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

Returns

◆ RequestRecalculation()

void Grail.SimulatedGames.Reasoners.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.

◆ SetSnapshotProduction()

void Grail.SimulatedGames.Reasoners.SimulatedGameReasoner.SetSnapshotProduction ( bool  shouldProduceData)
inline

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

Parameters
shouldProduceData

◆ StageBehavior()

override void Grail.SimulatedGames.Reasoners.SimulatedGameReasoner.StageBehavior ( AIEntity  entity)
inlinevirtual

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

Parameters
entity

Implements Grail.Core.Reasoner.

Property Documentation

◆ FallbackBehavior

Behavior Grail.SimulatedGames.Reasoners.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.SimulatedGames.Reasoners.SimulatedGameReasoner.Game
get

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

◆ IsComputing

bool Grail.SimulatedGames.Reasoners.SimulatedGameReasoner.IsComputing
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: