[−][src]Struct max_tree::Ai
AI setup.
Provides a common setup for different search algorithms. The search algorithm constructs a maximum tree, which can be used to find the optimal course of action.
The T
parameter is the type of node data.
This is used to store delta changes for undo operations.
Also stores data that tracks internal state of the AI agent,
when the AI agent is not interacting with the context (pure search).
Node data is stored separately from the context, making it easy
to analyse after constructing the maximum tree.
The A
parameter is the type of action.
It describes the choices the AI agent can make in a specific context.
An action modifies the context and must be undone when rolling back changes.
The C
parameter is the type of context (environment).
This stores the data that is necessary to calculate utility.
The context is modified by actions when exploring,
but these changes are undone when rolling back changes.
Fields
utility: fn(_: &T, _: &C) -> f64
Calculates utility from data and context.
actions: fn(_: &T, _: &C) -> Vec<A>
Returns a list of possible actions.
execute: fn(_: &T, a: &A, _: &mut C) -> Result<T, ()>
Executes an action, returning new node data.
undo: fn(_: &T, _: &mut C)
Undoes change made to context.
The data required to rollback delta changes must be stored in node data.
settings: AiSettings
Stores AI settings.
analysis: AiAnalysis
Stores analysis.
Implementations
impl<T, A, C> Ai<T, A, C>
[src]
pub fn node_size(&self) -> usize
[src]
Computes the size of nodes in bytes.
pub fn utility_with_settings(&self, data: &T, depth: usize, ctx: &C) -> f64
[src]
Calculates utility with extra terms computed from settings.
pub fn update<'a>(&mut self, node: &'a Node<T, A>, ctx: &mut C) -> Option<usize>
[src]
Updates context by tracing the optimal path.
pub fn sub_breadth(&mut self, root: &mut Node<T, A>, depth: usize, ctx: &mut C) where
A: Clone,
[src]
A: Clone,
A sub-procedure constructing maximum tree of all available actions.
Uses by other search algorithms.
pub fn memory_exceeded(&self) -> bool
[src]
Returns true
when estimated memory usage is exceeded, false
otherwise.
Returns false
when analysis is deactivated.
pub fn greedy(&mut self, root: &mut Node<T, A>, depth: usize, ctx: &mut C) where
A: Clone,
[src]
A: Clone,
Only picks choices that increases utility.
In order to find global maximum, it requires utility gradient to be convex.
pub fn full(&mut self, root: &mut Node<T, A>, depth: usize, ctx: &mut C) where
A: Clone,
[src]
A: Clone,
Performs a full construction of the entire maximum tree.
Auto Trait Implementations
impl<T, A, C> RefUnwindSafe for Ai<T, A, C>
impl<T, A, C> Send for Ai<T, A, C>
impl<T, A, C> Sync for Ai<T, A, C>
impl<T, A, C> Unpin for Ai<T, A, C>
impl<T, A, C> UnwindSafe for Ai<T, A, C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,