Jido.BehaviorTree.Nodes.Repeat (Jido Behavior Tree v1.0.0)

View Source

A decorator node that repeats its child a specified number of times.

The node ticks the child repeatedly until:

  • The child has succeeded count times (returns :success)
  • The child fails (returns :failure immediately)
  • The child returns :running (returns :running)

Example

repeat = Repeat.new(attack_action, 3)
# Executes attack_action 3 times before succeeding

Summary

Functions

Creates a new Repeat node that repeats the child count times.

Returns the Zoi schema for this module

Context-aware tick that preserves child tick mutations.

Types

t()

@type t() :: %Jido.BehaviorTree.Nodes.Repeat{
  child: any(),
  count: integer(),
  current_iteration: integer()
}

Functions

new(child, count)

@spec new(Jido.BehaviorTree.Node.t(), pos_integer()) :: t()

Creates a new Repeat node that repeats the child count times.

Examples

iex> Repeat.new(child_node, 5)
%Repeat{child: child_node, count: 5, current_iteration: 0}

schema()

Returns the Zoi schema for this module

tick_with_context(state, tick)

Context-aware tick that preserves child tick mutations.