Struct relearn::envs::MemoryGame
source · [−]Expand description
Memory Game Environment
The agent must remember the inital state and choose the corresponding action as the final action in an episode.
- The environment consists of
(NUM_ACTIONS + HISTORY_LEN)
states. - An episode starts in a state
[0, NUM_ACTIONS)
uniformly at random. - Step
i
in[0, HISTORY_LEN)
transitions to stateNUM_ACTIONS + i
with 0 reward regardless of the action. - On step
HISTORY_LEN
, the agent chooses one ofNUM_ACTIONS
actions and if the action index matches the index of the inital state then the agent earns+1
reward, otherwise it earns-1
reward. This step is terminal. - Every episode has length
HISTORY_LEN + 1
.
Fields
num_actions: usize
The number of actions.
history_len: usize
Length of remembered history required to solve the environment.
Implementations
Trait Implementations
sourceimpl Clone for MemoryGame
impl Clone for MemoryGame
sourcefn clone(&self) -> MemoryGame
fn clone(&self) -> MemoryGame
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MemoryGame
impl Debug for MemoryGame
sourceimpl Default for MemoryGame
impl Default for MemoryGame
sourceimpl<'de> Deserialize<'de> for MemoryGame
impl<'de> Deserialize<'de> for MemoryGame
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl EnvStructure for MemoryGame
impl EnvStructure for MemoryGame
type ObservationSpace = IndexSpace
type ActionSpace = IndexSpace
type FeedbackSpace = IntervalSpace<Reward>
sourcefn observation_space(&self) -> Self::ObservationSpace
fn observation_space(&self) -> Self::ObservationSpace
Space containing all possible observations. Read more
sourcefn action_space(&self) -> Self::ActionSpace
fn action_space(&self) -> Self::ActionSpace
The space of all possible actions. Read more
sourcefn feedback_space(&self) -> Self::FeedbackSpace
fn feedback_space(&self) -> Self::FeedbackSpace
The space of all possible feedback. Read more
sourcefn discount_factor(&self) -> f64
fn discount_factor(&self) -> f64
A discount factor applied to future feedback. Read more
sourceimpl Environment for MemoryGame
impl Environment for MemoryGame
type Observation = usize
type Observation = usize
Observation of the state provided to the agent.
sourcefn initial_state(&self, rng: &mut Prng) -> Self::State
fn initial_state(&self, rng: &mut Prng) -> Self::State
Sample a state for the start of a new episode. Read more
sourcefn observe(&self, state: &Self::State, _rng: &mut Prng) -> Self::Observation
fn observe(&self, state: &Self::State, _rng: &mut Prng) -> Self::Observation
Generate an observation for a given state.
sourcefn step(
&self,
state: Self::State,
action: &Self::Action,
_: &mut Prng,
_: &mut dyn StatsLogger
) -> (Successor<Self::State>, Self::Feedback)
fn step(
&self,
state: Self::State,
action: &Self::Action,
_: &mut Prng,
_: &mut dyn StatsLogger
) -> (Successor<Self::State>, Self::Feedback)
Perform a state transition in reponse to an action. Read more
sourcefn run<T, L>(self, actor: T, seed: SimSeed, logger: L) -> Steps<Self, T, Prng, L>ⓘNotable traits for Steps<E, T, R, L>impl<E, T, R, L> Iterator for Steps<E, T, R, L> where
E: Environment,
T: Actor<E::Observation, E::Action>,
R: BorrowMut<Prng>,
L: StatsLogger, type Item = PartialStep<E::Observation, E::Action, E::Feedback>;
where
T: Actor<Self::Observation, Self::Action>,
L: StatsLogger,
Self: Sized,
fn run<T, L>(self, actor: T, seed: SimSeed, logger: L) -> Steps<Self, T, Prng, L>ⓘNotable traits for Steps<E, T, R, L>impl<E, T, R, L> Iterator for Steps<E, T, R, L> where
E: Environment,
T: Actor<E::Observation, E::Action>,
R: BorrowMut<Prng>,
L: StatsLogger, type Item = PartialStep<E::Observation, E::Action, E::Feedback>;
where
T: Actor<Self::Observation, Self::Action>,
L: StatsLogger,
Self: Sized,
E: Environment,
T: Actor<E::Observation, E::Action>,
R: BorrowMut<Prng>,
L: StatsLogger, type Item = PartialStep<E::Observation, E::Action, E::Feedback>;
Run this environment with the given actor.
sourceimpl Hash for MemoryGame
impl Hash for MemoryGame
sourceimpl PartialEq<MemoryGame> for MemoryGame
impl PartialEq<MemoryGame> for MemoryGame
sourcefn eq(&self, other: &MemoryGame) -> bool
fn eq(&self, other: &MemoryGame) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MemoryGame) -> bool
fn ne(&self, other: &MemoryGame) -> bool
This method tests for !=
.
sourceimpl Serialize for MemoryGame
impl Serialize for MemoryGame
impl CloneBuild for MemoryGame
impl Copy for MemoryGame
impl Eq for MemoryGame
impl StructuralEq for MemoryGame
impl StructuralPartialEq for MemoryGame
Auto Trait Implementations
impl RefUnwindSafe for MemoryGame
impl Send for MemoryGame
impl Sync for MemoryGame
impl Unpin for MemoryGame
impl UnwindSafe for MemoryGame
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.