langgoap.plan#
- plan(start, goal, actions, blacklisted_actions=None, *, time_budget_ms=None, tracer=None, record_expansions=False, blacklist_fallback=None)[source]#
Find an optimal action sequence from start to goal using A*.
- Parameters:
start (PlanningState | dict[str, Any]) – Current world state. Accepts a plain
dictfor convenience; it will be coerced toPlanningStateinternally.goal (GoalSpec) – Goal specification with target conditions.
actions (list[ActionSpec]) – Available actions to choose from.
blacklisted_actions (list[str] | None) – Action names to exclude from planning.
blacklist_fallback (bool | None) – When the blacklist makes the goal unreachable,
Trueretries with the full action set (re-admitting the blacklisted actions) instead of returningNone.None(default) readsgoal.policy.blacklist_fallback, which isFalseunless the caller opted in: a permanently failing, human-denied, or guard-blocked action must not be re-run just because it is the only path (issue #15).time_budget_ms (float | None) – Optional wall-clock budget in milliseconds. When set, the search is anytime: weighted A* runs with the tightening schedule
ANYTIME_WEIGHTS, so a complete (bounded-suboptimal) plan is available early and is improved while the budget lasts; the final iteration is optimal A*. On expiry the best complete plan found so far is returned, orNonewhen not even the loosest iteration finished.None(the default) means no limit — plain optimal A*.tracer (Any) – Optional
PlanningTracerthat receives per-expansion, dead-end, and completion events whenrecord_expansionsis alsoTrue.record_expansions (bool) – Opt-in gate for the search-tree firehose. Off by default so production planning stays zero-overhead.
- Returns:
A Plan if a path exists, None if the goal is unreachable.
- Return type:
Plan | None