pub trait StepProcessor<E: Env> {
type Config: Clone;
type Output;
// Required methods
fn build(config: &Self::Config) -> Self;
fn reset(&mut self, init_obs: E::Obs);
fn process(&mut self, step: Step<E>) -> Self::Output;
}
Expand description
Processes environment steps and produces items for a replay buffer.
This trait defines the interface for converting Step
objects into items
that can be stored in a replay buffer. It is used by the Trainer
to
transform environment interactions into training samples.
§Type Parameters
E
- The environment type
§Associated Types
Config
- Configuration parameters for the processorOutput
- The type of items produced by the processor
§Examples
struct SimpleProcessor;
impl<E: Env> StepProcessor<E> for SimpleProcessor {
type Config = ();
type Output = (E::Obs, E::Act, E::Obs, f32);
fn build(_: &Self::Config) -> Self {
Self
}
fn reset(&mut self, _: E::Obs) {}
fn process(&mut self, step: Step<E>) -> Self::Output {
(step.init_obs.unwrap(), step.act, step.obs, step.reward[0])
}
}
Required Associated Types§
Required Methods§
Sourcefn reset(&mut self, init_obs: E::Obs)
fn reset(&mut self, init_obs: E::Obs)
Resets the processor with a new initial observation.
This method is called at the start of each episode to initialize the processor with the first observation.
§Arguments
init_obs
- The initial observation of the episode
Sourcefn process(&mut self, step: Step<E>) -> Self::Output
fn process(&mut self, step: Step<E>) -> Self::Output
Processes a step and produces an item for the replay buffer.
This method transforms a Step
object into an item that can be
stored in a replay buffer. The transformation typically involves
creating a transition tuple of the form (o_t, a_t, o_t+1, r_t)
.
§Arguments
step
- The step to process
§Returns
An item ready to be stored in a replay buffer
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.