pub struct Action {
pub name: String,
pub cost: f32,
pub preconditions: Preconditions,
pub effects: ActionEffects,
pub duration_secs: f32,
pub interrupt_priority: u32,
pub disabled: bool,
pub tags: Vec<String>,
}Expand description
A GOAP action that an agent can execute.
Each action has:
- A cost (lower = preferred by the planner).
- A set of preconditions that must hold before it can run.
- A set of effects that it applies to the world state.
- An optional duration in simulated seconds.
- An optional interruption priority (higher = harder to interrupt).
Fields§
§name: StringUnique name identifying this action.
cost: f32Base cost (used by A* to prefer cheaper plans).
preconditions: PreconditionsPreconditions that must hold.
effects: ActionEffectsEffects applied to world state on completion.
duration_secs: f32Estimated duration in seconds (used by the executor).
interrupt_priority: u32Priority when being interrupted by a higher-priority action.
disabled: boolIf true, the planner will not use this action (temporarily disabled).
User data tag for categorizing actions.
Implementations§
Source§impl Action
impl Action
pub fn new(name: &str, cost: f32) -> Self
pub fn require_bool(self, key: &str, value: bool) -> Self
pub fn require_float_gte(self, key: &str, min: f32) -> Self
pub fn require_float_lte(self, key: &str, max: f32) -> Self
pub fn require_float_gt(self, key: &str, val: f32) -> Self
pub fn require_float_lt(self, key: &str, val: f32) -> Self
pub fn effect_bool(self, key: &str, value: bool) -> Self
pub fn effect_add_float(self, key: &str, delta: f32) -> Self
pub fn effect_set_float(self, key: &str, value: f32) -> Self
pub fn with_duration(self, secs: f32) -> Self
pub fn with_interrupt_priority(self, p: u32) -> Self
pub fn with_tag(self, tag: &str) -> Self
pub fn disabled(self) -> Self
pub fn is_applicable(&self, state: &WorldState) -> bool
Sourcepub fn apply_effects(&self, state: &WorldState) -> WorldState
pub fn apply_effects(&self, state: &WorldState) -> WorldState
Compute the successor state by applying this action’s effects.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Action
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnsafeUnpin for Action
impl UnwindSafe for Action
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.