Grail (C#)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Grail.Planners.Reasoners.PlannerReasoner Class Reference

A reasoner which uses planners to find optimal sequences of behaviors based on goals. More...

Inheritance diagram for Grail.Planners.Reasoners.PlannerReasoner:
Collaboration diagram for Grail.Planners.Reasoners.PlannerReasoner:

Classes

class  Config
 The PlannerReasoner run-time configuration parameters. More...
 

Public Member Functions

 PlannerReasoner ()
 Constructs a new PlannerReasoner instance with default parameters. More...
 
 PlannerReasoner (IGoalSelector goalSelector, DomainTranslator translator, Config config)
 Constructs a new PlannerReasoner instance based on the provided arguments. More...
 
override void StageBehavior (AIEntity entity)
 Runs reasoner's selection algorithm and assigns chosen behavior to provided entity. More...
 
void SetNewGoal (Goal goal, AIEntity entity)
 Sets a new target for planning by this reasoner.
If the entity is currently performing a behavior related to its previous goal, it will switch to the FallbackBehavior, if defined. More...
 
void SetupNewPlanner (DomainTranslator domainTranslator, Config config)
 Resets the planner domain based on data provided by the new domain translator. This method can be used if you want the agent to start planning an entirely different set of actions and disregard the previously defined domain. More...
 
override ISnapshotGenerator CreateSnapshotGenerator (int entityId)
 
override void ClearCache ()
 Called when assigning this reasoner to an entity. Clears internally stored data, which may be invalidated when assigned to a different entity. THIS METHOD SHOULD NOT BE CALLED BY THE USER. IT IS PUBLIC SO THAT THIS METHOD CAN BE USED BY ENTITY AND OVERRIDEN IN DIFFERENT MODULE More...
 

Public Attributes

bool IsComputing => planner.IsComputing
 Returns whether the Planner hasn't yet finished computing the plan. More...
 

Properties

PlannerDelegate OnPlanningSucceeded [set]
 Callback executed whenever a non-partial plan has been found by the algorithm. More...
 
PlannerDelegate OnPartialPlanFound [set]
 Callback executed if a partial plan has been found provided that partial plans are enabled. More...
 
System.Action< GoalOnPlanningFailed [set]
 Callback executed if no plans were found in the allotted iteration budget and satisfying the Config.MaxPlanLength and Config.MaxPlanCost limits. More...
 
Goal CurrentGoal [get]
 Current goal set for planning. More...
 
Behavior FallbackBehavior [set]
 The behavior that should be performed during plan computation or if no valid plan is found. More...
 
uint DebugSnapshotFirstIteration [get, set]
 The number of the iteration starting from which debug snapshots will be generated if run in debug mode. More...
 
uint DebugSnapshotLastIteration = 0 [get, set]
 The number of the iteration up to which debug snapshots will be generated if run in debug mode. More...
 
- Properties inherited from Grail.Planners.IGoalAcceptor
Goal CurrentGoal [get]
 

Events

System.Action OnPlanExecuted
 Callback to tell that a plan has been executed in the game. More...
 

Detailed Description

A reasoner which uses planners to find optimal sequences of behaviors based on goals.

Constructor & Destructor Documentation

◆ PlannerReasoner() [1/2]

Grail.Planners.Reasoners.PlannerReasoner.PlannerReasoner ( )
inline

Constructs a new PlannerReasoner instance with default parameters.

◆ PlannerReasoner() [2/2]

Grail.Planners.Reasoners.PlannerReasoner.PlannerReasoner ( IGoalSelector  goalSelector,
DomainTranslator  translator,
Config  config 
)
inline

Constructs a new PlannerReasoner instance based on the provided arguments.

Parameters
goalSelectorImplementation that allows to choose subsequent goals for planning (at start and whenever a new goal is required).
translatorA translation layer between the abstract plan space and the game objects. See DomainTranslator
configThe run-time configuration parameters for the planner.

Member Function Documentation

◆ ClearCache()

override void Grail.Planners.Reasoners.PlannerReasoner.ClearCache ( )
inlinevirtual

Called when assigning this reasoner to an entity. Clears internally stored data, which may be invalidated when assigned to a different entity. THIS METHOD SHOULD NOT BE CALLED BY THE USER. IT IS PUBLIC SO THAT THIS METHOD CAN BE USED BY ENTITY AND OVERRIDEN IN DIFFERENT MODULE

Reimplemented from Grail.Core.Reasoner.

◆ SetNewGoal()

void Grail.Planners.Reasoners.PlannerReasoner.SetNewGoal ( Goal  goal,
AIEntity  entity 
)
inline

Sets a new target for planning by this reasoner.
If the entity is currently performing a behavior related to its previous goal, it will switch to the FallbackBehavior, if defined.

Parameters
goalThe new goal to be set as the current goal.
entityThe entity for which the planning is performed.

Implements Grail.Planners.IGoalAcceptor.

◆ SetupNewPlanner()

void Grail.Planners.Reasoners.PlannerReasoner.SetupNewPlanner ( DomainTranslator  domainTranslator,
Config  config 
)
inline

Resets the planner domain based on data provided by the new domain translator. This method can be used if you want the agent to start planning an entirely different set of actions and disregard the previously defined domain.

◆ StageBehavior()

override void Grail.Planners.Reasoners.PlannerReasoner.StageBehavior ( AIEntity  entity)
inlinevirtual

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

Parameters
entity

Implements Grail.Core.Reasoner.

Member Data Documentation

◆ IsComputing

bool Grail.Planners.Reasoners.PlannerReasoner.IsComputing => planner.IsComputing

Returns whether the Planner hasn't yet finished computing the plan.

Property Documentation

◆ CurrentGoal

Goal Grail.Planners.Reasoners.PlannerReasoner.CurrentGoal
get

Current goal set for planning.

◆ DebugSnapshotFirstIteration

uint Grail.Planners.Reasoners.PlannerReasoner.DebugSnapshotFirstIteration
getset

The number of the iteration starting from which debug snapshots will be generated if run in debug mode.

◆ DebugSnapshotLastIteration

uint Grail.Planners.Reasoners.PlannerReasoner.DebugSnapshotLastIteration = 0
getset

The number of the iteration up to which debug snapshots will be generated if run in debug mode.

◆ FallbackBehavior

Behavior Grail.Planners.Reasoners.PlannerReasoner.FallbackBehavior
set

The behavior that should be performed during plan computation or if no valid plan is found.

◆ OnPartialPlanFound

PlannerDelegate Grail.Planners.Reasoners.PlannerReasoner.OnPartialPlanFound
set

Callback executed if a partial plan has been found provided that partial plans are enabled.

◆ OnPlanningFailed

System.Action<Goal> Grail.Planners.Reasoners.PlannerReasoner.OnPlanningFailed
set

Callback executed if no plans were found in the allotted iteration budget and satisfying the Config.MaxPlanLength and Config.MaxPlanCost limits.

◆ OnPlanningSucceeded

PlannerDelegate Grail.Planners.Reasoners.PlannerReasoner.OnPlanningSucceeded
set

Callback executed whenever a non-partial plan has been found by the algorithm.

Event Documentation

◆ OnPlanExecuted

System.Action Grail.Planners.Reasoners.PlannerReasoner.OnPlanExecuted

Callback to tell that a plan has been executed in the game.


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