Skip to main content

CompositionConfig

Enum CompositionConfig 

Source
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.

§name: Option<String>

Optional name for this node.

§

Selector

Runs its children in order, stopping early if one succeeds.

Fields

§children: Vec<CompositionConfig>

Child nodes to try in order.

§name: Option<String>

Optional name for this node.

§

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.

§name: Option<String>

Optional name for this node.

§

Parallel

Runs all of its children concurrently.

Fields

§children: Vec<CompositionConfig>

Child nodes to run concurrently.

§policy: ParallelPolicyConfig

Policy determining when this node succeeds based on its children’s outcomes.

§name: Option<String>

Optional name for this node.

§

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: ParallelPolicyConfig

Policy determining when this node succeeds/fails based on its children’s outcomes.

§name: Option<String>

Optional name for this node.

§

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).

§name: Option<String>

Optional name for this node.

§

Inverter

Negates its child’s Success/Failure result; Running passes through unchanged.

Fields

§child: Box<CompositionConfig>

The single child node to invert.

§name: Option<String>

Optional name for this node.

§

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.

§name: Option<String>

Optional name for this node.

§

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.

§name: Option<String>

Optional name for this node.

§

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.

§count: Option<u32>

Number of successful runs required before this node succeeds. Omit to repeat indefinitely (the node only ever stops via the child failing).

§name: Option<String>

Optional name for this node.

§

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.

§max_attempts: u32

Maximum number of attempts (must be at least 1).

§name: Option<String>

Optional name for this node.

§

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.

§timeout_secs: f64

Maximum time, in seconds, the child is allowed to stay Running.

§name: Option<String>

Optional name for this node.

§

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.

§cooldown_secs: f64

How long, in seconds, to refuse to re-tick the child after it resolves.

§name: Option<String>

Optional name for this node.

§

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: ConditionConfig

The predicate to evaluate before ticking child.

§child: Box<CompositionConfig>

The single child node to gate.

§name: Option<String>

Optional name for this node.

§

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

§path: String

Path to the fragment file, relative to the including file’s own directory.

§name: Option<String>

Optional name for this node (describes the include site, not the fragment itself).

§

Node

A leaf node that runs a single behavior node implementation.

Fields

§node: String

Name of the behavior node type to run.

§config_ref: Option<String>

Key into the top-level configs map to use as this node’s configuration.

§config: Option<Value>

Inline configuration for this node.

§name: Option<String>

Optional name for this node.

Trait Implementations§

Source§

impl Clone for CompositionConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompositionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CompositionConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for CompositionConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for CompositionConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more