pub enum CompositionConfig {
Sequence {
children: Vec<CompositionConfig>,
name: Option<String>,
},
Selector {
children: Vec<CompositionConfig>,
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>,
},
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.
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 (not Parallel) for a condition that
must be re-evaluated indefinitely, e.g. inside a Subsumption layer that needs to flip
between claiming and ceding control many times over a session.
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 one to return Running/Success “wins” and its status is returned for
this tick (lower-priority layers aren’t ticked at all that cycle, so their own internal
progress - e.g. a Sequence’s current child index - is naturally preserved rather than
reset, which is what gives a preempted lower layer “resume where it left off” semantics
for free). A layer returns Failure to cede control to the next layer down, within the
same tick - this matters: if every layer fails, Subsumption itself returns Failure,
which the top-level executor treats as “whole tree finished, reset everything” - so a
layer meant to cede control temporarily (not finish the whole tree) must never be the sole
reason the overall tick ends in Failure while a lower layer still has work to do; in
practice this means: as long as there’s always at least one always-available fallback
layer (e.g. the lowest-priority layer is something like wander/patrol that’s
essentially never Failure), a higher layer ceding just causes an immediate same-tick
fallthrough to that layer instead, and Subsumption returns that layer’s status
(typically Running) - never reaching the “all layers failed” case at all.
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.
Node
A leaf node that runs a single behavior node implementation.
Trait Implementations§
Source§impl Clone for CompositionConfig
impl Clone for CompositionConfig
Source§fn clone(&self) -> CompositionConfig
fn clone(&self) -> CompositionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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<CompositionConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CompositionConfig, <__D as Deserializer<'de>>::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 moreSource§impl Serialize for CompositionConfig
impl Serialize for CompositionConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto 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