pub struct WorldState { /* private fields */ }Expand description
A set of named conditions describing the current state of the world from one agent’s perspective.
Conditions have two flavours:
- Bool — classic GOAP true/false flags.
- Float — numeric values (health, ammo count, distance…) used for richer precondition checking.
Implementations§
Source§impl WorldState
impl WorldState
pub fn new() -> Self
pub fn set_bool(&mut self, key: &str, value: bool)
pub fn get_bool(&self, key: &str) -> bool
pub fn has_bool(&self, key: &str) -> bool
pub fn set_float(&mut self, key: &str, value: f32)
pub fn get_float(&self, key: &str) -> f32
pub fn has_float(&self, key: &str) -> bool
Sourcepub fn satisfies(&self, goal: &WorldState) -> bool
pub fn satisfies(&self, goal: &WorldState) -> bool
Does self satisfy every condition in goal?
Bool conditions must match exactly.
Float conditions in goal are treated as lower bounds — i.e.
self.float >= goal.float.
Sourcepub fn distance_to(&self, goal: &WorldState) -> usize
pub fn distance_to(&self, goal: &WorldState) -> usize
Number of unsatisfied conditions from goal. Used as A* heuristic.
Sourcepub fn apply(&self, effects: &ActionEffects) -> WorldState
pub fn apply(&self, effects: &ActionEffects) -> WorldState
Apply an action’s effects to produce the successor state.
Sourcepub fn merge_from(&mut self, other: &WorldState)
pub fn merge_from(&mut self, other: &WorldState)
Merge another state into self, overwriting on conflict.
Trait Implementations§
Source§impl Clone for WorldState
impl Clone for WorldState
Source§fn clone(&self) -> WorldState
fn clone(&self) -> WorldState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorldState
impl Debug for WorldState
Source§impl Default for WorldState
impl Default for WorldState
Source§fn default() -> WorldState
fn default() -> WorldState
Returns the “default value” for a type. Read more
Source§impl PartialEq for WorldState
impl PartialEq for WorldState
impl StructuralPartialEq for WorldState
Auto Trait Implementations§
impl Freeze for WorldState
impl RefUnwindSafe for WorldState
impl Send for WorldState
impl Sync for WorldState
impl Unpin for WorldState
impl UnsafeUnpin for WorldState
impl UnwindSafe for WorldState
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.