langgoap.MultiGoal

langgoap.MultiGoal#

class MultiGoal(goals, mode='sequential')[source]#

A composite goal made up of one or more GoalSpec children.

Two execution modes are supported:

  • "sequential" (default) — the observer plans and executes goals[0] to completion, then uses the resulting world state as the starting state for goals[1], and so on. This is the right model when sub-goals represent successive stages of a workflow (e.g. “collect data → analyse → publish”).

  • "any" — the planner plans each sub-goal independently and the observer picks the lowest-Score feasible plan. Useful when several possible goals are acceptable and the system should chase the cheapest one.

Recursive (HTN-style) decomposition where a sub-goal is itself a MultiGoal is out of scope for v0.1.0 — only flat composition is supported and __post_init__() rejects non-GoalSpec children with a clear ValueError.

In "any" mode, ties on plan cost are broken by list order: the first sub-goal whose plan has the lowest cost wins. This makes the order of goals semantically meaningful when several candidates are equally cheap.

Parameters:
  • goals (tuple[GoalSpec, ...]) – Non-empty sequence of GoalSpec children. Accepts tuples or lists; a list is coerced to a tuple.

  • mode (Literal['sequential', 'any', 'best_value']) – Either "sequential" or "any".

__init__(goals, mode='sequential')#
Parameters:
  • goals (tuple[GoalSpec, ...])

  • mode (Literal['sequential', 'any', 'best_value'])

Return type:

None

Methods

__init__(goals[, mode])

Attributes

goals

mode