use rlevo_core::base::Observation;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BipedalWalkerObservation {
pub values: [f32; 24],
}
impl BipedalWalkerObservation {
pub fn new(values: [f32; 24]) -> Self {
Self { values }
}
pub fn is_finite(&self) -> bool {
self.values.iter().all(|v| v.is_finite())
}
}
impl Default for BipedalWalkerObservation {
fn default() -> Self {
Self { values: [0.0; 24] }
}
}
impl Observation<1> for BipedalWalkerObservation {
fn shape() -> [usize; 1] {
[24]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_shape() {
assert_eq!(BipedalWalkerObservation::shape(), [24]);
}
#[test]
fn test_default_is_finite() {
assert!(BipedalWalkerObservation::default().is_finite());
}
}