Skip to main content

UtilityAiBrain

Struct UtilityAiBrain 

Source
pub struct UtilityAiBrain { /* private fields */ }
Expand description

Multi-consideration Utility AI selector with response curves and hysteresis anti-oscillation.

Implementations§

Source§

impl UtilityAiBrain

Multi-consideration scoring and hysteresis action selection for UtilityAiBrain.

Source

pub fn new(inertia_bonus: f32, min_dwell_time: f32) -> Self

Creates a new UtilityAiBrain with configurable inertia bonus and minimum dwell duration.

§Arguments
  • f32 - Additive inertia bonus applied to the active action.
  • f32 - Minimum dwell seconds before switching away from a viable active action.
§Returns
  • Self - Empty utility AI brain.
Source

pub fn add_action(&mut self, action: UtilityActionDef)

Registers a candidate UtilityActionDef.

§Arguments
  • UtilityActionDef - Action definition with base weight and response-curve considerations.
Source

pub fn active_action(&self) -> Option<u32>

Returns the currently selected action identifier, if any.

§Returns
  • Option<u32> - Active action identifier.
Source

pub fn evaluate<F>(&mut self, dt: f32, sample_input: F) -> Option<u32>
where F: FnMut(u32) -> f32,

Scores every registered action and selects the highest-utility action with hysteresis protection.

§Arguments
  • f32 - Elapsed time step in seconds.
  • F - Input sampler returning the raw scalar value for each input_id.
§Returns
  • Option<u32> - Winning action identifier.
Source§

impl UtilityAiBrain

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_actions(&self) -> &Vec<UtilityActionDef>

Source

pub fn get_mut_actions(&mut self) -> &mut Vec<UtilityActionDef>

Source

pub fn set_actions(&mut self, val: Vec<UtilityActionDef>) -> &mut Self

Source

pub fn get_inertia_bonus(&self) -> f32

Source

pub fn get_mut_inertia_bonus(&mut self) -> &mut f32

Source

pub fn set_inertia_bonus(&mut self, val: f32) -> &mut Self

Source

pub fn get_min_dwell_time(&self) -> f32

Source

pub fn get_mut_min_dwell_time(&mut self) -> &mut f32

Source

pub fn set_min_dwell_time(&mut self, val: f32) -> &mut Self

Source

pub fn get_current_action(&self) -> u32

Source

pub fn get_mut_current_action(&mut self) -> &mut u32

Source

pub fn set_current_action(&mut self, val: u32) -> &mut Self

Source

pub fn get_has_active(&self) -> bool

Source

pub fn get_mut_has_active(&mut self) -> &mut bool

Source

pub fn set_has_active(&mut self, val: bool) -> &mut Self

Source

pub fn get_dwell_elapsed(&self) -> f32

Source

pub fn get_mut_dwell_elapsed(&mut self) -> &mut f32

Source

pub fn set_dwell_elapsed(&mut self, val: f32) -> &mut Self

Source

pub fn get_last_scores(&self) -> &Vec<(u32, f32)>

Source

pub fn get_mut_last_scores(&mut self) -> &mut Vec<(u32, f32)>

Source

pub fn set_last_scores(&mut self, val: Vec<(u32, f32)>) -> &mut Self

Trait Implementations§

Source§

impl Clone for UtilityAiBrain

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 UtilityAiBrain

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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