Jido. BehaviorTree. Nodes. Selector
(Jido Behavior Tree v1.0.0)
View Source
A composite node that selects the first successful child.
The Selector node executes each child in order until one succeeds. If any child succeeds, the selector succeeds immediately. If all children fail, the selector fails. If a child returns running, the selector returns running and will resume from that child on the next tick.
Also known as a "fallback" or "priority" node.
Example
selector = Selector.new([
TryOption1.new(),
TryOption2.new(),
FallbackOption.new()
])
Summary
Functions
Creates a new Selector node with the given children.
Returns the Zoi schema for this module
Context-aware tick that threads the tick through child nodes.
Types
Functions
@spec new([Jido.BehaviorTree.Node.t()]) :: t()
Creates a new Selector node with the given children.
Examples
iex> Selector.new([node1, node2, node3])
%Selector{children: [node1, node2, node3], current_index: 0}
Returns the Zoi schema for this module
@spec tick_with_context(t(), Jido.BehaviorTree.Tick.t()) :: {Jido.BehaviorTree.Status.t(), t(), Jido.BehaviorTree.Tick.t()}
Context-aware tick that threads the tick through child nodes.
Used by Tree.tick_with_context/2 to ensure agent state and directives
are properly accumulated as children execute.