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