pub struct WeightedSelectNode { /* private fields */ }Expand description
Like SelectOrNode (ticks children until one returns non-Failure), but instead of always
trying children in a fixed index order, each tick-cycle picks the next untried child via a
weighted-random draw among children not yet tried THIS resolution cycle. A weight of 0.0 (or
negative) means that child is never picked. Once a child is chosen it is “sticky”: while it
reports Running, the next tick() re-ticks that same child rather than re-rolling - only
once it resolves does the node either return (on Success) or roll again among the remaining
untried children (on Failure), mirroring SelectOrNode::current_index’s “resume where we
left off” behavior, just with a random rather than fixed starting point each cycle.
Implementations§
Source§impl WeightedSelectNode
impl WeightedSelectNode
Sourcepub fn new(weighted_children: Vec<(f64, BoxedBehavior)>) -> Self
pub fn new(weighted_children: Vec<(f64, BoxedBehavior)>) -> Self
Create a new weighted selector from (weight, child) pairs, using a freshly OS-seeded
RNG. Negative weights are clamped to 0.0 (never picked).
Trait Implementations§
Source§impl BehaviorNode for WeightedSelectNode
impl BehaviorNode for WeightedSelectNode
Source§fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
NodeStatus.Source§fn reset_self(&mut self)
fn reset_self(&mut self)
Source§fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
Source§fn active_capability(&self) -> Option<&str>
fn active_capability(&self) -> Option<&str>
capability this node implies should be published on /behavior/status while it’s
actively being ticked; None for nodes with no such gate (the default). Composite nodes
override this to forward whichever child is currently active.Source§fn status_snapshot(&self) -> TreeStatusSnapshot
fn status_snapshot(&self) -> TreeStatusSnapshot
tick(), for live behavior-tree visualization. The default implementation reports
status: None (as if never ticked) and no children - correct for a brand-new node type
that hasn’t been wired up for status tracking yet, but every node type should override
this once it stores a last_status field: leaf nodes return their own last_status,
composite nodes additionally recurse into children_mut’s non-mut counterpart (there’s
no shared non-mut child accessor, so each composite overrides this to walk its own child
collection directly - same pattern as children_mut).Source§fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for WeightedSelectNode
impl !UnwindSafe for WeightedSelectNode
impl Freeze for WeightedSelectNode
impl Send for WeightedSelectNode
impl Sync for WeightedSelectNode
impl Unpin for WeightedSelectNode
impl UnsafeUnpin for WeightedSelectNode
Blanket Implementations§
Source§impl<T> BehaviorNodeExt for Twhere
T: BehaviorNode + ?Sized,
impl<T> BehaviorNodeExt for Twhere
T: BehaviorNode + ?Sized,
Source§fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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> 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