pub trait Obs: Clone + Debug {
// Required method
fn len(&self) -> usize;
}
Expand description
A trait representing observations from an environment.
This trait defines the interface for observations in reinforcement learning. Observations represent the state of the environment as perceived by the agent.
§Requirements
Implementations must:
- Be cloneable for efficient copying
- Support debug formatting for logging and debugging
- Provide a method to determine the number of observations
§Note
While the interface supports vectorized environments through the len
method,
the current implementation only supports single environments. Therefore,
len()
is expected to return 1 in all cases.
§Examples
ⓘ
#[derive(Clone, Debug)]
struct SimpleObservation {
position: f32,
velocity: f32,
}
impl Obs for SimpleObservation {
fn len(&self) -> usize {
1 // Single observation
}
}
Required Methods§
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.