Skip to content

Class: planner_action

GOAP action class implementing both action base and action planner. Captures execution as action and plans its internal logic with separate logics graph.

Examples: combat planner, anomaly planner, items looting planner, alife planner, state planner.

Source

C++ class planner_action : action_planner,action_base

Custom Constructor

planner_action

Extends

Constructors

Constructor

ts
new planner_action(): planner_action;

Default constructor.

Returns

planner_action

Overrides

action_planner.constructor

Constructor

ts
new planner_action(object?: Nillable<game_object>): planner_action;

Parameters

ParameterTypeDescription
object?Nillable<game_object>Target game object to work with, null is OK since correct object will be injected on setup.

Returns

planner_action

Overrides

ts
action_planner.constructor

Constructor

ts
new planner_action(object: Nillable<game_object>, name: string): planner_action;

Parameters

ParameterTypeDescription
objectNillable<game_object>Target game object to work with, null is OK since correct object will be injected on setup.
namestringName of the action, used for debug purposes mainly.

Returns

planner_action

Overrides

ts
action_planner.constructor

Methods

action()

ts
action(id: number): action_base;

Get action instance by unique id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the action to get.

Returns

action_base

Registered action instance.

Inherited from

action_planner.action


actual()

ts
actual(): boolean;

Returns

boolean

Whether state of current planner is actual.

Inherited from

action_planner.actual


add_action()

ts
add_action(id: number, action: action_base): void;

Add generic action by id for planner execution.

Parameters

ParameterTypeDescription
idnumberUnique identifier of new action.
actionaction_baseAction implementation containing preconditions, logics, effects and other meta infos.

Returns

void

Remarks

Do not add actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.

Inherited from

action_planner.add_action


add_effect()

ts
add_effect(property: world_property): void;

Add action effect. Describes what target world state is expected to be if action is completed.

Parameters

ParameterTypeDescription
propertyworld_propertyWorld state property describing a pair of evaluator ID and value.

Returns

void

Remarks

Do not mutate effects while the owner planner is updating; the engine asserts on graph changes during solving.


add_evaluator()

ts
add_evaluator(id: number, evaluator: property_evaluator): void;

Add evaluator instance for current action planner.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator.
evaluatorproperty_evaluatorInstance of evaluator linked to the id.

Returns

void

Remarks

Do not add evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.

Inherited from

action_planner.add_evaluator


add_precondition()

ts
add_precondition(property: world_property): void;

Add action execution precondition. When building logics graph, action will be considered blocked by some preconditions.

Parameters

ParameterTypeDescription
propertyworld_propertyWorld state property describing a pair of evaluator ID and value.

Returns

void

Remarks

Do not mutate preconditions while the owner planner is updating; the engine asserts on graph changes during solving.


clear()

ts
clear(): void;

Clear state of current action planner.

Returns

void

Inherited from

action_planner.clear


current_action()

ts
current_action(): action_base;

Get currently active action being executed.

Returns

action_base

Current action instance reference.

Remarks

Requires the planner to be initialized, usually after a successful update.

Inherited from

action_planner.current_action


current_action_id()

ts
current_action_id(): number;

Get currently active action identifier.

Returns

number

Unique identifier of current action.

Throws

If the planner is not initialized yet.

Inherited from

action_planner.current_action_id


evaluator()

ts
evaluator(id: number): property_evaluator;

Get evaluator instance by id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator to get.

Returns

property_evaluator

Registered property evaluator.

Inherited from

action_planner.evaluator


execute()

ts
execute(): void;

Lifecycle method. Execution tick of the action, called from object logics update cycle when current action is active.

Returns

void

Remarks

Called by the owning outer planner after initialize. Direct calls bypass planner state.


finalize()

ts
finalize(): void;

Lifecycle method called once on action execution stop. Means that action is finished / preconditions are not met anymore.

Returns

void

Remarks

Called by the owning outer planner. Direct calls are only useful when driving the planner action manually in tests or tools.


initialize()

ts
initialize(): void;

Lifecycle method called once on action execution start. Means that lifecycle of the action begun.

Returns

void

Remarks

Called by the owning outer planner. Direct calls are only useful when driving the planner action manually in tests or tools.


initialized()

ts
initialized(): boolean;

Returns

boolean

Whether object action planner is already initialized.

Inherited from

action_planner.initialized


remove_action()

ts
remove_action(id: number): void;

Remove action by unique id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the action to remove.

Returns

void

Remarks

Do not remove actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.

Inherited from

action_planner.remove_action


remove_effect()

ts
remove_effect(id: number): void;

Remove action effect. Action will be not considered as property changing for id anymore.

Parameters

ParameterTypeDescription
idnumberWorld state property id.

Returns

void

Remarks

Do not mutate effects while the owner planner is updating; the engine asserts on graph changes during solving.


remove_evaluator()

ts
remove_evaluator(id: number): void;

Remove evaluator instance from current action planner.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator for removal.

Returns

void

Remarks

Do not remove evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.

Inherited from

action_planner.remove_evaluator


remove_precondition()

ts
remove_precondition(id: number): void;

Remove precondition for action. When building logics graph, action will not be considered blocked by evaluator id states.

Parameters

ParameterTypeDescription
idnumberWorld state property id.

Returns

void

Remarks

Do not mutate preconditions while the owner planner is updating; the engine asserts on graph changes during solving.


set_goal_world_state()

ts
set_goal_world_state(state: world_state): void;

Set target world state to try to reach with all the graph logics. All graphs will be built from current state to goal world state with the shortest possible path.

Parameters

ParameterTypeDescription
stateworld_stateTarget world state to reach with planner.

Returns

void

Inherited from

action_planner.set_goal_world_state


set_weight()

ts
set_weight(weight: number): void;

Set weight of planner action switch.

Parameters

ParameterTypeDescription
weightnumberWeight value to express how prioritized action is.

Returns

void


setup()

ts
setup(object: game_object): void;

Setup planner for game object.

Parameters

ParameterTypeDescription
objectgame_objectClient game object to setup planner for.

Returns

void

Throws

If object is missing.

Inherited from

action_planner.setup


show()

ts
show(prefix: string): void;

Debug method. With mixed / debug build allows investigation of evaluators and actions matches. Helps to debug custom actions and actions pre-conditions with state printing in log files.

Note: Available only in mixed / debug engine builds, not for direct usage from lua.

Parameters

ParameterTypeDescription
prefixstringString prefix to display current action state in logs.

Returns

void

Inherited from

action_planner.show


update()

ts
update(): void;

Lifecycle method to handle generic game loop updates.

Returns

void

Throws

If the planner cannot build a non-empty action sequence to the target world state.

Inherited from

action_planner.update


weight()

ts
weight(first: world_state, second: world_state): number;

Comparator to check weight of switching one state to another.

Parameters

ParameterTypeDescription
firstworld_stateFirst state.
secondworld_stateSecond state.

Returns

number

Transition weight.

Properties

__name

ts
readonly __name: string;

LuaBind instance constructor name.

Inherited from

action_planner.__name


object

ts
readonly object: game_object;

Game object that is handled by current planner instance.

Inherited from

action_planner.object


storage

ts
readonly storage: property_storage;

Container reference with state of planner preconditions.

Inherited from

action_planner.storage


__name

ts
readonly static __name: string;

LuaBind class constructor name.

Inherited from

action_planner.__name