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

t()

@type t() :: %Jido.BehaviorTree.Nodes.Selector{
  children: [any()],
  current_index: integer()
}

Functions

new(children)

@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}

schema()

Returns the Zoi schema for this module

tick_with_context(state, tick)

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.