pub trait Environment<const ACTIONS: usize> {
// Required methods
fn valid_actions(
&self,
state: usize,
actions: &mut [usize; ACTIONS],
) -> usize;
fn random_int(&mut self, min: usize, max: usize) -> usize;
}Expand description
The world a QLearner acts in: tinymind (C++)’s environment (the
getValidActionsForState an example environment defines, and its random
number policy’s randInt).
Required Methods§
Sourcefn valid_actions(&self, state: usize, actions: &mut [usize; ACTIONS]) -> usize
fn valid_actions(&self, state: usize, actions: &mut [usize; ACTIONS]) -> usize
Writes the actions valid in state to the front of actions and
returns how many there are (0 if none; values above ACTIONS count as
ACTIONS).
Sourcefn random_int(&mut self, min: usize, max: usize) -> usize
fn random_int(&mut self, min: usize, max: usize) -> usize
A uniformly distributed integer in min..=max, for exploration. The
learner asks for random_int(0, 99) to decide whether to explore and
random_int(0, n - 1) to pick one of n valid actions.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".