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

A class representing a model (family) of an action that can be simulated by a planner. Action objects are produced based on the ActionTemplate. More...

Public Member Functions

delegate bool PreconditionFunction (List< WorldObject > worldObjects, WorldState state)
 Delegate for Preconditions; Preconditions. More...
 
delegate void EffectFunction (List< WorldObject > worldObjects, WorldState state)
 Delegate for Effects; Effects. More...
 
delegate float CostFunction (List< WorldObject > worldObjects, WorldState state)
 Delegate for Cost; Cost. More...
 
 ActionTemplate (string name, List< int > actionParameterTypes)
 Constructs a new ActionTemplate object. After creation, please remember to assign the ConditionFunction, EffectFunction, and CostFunction. More...
 
List< ActionGenerateActions (WorldState state)
 Generates all action instances based on the action template and the given state. More...
 

Public Attributes

string Name => name
 Gets a log-friendly name of the actions produced by the template. More...
 

Properties

PreconditionFunction Preconditions [get, set]
 A precondition function that will be checked to verify the legality of the action. Represented as a boolean function accepting a vector of action arguments (WorldObjects) and the current WorldState reference. More...
 
EffectFunction Effects [get, set]
 A function applied to the world state each time this action is performed in a planner iteration. Represented as a function returning void and accepting a vector of action arguments (WorldObjects) and the current WorldState reference. More...
 
CostFunction Cost [get, set]
 A function returning execution cost of the action, given a world state Represented as a function returning a number representing the action's cost, accepting a vector of action arguments (WorldObjects) and the current WorldState reference More...
 
int TypeID [get, set]
 A unique ID of the action template. More...
 

Detailed Description

A class representing a model (family) of an action that can be simulated by a planner. Action objects are produced based on the ActionTemplate.

Constructor & Destructor Documentation

◆ ActionTemplate()

Grail.Planners.ActionTemplate.ActionTemplate ( string  name,
List< int >  actionParameterTypes 
)
inline

Constructs a new ActionTemplate object. After creation, please remember to assign the ConditionFunction, EffectFunction, and CostFunction.

Parameters
nameThe name of this family of actions.
actionParameterTypesIDs of types of objects that are parameters of the actions instantiated using this template. E.g. name=attack; actionParameterTypes={enemyTypeIDs}

Member Function Documentation

◆ CostFunction()

delegate float Grail.Planners.ActionTemplate.CostFunction ( List< WorldObject worldObjects,
WorldState  state 
)

Delegate for Cost; Cost.

Parameters
worldObjectsSpecific objects assigned as the arguments of the action.
stateThe current world state. Provided as the extra context. You can use both or just one of the parameters of this function.
Returns

◆ EffectFunction()

delegate void Grail.Planners.ActionTemplate.EffectFunction ( List< WorldObject worldObjects,
WorldState  state 
)

Delegate for Effects; Effects.

Parameters
worldObjectsSpecific objects assigned as the arguments of the action.
stateThe world state object to apply the effects to.

◆ GenerateActions()

List<Action> Grail.Planners.ActionTemplate.GenerateActions ( WorldState  state)
inline

Generates all action instances based on the action template and the given state.

Constructor

Parameters
name-
actionParameterTypes-
preconditionFunction- a boolean function accepting a vector of action arguments (WorldObjects) and the current WorldState reference
effectFunction- a function returning void and accepting a vector of action arguments (WorldObjects) and the current WorldState reference
costFunction- a function returning a number representing the action's cost, accepting a vector of action arguments (WorldObjects) and the current WorldState reference
stateThe current state of the planner
Returns
A list of actions with parameters that could be generated in the current state of the planner.

◆ PreconditionFunction()

delegate bool Grail.Planners.ActionTemplate.PreconditionFunction ( List< WorldObject worldObjects,
WorldState  state 
)

Delegate for Preconditions; Preconditions.

Parameters
worldObjectsSpecific objects assigned as the arguments of the action.
stateThe current world state. Provided as the extra context. You can use both or just one of the parameters of this function.
Returns

Member Data Documentation

◆ Name

string Grail.Planners.ActionTemplate.Name => name

Gets a log-friendly name of the actions produced by the template.

Property Documentation

◆ Cost

CostFunction Grail.Planners.ActionTemplate.Cost
getset

A function returning execution cost of the action, given a world state Represented as a function returning a number representing the action's cost, accepting a vector of action arguments (WorldObjects) and the current WorldState reference

If this is still unclear, please consult the web documentation.

◆ Effects

EffectFunction Grail.Planners.ActionTemplate.Effects
getset

A function applied to the world state each time this action is performed in a planner iteration. Represented as a function returning void and accepting a vector of action arguments (WorldObjects) and the current WorldState reference.

If this is still unclear, please consult the web documentation.

◆ Preconditions

PreconditionFunction Grail.Planners.ActionTemplate.Preconditions
getset

A precondition function that will be checked to verify the legality of the action. Represented as a boolean function accepting a vector of action arguments (WorldObjects) and the current WorldState reference.

If this is still unclear, please consult the web documentation.

◆ TypeID

int Grail.Planners.ActionTemplate.TypeID
getset

A unique ID of the action template.


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