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

The main class responsible for finding paths in plan space. More...

#include <Planner.hh>

Classes

struct  AbstractPlan
 
struct  Config
 

Public Member Functions

 Planner (std::unique_ptr< WorldState > initialState, const Config &config=Config{})
 
void SetIterationLimit (std::size_t iterationLimit)
 SetIterationLimit - sets maximum number of plans that can be generated during calculations. More...
 
void SetMaxPlanLength (int maxLength)
 SetMaxPlanLength - Limits generated plans to not exceed given number of steps to achieve goal conditions. More...
 
void SetMaxPlanCost (double maxCost)
 SetMaxPlanCost - Limits generated plans cost needed to achieve goal conditions. More...
 
void SetHeuristic (PlannerHeuristic heuristic)
 SetHeuristic - Gives planner a way to evaluate calculated plans. More...
 
void ResetConfig (const Config &config)
 ResetConfig - Sets planner config: max iteration, cost, length, plan heuristic, and node count. More...
 
void PushCondition (ConditionFunction condition)
 
AbstractPlan GetPartialPlan () const
 GetPartialPlan - returns currently best plan, regardless if goal conditions are met. Will return an empty plan if no calculations were finished. More...
 
data::PlannerIterationSnapshot GetPlanSnapshot (std::size_t goalNodeIndex, std::size_t iteration) const
 GetPlanSnapshot - Get debug data on a single iteration of a plan. More...
 
void Iterate (std::size_t iterationCount) noexcept
 Iterate - Formulate a plan trying to meet goalConditions from initialState. Evaluates plan using nodes dijkstraScore and aStarScore. More...
 
void IterateWithSnapshot (std::size_t iterationCount, data::PlannerReasonerSnapshot &snapshot, std::size_t minDebugSnapshotIteration=0, std::size_t maxDebugSnapshotIteration=std::numeric_limits< std::size_t >::max()) noexcept
 IterateWithSnapshot - Formulates a plan trying to meet goalConditions from initialState. Outputs debug data during every iteration if not limited by min or max snapshot iteration parameters. More...
 
void SetPlanFoundCallback (const std::function< void(const AbstractPlan &)> callbackFunction)
 SetPlanFoundCallback - Binds a function handle to call if a sufficient plan is found. Best plan will be passed as function argument. More...
 
void SetPlanningFailedCallback (const std::function< void()> callbackFunction)
 SetPlanningFailedCallback - Binds a function handle to call if no sufficient plan was found. More...
 
void Reset (std::unique_ptr< WorldState > initialState)
 Reset - Resets planner to given world state. Any existing plans and goal conditions will be cleared. More...
 
bool IsComputing () const
 IsComputing - Returns true if no suitable plan was found and planning hasn't failed. This does not mean that planner is currently formulating a plan. More...
 

Detailed Description

The main class responsible for finding paths in plan space.

Member Function Documentation

◆ GetPartialPlan()

Planner::AbstractPlan grail::planner::Planner::GetPartialPlan ( ) const

GetPartialPlan - returns currently best plan, regardless if goal conditions are met. Will return an empty plan if no calculations were finished.

Returns
Currently best plan

◆ GetPlanSnapshot()

data::PlannerIterationSnapshot grail::planner::Planner::GetPlanSnapshot ( std::size_t  goalNodeIndex,
std::size_t  iteration 
) const

GetPlanSnapshot - Get debug data on a single iteration of a plan.

Parameters
goalNodeIndexIndex of Planner generatedNodes
iterationPlan iteration to gather debug data from
Returns
Plan iteration debug data

◆ IsComputing()

bool grail::planner::Planner::IsComputing ( ) const

IsComputing - Returns true if no suitable plan was found and planning hasn't failed. This does not mean that planner is currently formulating a plan.

Returns
Plan hasn't finished

◆ Iterate()

void grail::planner::Planner::Iterate ( std::size_t  iterationCount)
noexcept

Iterate - Formulate a plan trying to meet goalConditions from initialState. Evaluates plan using nodes dijkstraScore and aStarScore.

Parameters
iterationCountMax number of plan iterations to calculate

◆ IterateWithSnapshot()

void grail::planner::Planner::IterateWithSnapshot ( std::size_t  iterationCount,
data::PlannerReasonerSnapshot snapshot,
std::size_t  minDebugSnapshotIteration = 0,
std::size_t  maxDebugSnapshotIteration = std::numeric_limits<std::size_t>::max() 
)
noexcept

IterateWithSnapshot - Formulates a plan trying to meet goalConditions from initialState. Outputs debug data during every iteration if not limited by min or max snapshot iteration parameters.

Parameters
iterationCountMax number of plan iterations to calculate
snapshotPlan debug data
minDebugSnapshotIterationMin number of plan iterations to include in debug data from
maxDebugSnapshotIterationMax number of plan iteration to include in debug data

◆ PushCondition()

void grail::planner::Planner::PushCondition ( ConditionFunction  condition)

Adds a single goal condition to the planner

Parameters
condition- a boolean function representing a single goal condition

◆ Reset()

void grail::planner::Planner::Reset ( std::unique_ptr< WorldState initialState)

Reset - Resets planner to given world state. Any existing plans and goal conditions will be cleared.

Parameters
initialStateNew WorldState planner will start formulating plans from

◆ ResetConfig()

void grail::planner::Planner::ResetConfig ( const Config config)

ResetConfig - Sets planner config: max iteration, cost, length, plan heuristic, and node count.

TODO rename?

Parameters
configNew planner config

◆ SetHeuristic()

void grail::planner::Planner::SetHeuristic ( PlannerHeuristic  heuristic)

SetHeuristic - Gives planner a way to evaluate calculated plans.

Parameters
heuristicPlan evaluation heuristic

◆ SetIterationLimit()

void grail::planner::Planner::SetIterationLimit ( std::size_t  iterationLimit)

SetIterationLimit - sets maximum number of plans that can be generated during calculations.

Parameters
iterationLimitIteration limit

◆ SetMaxPlanCost()

void grail::planner::Planner::SetMaxPlanCost ( double  maxCost)

SetMaxPlanCost - Limits generated plans cost needed to achieve goal conditions.

Parameters
maxCostMaximum plan cost

◆ SetMaxPlanLength()

void grail::planner::Planner::SetMaxPlanLength ( int  maxLength)

SetMaxPlanLength - Limits generated plans to not exceed given number of steps to achieve goal conditions.

TODO unsigned or size_t ? can negative depth be useful?

Parameters
maxLengthMaximum number of plan steps

◆ SetPlanFoundCallback()

void grail::planner::Planner::SetPlanFoundCallback ( const std::function< void(const AbstractPlan &)>  callbackFunction)

SetPlanFoundCallback - Binds a function handle to call if a sufficient plan is found. Best plan will be passed as function argument.

Parameters
callbackFunctionFunction to call if plan is found

◆ SetPlanningFailedCallback()

void grail::planner::Planner::SetPlanningFailedCallback ( const std::function< void()>  callbackFunction)

SetPlanningFailedCallback - Binds a function handle to call if no sufficient plan was found.

Parameters
callbackFunctionFunction to call if planning failed

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