Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::planner::PlannerReasoner Class Referencefinal

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

#include <PlannerReasoner.hh>

Inheritance diagram for grail::planner::PlannerReasoner:
Collaboration diagram for grail::planner::PlannerReasoner:

Classes

struct  Config
 The Planner's run-time configuration parameters. More...
 

Public Member Functions

 PlannerReasoner (std::unique_ptr< MemoryPool > memory)
 
 PlannerReasoner (std::unique_ptr< MemoryPool > memory, std::shared_ptr< planner::GoalSelector > goalSelector, std::unique_ptr< planner::DomainTranslator > domainTranslator, const Config &config)
 
virtual void StageBehavior (AIEntity &entity) override
 selectBehavior - Runs reasoner's selection algorithm and assigns chosen behavior to provided entity. More...
 
virtual void SetNewGoal (std::unique_ptr< planner::Goal > newGoal, AIEntity &entity) override
 Sets a new current goal for the given entity.
 
void SetupNewPlanner (std::unique_ptr< planner::DomainTranslator > domainTranslator, const Config &config)
 
void SetFallbackBehavior (std::unique_ptr< Behavior > behavior)
 Sets the behavior that should be performed during plan computation or if no valid plan is found.
 
virtual const planner::GoalGetCurrentGoal () const override
 
void BindPlanningSucceededCallback (PlannerCallback callback)
 BindPlanningSucceededCallback - Binds a function handle to call if a sufficient (all goal conditions and plan restrictions met) plan is found. Found plan will be passed as function argument. More...
 
void BindPartialPlanFoundCallback (PlannerCallback callback)
 BindPartialPlanFoundCallback - Bind a function to call when no sufficient plan could be found, but some plan was formulated, this delegate will be called instead of onPlanningFailed. usePartialPlans needs to be true for this execute Plan with highest score will be passed as a function argument. More...
 
void BindPlanningFailedCallback (std::function< void(const planner::Goal &)> callback)
 BindPlanningFailedCallback - Bind a function to call when no sufficient plan was found. If reasoner uses partial plans this will only be called if no plan was formulated at all. More...
 
void BindPlanExecutedCallback (std::function< void()> callback)
 BindPlanExecutedCallback - Bind a function to call when entity has successfully executed chosen plan. More...
 
void SetSnapshotProduction (bool shouldProduce)
 Enable or disable snapshot production for debugging.
 
bool IsComputing () const
 
data::PlannerReasonerSnapshot ProduceDebugSnapshot ()
 
virtual std::unique_ptr< ISnapshotGeneratorCreateSnapshotGenerator (std::size_t) override
 
void ClearCurrentDebugSnapshot ()
 Clears any debug data that have been accumulated during iterations so far.
 
void SetDebugSnapshotFirstIteration (std::size_t iterationNumber)
 Sets the number of the iteration starting from which debug snapshots will be generated if run in debug mode.
 
void SetDebugSnapshotLastIteration (std::size_t iterationNumber)
 Sets the number of the iteration up to which debug snapshots will be generated if run in debug mode.
 
std::size_t GetDebugSnapshotFirstIteration () const
 Gets the number of the iteration starting from which debug snapshots will be generated if run in debug mode.
 
std::size_t GetDebugSnapshotLastIteration () const
 Gets the number of the iteration up to which debug snapshots will be generated if run in debug mode.
 
- Public Member Functions inherited from grail::Reasoner
 Reasoner (const Reasoner &)=default
 
 Reasoner (Reasoner &&)=default
 
Reasoneroperator= (const Reasoner &)=default
 
Reasoneroperator= (Reasoner &&)=default
 
virtual std::unique_ptr< ISnapshotGeneratorCreateSnapshotGenerator (size_t)
 

Protected Member Functions

virtual void ClearCache () override
 ClearCache - called when assigning this reasoner to an entity. Clears internally stored data, which may be invalidated when assigned to a different entity.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ PlannerReasoner() [1/2]

grail::planner::PlannerReasoner::PlannerReasoner ( std::unique_ptr< MemoryPool memory)

Constructs a new PlannerReasoner instance.

Parameters
memory- pool object used for memory optimization.

◆ PlannerReasoner() [2/2]

grail::planner::PlannerReasoner::PlannerReasoner ( std::unique_ptr< MemoryPool memory,
std::shared_ptr< planner::GoalSelector goalSelector,
std::unique_ptr< planner::DomainTranslator domainTranslator,
const Config config 
)

Constructs a new PlannerReasoner instance based on the provided arguments.

\memory - pool object used for memory optimization. \goalSelector - implementation that allows to choose subsequent goals for planning (at start and whenever a new goal is required) \domainTranslator - a translation layer between the abstract plan space and the game objects. See DomainTranslator. \config - the run-time configuration parameters for the planner

Member Function Documentation

◆ BindPartialPlanFoundCallback()

void grail::planner::PlannerReasoner::BindPartialPlanFoundCallback ( PlannerCallback  callback)

BindPartialPlanFoundCallback - Bind a function to call when no sufficient plan could be found, but some plan was formulated, this delegate will be called instead of onPlanningFailed. usePartialPlans needs to be true for this execute Plan with highest score will be passed as a function argument.

Parameters
callbackFunction to call if a partial plan is found

◆ BindPlanExecutedCallback()

void grail::planner::PlannerReasoner::BindPlanExecutedCallback ( std::function< void()>  callback)

BindPlanExecutedCallback - Bind a function to call when entity has successfully executed chosen plan.

Parameters
callbackFunction to call when plan goal is achieved

◆ BindPlanningFailedCallback()

void grail::planner::PlannerReasoner::BindPlanningFailedCallback ( std::function< void(const planner::Goal &)>  callback)

BindPlanningFailedCallback - Bind a function to call when no sufficient plan was found. If reasoner uses partial plans this will only be called if no plan was formulated at all.

Parameters
callbackfunction to call if planning failed

◆ BindPlanningSucceededCallback()

void grail::planner::PlannerReasoner::BindPlanningSucceededCallback ( PlannerCallback  callback)

BindPlanningSucceededCallback - Binds a function handle to call if a sufficient (all goal conditions and plan restrictions met) plan is found. Found plan will be passed as function argument.

Parameters
callbackFunction to call if a suitable plan is found

◆ GetCurrentGoal()

const planner::Goal * grail::planner::PlannerReasoner::GetCurrentGoal ( ) const
overridevirtual
Returns
The goal currently set via SetNewGoal.

Implements grail::planner::IGoalAcceptor.

◆ IsComputing()

bool grail::planner::PlannerReasoner::IsComputing ( ) const
Returns
Returns whether the Planner hasn't yet finished computing the plan.

◆ SetupNewPlanner()

void grail::planner::PlannerReasoner::SetupNewPlanner ( std::unique_ptr< planner::DomainTranslator domainTranslator,
const 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.

◆ StageBehavior()

void grail::planner::PlannerReasoner::StageBehavior ( 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: