Files
rustytorch/crates/training/rtx-rl/src/environment.rs
T
2026-03-04 00:08:42 +00:00

30 lines
867 B
Rust

use std::collections::HashMap;
/// A step in the environment, containing the new state, reward, and termination info
#[derive(Debug, Clone)]
pub struct Step<State, Reward> {
pub state: State,
pub reward: Reward,
pub done: bool,
pub info: HashMap<String, String>,
}
/// Environment trait for reinforcement learning
pub trait Environment {
type State: Clone;
type Action: Clone;
type Reward: Clone;
/// Reset the environment to initial state
fn reset(&mut self) -> Self::State;
/// Take one step in the environment
fn step(&mut self, action: &Self::Action) -> Step<Self::State, Self::Reward>;
/// Get the action space bounds (low, high)
fn action_space(&self) -> (Self::Action, Self::Action);
/// Get the observation space bounds (low, high)
fn observation_space(&self) -> (Self::State, Self::State);
}