📝Goal-Oriented Action Planning
- tags
GOAP is an AI engine architecture that plans multiple action path to satisfy a weighted set of goals and selects the plan with the minimum cost.
It operates on a world state—a set of facts about the world. Each action has a cost, preconditions, and post-conditions.
GOAP planner first translates a goal to a list of conditions (facts) that needs to be satisfied, and then searches backwards from the desired state through actions until all conditions are satisfied.
A* can be used to optimize the search (as the solution space can get quite large).
Example
Current world: {HasMeleeWeapon}
Goal: Kill X
Available actions:
| Action | Requires | Satisfies |
|---|---|---|
| MeleeAttack X | HasMeleeWeapon, AtTarget X | Attacking X |
| RangedAttack X | HasRangedWeapon, NearTarget X | Attacking X |
| GotoTarget X | AtTarget X, NearTarget X |
The planner first translates Kill X into Attacking X, so the world starts as: has: {HasMeleeWeapon}, needs: {Attacking X}.
Planner then explores two actions that satisfy Attacking X: MeleeAttack and RangedAttack. MeleeAttack already has one condition satisfied (HasMeleeWeapon), so it has higher heuristic and is explored first.
The world state at this point is: has: {HasMeleeWeapon, Attacking X}, needs: {HasMeleeWeapon, AtTarget X}. Plan is [MeleeAttack X].
Now the planner picks GotoTarget X as it satisfies the needed condition.
The world state is now: has: {HasMeleeWeapon, Attacking X, AtTarget X}, needs: {}. Plan is [GotoTarget X, MeleeAttack X]. All required conditions are satisfied, so that’s a valid plan and can be followed.
Resources
Backlinks
- 📝 § Gamedev