dcsex.containers.goap

Goal-Oriented Action Planning system.

Contents

  1. Description
  2. Functions
    1. Property:__init(__id, value)
    2. Property:copy()
    3. WorldState:__init(props)
    4. WorldState:iterate()
    5. WorldState:copy()
    6. WorldState:get(id)
    7. WorldState:add(newprop)
    8. WorldState:remove(id)
    9. WorldState:unsatisfied(state)
    10. WorldState:distance(state)
    11. Action:__init(cost, precond, effects)
    12. Action:checkProceduralPreconditions(goalsofar)
    13. StateNode:__init(state, goal, action)
    14. StateNode:found(node)
    15. StateNode:unsatisfied()
    16. GOAPGraph:__init(agent, actions)
    17. GOAPGraph:add_action(action)
    18. GOAPGraph:handle_action(node, symbol, action)
    19. GOAPGraph:neighbors(node)

Description

Provides the basic building blocks to create an action planner. The unit tests serves as an example of its usage.

Functions

Property:__init(__id, value)

Parameters

__id
a globally unique ID of the symbol
value
the value of the symbol

Property:copy()

WorldState:__init(props)

Parameters

props
set of properties, where the key is the property ID, thus only one unique property may exist in a given state.

WorldState:iterate()

WorldState:copy()

WorldState:get(id)

Parameters

id

WorldState:add(newprop)

Parameters

newprop

WorldState:remove(id)

Parameters

id

WorldState:unsatisfied(state)

Thus we loop over our symbols and test if state has our symbol and if the two symbols are equal.

Parameters

state
the state to check against

Returns

  • list of property ids not satisfied by state

WorldState:distance(state)

This allows us to know we have x number of properties to become a sub-state of state. Remember our equality allows self to have fewer properties than state as long as all properties in self equal to properties in state, thus self is a sub-state of state.

Parameters

state
the state to calculate the distance to

Returns

  • distance from state

Action:__init(cost, precond, effects)

Parameters

cost
the cost of the action, used in finding the least cost path.
precond
a set of properties representing states that need to be true before the action can be executed.
effects
a set of properties representing states that the action purports to be able to achieve.

Action:checkProceduralPreconditions(goalsofar)

Parameters

goalsofar
goal the action is trying to satisify

Returns

  • bool true if the action should be considered in planning

StateNode:__init(state, goal, action)

Parameters

state
goal
action

StateNode:found(node)

Parameters

node

StateNode:unsatisfied()

GOAPGraph:__init(agent, actions)

Parameters

agent
actions

GOAPGraph:add_action(action)

Parameters

action

GOAPGraph:handle_action(node, symbol, action)

Parameters

node
symbol
action

GOAPGraph:neighbors(node)

Parameters

node