dcsex.containers.goap
Goal-Oriented Action Planning system.
Contents
- Description
- Functions
- Property:__init(__id, value)
- Property:copy()
- WorldState:__init(props)
- WorldState:iterate()
- WorldState:copy()
- WorldState:get(id)
- WorldState:add(newprop)
- WorldState:remove(id)
- WorldState:unsatisfied(state)
- WorldState:distance(state)
- Action:__init(cost, precond, effects)
- Action:checkProceduralPreconditions(goalsofar)
- StateNode:__init(state, goal, action)
- StateNode:found(node)
- StateNode:unsatisfied()
- GOAPGraph:__init(agent, actions)
- GOAPGraph:add_action(action)
- GOAPGraph:handle_action(node, symbol, action)
- 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