Skip to content

DEV GOAP AI Framework

Saveliy Tronza edited this page Jul 5, 2020 · 1 revision

This page is meant for internal use

For a basic overview see GOAP (basic)

How to use the AI framework

Goal and Action Parameters

Goals and Actions use the same format for parameters. Parameters is an array of [_tag, _value] where _tag can be a string or number.


Goals

Goals are static classes. You DO NOT create a Goal object.

Goals have effects, relevance, predefined action and parameters.

Parameters

Parameters typically come from a higher entity which gave this goal to an agent.

Effects

Goal Effects is the desired world state when goal has been reached. Effects are only required if the predefined action is not set. Effects can be static, derived from parameters and procedural.

  • Setting static effects: Code

  • Setting effects from parameters: Code (note the true passed as an argument, which indicates that it's derived from parameter) Framework will try to find a parameter with given tag and copy its value to specified world state property.

  • Setting procedural effects: override Goal's ""getEffects" method. Do this when you can't just copy a parameter value into the Effects world state, but must use code to get it. For instance, getting a position of an object which is passed as parameter.

Relevance

Calculate relevance in "calculateRelevance" static method.

Predefined action

If you don't need the planner to find an action plan for a goal, set its predefined action like this: code. If predefined action is not set, the planner will be run to find a plan to satisfy goal's effects.


Actions

Actions have preconditions, parameters, effects and cost.

Parameters

Parameters are passed to an action from its effects or from the goal parameters. Action parameters are resolved in following order:

  1. Goal parameters are propagated into action parameters, if action has a parameter with given tag and is set to accept a goal parameter with this tag. Set an action's parameter from goal this way: code.
  2. Effects are propagated into corresponding action parameters. See below how to specify affect that are propagated into parameters. NOTE Currently you can't make an action's that has parameters from goal and from effects with the same tag!

Cost

Cost can be static or procedural. Set static cost: code. For procedural cost override "getCost" method of your action class.

Effects

Effects can be static or depend on a parameter.

  • Setting static effects: code.

  • Setting effects from parameters: code. Parametric effects are defined in a similar way to Goal parametric effects. Framework will pass the value to parameter with specified tag of the Action.

Preconditions

Preconditions can be static or procedural.

  • Setting static preconditions: code.
  • Setting procedural preconditions: override your action's "getPreconditions" method.

Database

WIP

World State

WIP

Sensors

WIP