pub struct Agent { /* private fields */ }Expand description
A complete MC-AIXI agent.
The agent maintains an internal world model and a planning tree. It can be used for both live interaction with an environment and for “imaginary” simulations during planning.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(config: AgentConfig) -> Self
pub fn new(config: AgentConfig) -> Self
Creates a new Agent with the given configuration.
Sourcepub fn get_planned_action(
&mut self,
prev_obs_stream: &[PerceptVal],
prev_rew: Reward,
prev_act: Action,
) -> Action
pub fn get_planned_action( &mut self, prev_obs_stream: &[PerceptVal], prev_rew: Reward, prev_act: Action, ) -> Action
Primary interface for decision making.
Uses MCTS to find the action that maximizes expected future reward.
Sourcepub fn model_update_percept(&mut self, observation: PerceptVal, reward: Reward)
pub fn model_update_percept(&mut self, observation: PerceptVal, reward: Reward)
Updates the world model with real-world percepts.
Sourcepub fn model_update_percept_stream(
&mut self,
observations: &[PerceptVal],
reward: Reward,
)
pub fn model_update_percept_stream( &mut self, observations: &[PerceptVal], reward: Reward, )
Updates the world model with an observation stream and a terminal reward.
Sourcepub fn observation_repr_from_stream(
&self,
observations: &[PerceptVal],
) -> Vec<PerceptVal> ⓘ
pub fn observation_repr_from_stream( &self, observations: &[PerceptVal], ) -> Vec<PerceptVal> ⓘ
Computes the observation key used for search-tree branching.
Sourcepub fn model_update_action_external(&mut self, action: Action)
pub fn model_update_action_external(&mut self, action: Action)
Explicitly updates the world model with an action.
Trait Implementations§
Source§impl AgentSimulator for Agent
impl AgentSimulator for Agent
Source§fn get_num_actions(&self) -> usize
fn get_num_actions(&self) -> usize
Returns the number of possible actions the agent can perform.
Source§fn get_num_observation_bits(&self) -> usize
fn get_num_observation_bits(&self) -> usize
Returns the bit-width used to encode observations.
Source§fn observation_stream_len(&self) -> usize
fn observation_stream_len(&self) -> usize
Returns the number of observation symbols per action.
Source§fn observation_key_mode(&self) -> ObservationKeyMode
fn observation_key_mode(&self) -> ObservationKeyMode
Returns the observation key mode for search-tree branching.
Source§fn get_num_reward_bits(&self) -> usize
fn get_num_reward_bits(&self) -> usize
Returns the bit-width used to encode rewards.
Source§fn max_reward(&self) -> Reward
fn max_reward(&self) -> Reward
Returns the maximum possible reward value.
Source§fn min_reward(&self) -> Reward
fn min_reward(&self) -> Reward
Returns the minimum possible reward value.
Source§fn reward_offset(&self) -> i64
fn reward_offset(&self) -> i64
Returns the reward offset used to ensure encoded rewards are non-negative. Read more
Source§fn get_explore_exploit_ratio(&self) -> f64
fn get_explore_exploit_ratio(&self) -> f64
Returns the exploration-exploitation constant (often denoted as C).
Source§fn discount_gamma(&self) -> f64
fn discount_gamma(&self) -> f64
Returns the discount factor for future rewards.
Source§fn model_update_action(&mut self, action: Action)
fn model_update_action(&mut self, action: Action)
Updates the internal model state with a simulated action.
Source§fn gen_percept_and_update(&mut self, bits: usize) -> u64
fn gen_percept_and_update(&mut self, bits: usize) -> u64
Generates a simulated percept and updates the model state.
Source§fn gen_percepts_and_update(&mut self) -> (Vec<PerceptVal>, Reward)
fn gen_percepts_and_update(&mut self) -> (Vec<PerceptVal>, Reward)
Helper to generate a percept stream, update the model, and return a search key + reward.
Source§fn model_revert(&mut self, steps: usize)
fn model_revert(&mut self, steps: usize)
Reverts the model state to a previous point in the simulation.
Source§fn boxed_clone_with_seed(&self, seed: u64) -> Box<dyn AgentSimulator>
fn boxed_clone_with_seed(&self, seed: u64) -> Box<dyn AgentSimulator>
Creates a boxed clone of this simulator, re-seeding any RNG state.
Source§fn observation_repr_from_stream(
&self,
observations: &[PerceptVal],
) -> Vec<PerceptVal> ⓘ
fn observation_repr_from_stream( &self, observations: &[PerceptVal], ) -> Vec<PerceptVal> ⓘ
Returns the observation representation used for tree branching.
Source§fn boxed_clone(&self) -> Box<dyn AgentSimulator>
fn boxed_clone(&self) -> Box<dyn AgentSimulator>
Creates a boxed clone of this simulator for parallel search.
Auto Trait Implementations§
impl Freeze for Agent
impl !RefUnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl !UnwindSafe for Agent
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.