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§
Sourcetype Info: Info
type Info: Info
Information in the self::Step object.
Required Methods§
Sourcefn build(config: &Self::Config, seed: i64) -> Result<Self>where
Self: Sized,
fn build(config: &Self::Config, seed: i64) -> Result<Self>where
Self: Sized,
Builds an environment with a given random seed.
Sourcefn step(&mut self, a: &Self::Act) -> (Step<Self>, Record)where
Self: Sized,
fn step(&mut self, a: &Self::Act) -> (Step<Self>, Record)where
Self: Sized,
Performes an environment step.
Sourcefn reset(&mut self, is_done: Option<&Vec<i8>>) -> Result<Self::Obs>
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.
Sourcefn step_with_reset(&mut self, a: &Self::Act) -> (Step<Self>, Record)where
Self: Sized,
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.
Sourcefn reset_with_index(&mut self, ix: usize) -> Result<Self::Obs>
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.