Trait Env

Source
pub trait Env {
    type Config: Clone;
    type Obs: Obs;
    type Act: Act;
    type Info: Info;

    // Required methods
    fn build(config: &Self::Config, seed: i64) -> Result<Self>
       where Self: Sized;
    fn step(&mut self, a: &Self::Act) -> (Step<Self>, Record)
       where Self: Sized;
    fn reset(&mut self, is_done: Option<&Vec<i8>>) -> Result<Self::Obs>;
    fn step_with_reset(&mut self, a: &Self::Act) -> (Step<Self>, Record)
       where Self: Sized;
    fn reset_with_index(&mut self, ix: usize) -> Result<Self::Obs>;
}
Expand description

Represents an environment, typically an MDP.

Required Associated Types§

Source

type Config: Clone

Configurations.

Source

type Obs: Obs

Observation of the environment.

Source

type Act: Act

Action of the environment.

Source

type Info: Info

Information in the self::Step object.

Required Methods§

Source

fn build(config: &Self::Config, seed: i64) -> Result<Self>
where Self: Sized,

Builds an environment with a given random seed.

Source

fn step(&mut self, a: &Self::Act) -> (Step<Self>, Record)
where Self: Sized,

Performes an environment step.

Source

fn reset(&mut self, is_done: Option<&Vec<i8>>) -> Result<Self::Obs>

Resets the environment if is_done[0] == 1. or is_done.is_none().

Old versions of the library supports vectorized environments and is_done was used to reset a part of the vectorized environments. Currenly, vecorized environment is not supported and is_done.len() is expected to be 1.

Source

fn step_with_reset(&mut self, a: &Self::Act) -> (Step<Self>, Record)
where Self: Sized,

Performes an environment step and reset the environment if an episode ends.

Source

fn reset_with_index(&mut self, ix: usize) -> Result<Self::Obs>

Resets the environment with a given index.

The index is used in an arbitrary way. For example, it can be used as a random seed, which is useful when evaluation of a trained agent. Actually, this method is called in Trainer for evaluation. This method does not support vectorized environments.

Implementors§