Summary

Goal-Oriented Action Planning (GOAP) is a deliberative AI architecture in which an agent chooses a goal, searches for a sequence of actions that could achieve it, and then executes that plan while monitoring whether replanning is needed. It is most useful when the designer wants emergent multi-step problem solving rather than only reactive branch selection. (Millington, Artificial Intelligence for Games, see source-artificial-intelligence-for-games)

Key ideas

  • World state: facts currently believed true.
  • Goal: a desired future state.
  • Action: has preconditions and effects.
  • Planner: searches for a valid action chain.
  • Replanning: if the world changes enough, the plan may need to be rebuilt.

Implementation

public sealed class GoapAction
{
    public string Name;
    public int Cost;
    public HashSet<string> Preconditions = new();
    public HashSet<string> Effects = new();
}

Minimal planning loop:

  1. Read current world state.
  2. Pick the most important goal.
  3. Search for actions whose effects can satisfy the goal.
  4. Execute the first action in the plan.
  5. Re-evaluate if the world state changes.

In Unity, keep the planner separate from movement. The planner should decide what sequence to pursue; steering or navigation decides how to move there.

Trade-offs

  • Stronger than behaviour-trees when long multi-step reasoning matters.
  • More expensive and less predictable than an FSM or BT.
  • Requires careful authoring of preconditions and effects or the search space becomes noisy.

Examples

  • Classic GOAP examples include agents deciding whether to find a weapon, secure cover, flank, or heal before attacking.
  • Buckland’s goal-driven behaviour is not identical to formal GOAP, but it is a useful stepping stone because it introduces desirability-driven goal arbitration and queued subgoals (Buckland, Programming Game AI by Example, see source-programming-game-ai-by-example).

game-ai-agent-design · overview-cre341-agent-ai-route · behaviour-trees-vs-goap · behaviour-trees · ai-state-machine-pattern · pathfinding-algorithms · source-artificial-intelligence-for-games