langgoap.GoapSubgraph

langgoap.GoapSubgraph#

class GoapSubgraph(actions, goal, *, strategy=None, tracer=None, history=None, sensors=None, guards=None, resolvers=None, record_expansions=False, transition_model=None, rng=None, stuck_handlers=None, max_stuck_iterations=3, termination_policies=None, executor='sequential', history_state='full')[source]#

A GOAP planner packaged as a reusable sub-graph.

Parameters:

:param : :param record_expansions: :param transition_model: :param rng: :param stuck_handlers: :param : :param max_stuck_iterations: Forwarded verbatim to

GoapGraph; see its docstring.

Parameters:

Example:

sub = GoapSubgraph(
    actions=[a1, a2, a3],
    goal=GoalSpec(conditions={"done": True}),
)
compiled = sub.compile()
result = compiled.invoke({"world_state": {}, "goal": goal})

result is the JSON-native state (execution_history entries are dicts); langgoap.rehydrate_state() converts it back to typed objects. When the sub-graph is compiled with a checkpointer, pass goal.to_dict() as the input goal.

__init__(actions, goal, *, strategy=None, tracer=None, history=None, sensors=None, guards=None, resolvers=None, record_expansions=False, transition_model=None, rng=None, stuck_handlers=None, max_stuck_iterations=3, termination_policies=None, executor='sequential', history_state='full')[source]#
Parameters:
Return type:

None

Methods

__init__(actions, goal, *[, strategy, ...])

compile(**compile_kwargs)

Compile the sub-graph.