pub enum CompositionConfig {
Show 16 variants
Sequence {
children: Vec<CompositionConfig>,
name: Option<String>,
},
Selector {
children: Vec<CompositionConfig>,
name: Option<String>,
},
WeightedSelect {
children: Vec<WeightedChildConfig>,
name: Option<String>,
},
Parallel {
children: Vec<CompositionConfig>,
policy: ParallelPolicyConfig,
name: Option<String>,
},
Watch {
children: Vec<CompositionConfig>,
policy: ParallelPolicyConfig,
name: Option<String>,
},
Subsumption {
layers: Vec<SubsumptionLayerConfig>,
name: Option<String>,
},
Inverter {
child: Box<CompositionConfig>,
name: Option<String>,
},
ForceSuccess {
child: Box<CompositionConfig>,
name: Option<String>,
},
ForceFailure {
child: Box<CompositionConfig>,
name: Option<String>,
},
Repeat {
child: Box<CompositionConfig>,
count: Option<u32>,
name: Option<String>,
},
Retry {
child: Box<CompositionConfig>,
max_attempts: u32,
name: Option<String>,
},
Timeout {
child: Box<CompositionConfig>,
timeout_secs: f64,
name: Option<String>,
},
Cooldown {
child: Box<CompositionConfig>,
cooldown_secs: f64,
name: Option<String>,
},
Condition {
condition: ConditionConfig,
child: Box<CompositionConfig>,
name: Option<String>,
},
Include {
path: String,
name: Option<String>,
},
Node {
node: String,
config_ref: Option<String>,
config: Option<Value>,
name: Option<String>,
},
}Expand description
A node in a behavior tree: either a composite control-flow node or a leaf behavior node.
Variants§
Sequence
Runs its children in order, stopping early if one fails.
Fields
children: Vec<CompositionConfig>Child nodes to run in order.
Selector
Runs its children in order, stopping early if one succeeds.
Fields
children: Vec<CompositionConfig>Child nodes to try in order.
WeightedSelect
Like Selector, but instead of always trying children in a fixed index order, picks the
next untried child via a weighted-random draw among children not yet tried this
resolution cycle. A child’s weight of 0.0 (or negative) means it is never picked.
Otherwise behaves exactly like Selector: a chosen child returning Running is re-ticked
next tick (not re-rolled); a chosen child returning Success resolves the whole node to
Success; once every positive-weight child has been tried and failed, the node fails.
Fields
children: Vec<WeightedChildConfig>Child nodes, each with a weight controlling how likely it is to be tried next.
Parallel
Runs all of its children concurrently.
Fields
children: Vec<CompositionConfig>Child nodes to run concurrently.
policy: ParallelPolicyConfigPolicy determining when this node succeeds based on its children’s outcomes.
Watch
Like Parallel, but every child is re-ticked every call regardless of its previous
status - no “frozen once resolved” memory. Use this for a condition that must be
re-evaluated indefinitely, e.g. inside a Subsumption layer.
Fields
children: Vec<CompositionConfig>Child nodes, all re-ticked every call.
policy: ParallelPolicyConfigPolicy determining when this node succeeds/fails based on its children’s outcomes.
Subsumption
Priority-based preemption (subsumption architecture): tries each layer highest-priority
first; the first to return Running/Success wins for that tick. A layer returns
Failure to cede control to the next layer down, within the same tick.
Fields
layers: Vec<SubsumptionLayerConfig>Priority layers, highest priority first (ties broken by declaration order).
Inverter
Negates its child’s Success/Failure result; Running passes through unchanged.
Fields
child: Box<CompositionConfig>The single child node to invert.
ForceSuccess
Reports Success once its child resolves, regardless of the child’s actual result;
Running passes through unchanged. Useful for an optional/best-effort step whose
failure shouldn’t abort a surrounding Sequence.
Fields
child: Box<CompositionConfig>The single child node to force-succeed.
ForceFailure
Reports Failure once its child resolves, regardless of the child’s actual result;
Running passes through unchanged. The mirror of ForceSuccess.
Fields
child: Box<CompositionConfig>The single child node to force-fail.
Repeat
Re-runs its child every time it succeeds, up to an optional fixed count; a Failure
ends the loop immediately with Failure. Omit count to repeat indefinitely.
Fields
child: Box<CompositionConfig>The single child node to repeat.
Retry
Re-runs its child up to max_attempts times whenever it fails, succeeding as soon as one
attempt succeeds; only fails once every attempt is exhausted.
Fields
child: Box<CompositionConfig>The single child node to retry.
Timeout
Bounds how long its child may stay Running: fails immediately once timeout_secs have
elapsed since this node started ticking the child (without resolving).
Fields
child: Box<CompositionConfig>The single child node to bound.
Cooldown
Bounds the GAP between runs of its child - the complement of Timeout (which bounds how
long a single run may stay Running). Once the child returns a terminal result
(Success/Failure), refuses to re-tick it for cooldown_secs: tick() returns
Failure immediately, without ticking the child at all, until the window elapses. A
child that returns Running does not start the cooldown clock.
Fields
child: Box<CompositionConfig>The single child node to cool down between runs of.
Condition
Gates its single child on a condition predicate: evaluates the predicate first and only
ticks the child (forwarding its status) while it holds; reports Failure without ticking
the child when it doesn’t. A small, reusable building block - dropping several
condition-wrapped children into a selector gives capability- or state-gated branch
selection, since the selector advances past any Failure child to the next option.
Fields
condition: ConditionConfigThe predicate to evaluate before ticking child.
child: Box<CompositionConfig>The single child node to gate.
Include
Inlines another composition node loaded from a separate JSON file, so multiple behaviors
can share one subtree definition (e.g. a common interrupt layer) without duplicating it
in every config.json. The referenced file’s content must be a single bare
CompositionConfig JSON object - the same tagged "type" shape as any other node in a
tree - NOT a full BehaviorConfig envelope (no name/configs/$schema wrapper).
Only supported when the behavior tree itself was loaded from a file (BehaviorLoader:: load_from_file); path is resolved relative to the directory containing the config.json
this include node appears in (itself, if the fragment nests further includes) - NOT
relative to the current working directory. Loading via load_from_json/load with a
bare in-memory BehaviorConfig has no base directory to resolve against and fails if the
tree contains an include node.
Fields
Node
A leaf node that runs a single behavior node implementation.
Trait Implementations§
Source§impl Clone for CompositionConfig
impl Clone for CompositionConfig
Source§impl Debug for CompositionConfig
impl Debug for CompositionConfig
Source§impl<'de> Deserialize<'de> for CompositionConfig
impl<'de> Deserialize<'de> for CompositionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for CompositionConfig
impl JsonSchema for CompositionConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for CompositionConfig
impl RefUnwindSafe for CompositionConfig
impl Send for CompositionConfig
impl Sync for CompositionConfig
impl Unpin for CompositionConfig
impl UnsafeUnpin for CompositionConfig
impl UnwindSafe for CompositionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more