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

The main class encapsulating the planning algorithm in Grail. Responsible for finding paths in an abstract plans space.
You can use this class directly (as a raw algorithm) or indirectly through a Reasoners.PlannerReasoner instead. More...

Classes

struct  AbstractPlan
 
class  Config
 The Planner run-time configuration parameters. More...
 

Public Member Functions

 Planner ()
 Constructs a new planner object with no initial state set. More...
 
 Planner (WorldState initialState)
 Constructs a new planner object with a provided initial state and a default configuration. More...
 
 Planner (WorldState initialState, Config config)
 Constructs a new planner object with a provided initial state and the provided run-time configuration. More...
 
void PushCondition (ConditionFunction condition)
 Adds a goal satisfaction condition to the planner.
The planner may have multiple independent conditions defined. More...
 
void IterateWithSnapshot (int iterations, PlannerReasonerSnapshot snapshot, long minDebugSnapshotIteration=0, long maxDebugSnapshotIteration=long.MaxValue)
 Runs the planning process in a DEBUG mode for the given number of iterations.
The algorithm will try to formulate a plan starting from the initial state to a state that meets goalConditions. It will call OnPlanningFailed or when finished. More...
 
void Iterate (int iterations)
 Runs the planning process for the given number of iterations.
The algorithm will try to formulate a plan starting from the initial state to a state that meets goalConditions. It will call OnPlanningFailed or when finished. More...
 
void Reset (WorldState initialState)
 Performs a full reset of the planner. A typical usage is before a new decision point that requires a new plan.
Please note that this includes setting a new start state, clearing goal conditions, resetting the current iteration number. More...
 
AbstractPlan GetPartialPlan ()
 Returns the current best plan, regardless of whether the goal conditions are met. More...
 

Public Attributes

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

Properties

int IterationLimit [get, set]
 Sets or gets the number of iterations per each execution of the planning problem. Each iteration ends with one candidate plan. More...
 
int MaxPlanLength [get, set]
 Sets of gets the maximum number of actions (steps) a plan can take. Set -1 for unlimited plans. More...
 
float MaxPlanCost [get, set]
 Sets or gets an upper bound on the plan cost measured as the sum of costs of actions it consists of. Set -1 for no limit.
It may limit the possible plans generated (if they would exceed this cost). More...
 
PlannerHeuristic Heuristic [set]
 Enables the planner to heuristically evaluate the calculated plans.
Similarly to A* pathfinding heuristic, it should return the estimation of the distance (cost) between an arbitrary state and the goal state. More...
 
PlanFoundDelegate OnPlanFound [set]
 Callback executed whenever a new plan has been found by the algorithm. More...
 
System.Action OnPlanningFailed [set]
 Callback executed if no plans were found in the allotted iteration budget and satisfying the MaxPlanLength and MaxPlanCost limits. More...
 

Detailed Description

The main class encapsulating the planning algorithm in Grail. Responsible for finding paths in an abstract plans space.
You can use this class directly (as a raw algorithm) or indirectly through a Reasoners.PlannerReasoner instead.

Constructor & Destructor Documentation

◆ Planner() [1/3]

Grail.Planners.Planner.Planner ( )
inline

Constructs a new planner object with no initial state set.

◆ Planner() [2/3]

Grail.Planners.Planner.Planner ( WorldState  initialState)
inline

Constructs a new planner object with a provided initial state and a default configuration.

Parameters
initialStateThe initial state of the planning space. The plans will be created from this state to the goal state.

◆ Planner() [3/3]

Grail.Planners.Planner.Planner ( WorldState  initialState,
Config  config 
)
inline

Constructs a new planner object with a provided initial state and the provided run-time configuration.

Parameters
initialStateThe initial state of the planning space. The plans will be created from this state to the goal state.
configConfiguration with parameters for the planner.

Member Function Documentation

◆ GetPartialPlan()

AbstractPlan Grail.Planners.Planner.GetPartialPlan ( )
inline

Returns the current best plan, regardless of whether the goal conditions are met.

Returns
The current best plan or an empty plan if not enough calculations were performed.

◆ Iterate()

void Grail.Planners.Planner.Iterate ( int  iterations)
inline

Runs the planning process for the given number of iterations.
The algorithm will try to formulate a plan starting from the initial state to a state that meets goalConditions. It will call OnPlanningFailed or when finished.

Parameters
iterationsThe max number of plan iterations to calculate.

◆ IterateWithSnapshot()

void Grail.Planners.Planner.IterateWithSnapshot ( int  iterations,
PlannerReasonerSnapshot  snapshot,
long  minDebugSnapshotIteration = 0,
long  maxDebugSnapshotIteration = long.MaxValue 
)
inline

Runs the planning process in a DEBUG mode for the given number of iterations.
The algorithm will try to formulate a plan starting from the initial state to a state that meets goalConditions. It will call OnPlanningFailed or when finished.

Parameters
iterationsThe max number of plan iterations to calculate.
snapshotDebug data is outputted to the snapshot every iteration within min and max snapshot iteration parameters.
minDebugSnapshotIterationStarting from this iteration number, debug data will be included in the snapshot.
maxDebugSnapshotIterationThe last number of iteration from which the debug data will be included in the snapshot.

◆ PushCondition()

void Grail.Planners.Planner.PushCondition ( ConditionFunction  condition)
inline

Adds a goal satisfaction condition to the planner.
The planner may have multiple independent conditions defined.

Parameters
conditionA boolean function that returns true if the specific goal condition has been reached and false otherwise.

◆ Reset()

void Grail.Planners.Planner.Reset ( WorldState  initialState)
inline

Performs a full reset of the planner. A typical usage is before a new decision point that requires a new plan.
Please note that this includes setting a new start state, clearing goal conditions, resetting the current iteration number.

Parameters
initialStateThe new initial state the formulated plans will start from.

Member Data Documentation

◆ IsComputing

bool Grail.Planners.Planner.IsComputing => !isPlanningFinished

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

Property Documentation

◆ Heuristic

PlannerHeuristic Grail.Planners.Planner.Heuristic
set

Enables the planner to heuristically evaluate the calculated plans.
Similarly to A* pathfinding heuristic, it should return the estimation of the distance (cost) between an arbitrary state and the goal state.

◆ IterationLimit

int Grail.Planners.Planner.IterationLimit
getset

Sets or gets the number of iterations per each execution of the planning problem. Each iteration ends with one candidate plan.

◆ MaxPlanCost

float Grail.Planners.Planner.MaxPlanCost
getset

Sets or gets an upper bound on the plan cost measured as the sum of costs of actions it consists of. Set -1 for no limit.
It may limit the possible plans generated (if they would exceed this cost).

◆ MaxPlanLength

int Grail.Planners.Planner.MaxPlanLength
getset

Sets of gets the maximum number of actions (steps) a plan can take. Set -1 for unlimited plans.

◆ OnPlanFound

PlanFoundDelegate Grail.Planners.Planner.OnPlanFound
set

Callback executed whenever a new plan has been found by the algorithm.

◆ OnPlanningFailed

System.Action Grail.Planners.Planner.OnPlanningFailed
set

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


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