use beet_core::prelude::*;
use bevy::ecs::component::Mutable;
use std::fmt::Debug;
use std::hash::Hash;
#[derive(Deref)]
pub struct Readonly<T>(T);
impl<T> Readonly<T> {
pub fn new(value: T) -> Self { Self(value) }
}
pub trait Environment: 'static + Send + Sync + Clone {
type State: StateSpace;
type Action: ActionSpace;
fn step(
&mut self,
state: &Self::State,
action: &Self::Action,
) -> StepOutcome<Self::State>;
}
#[derive(Clone)]
pub struct StepOutcome<State> {
pub state: State,
pub reward: f32,
pub done: bool,
}
pub trait DiscreteSpace:
'static
+ Send
+ Sync
+ Debug
+ Hash
+ Clone
+ PartialEq
+ Eq
+ Component<Mutability = Mutable>
+ TypePath
{
}
impl<
T: 'static
+ Send
+ Sync
+ Debug
+ Hash
+ Clone
+ PartialEq
+ Eq
+ Component<Mutability = Mutable>
+ TypePath,
> DiscreteSpace for T
{
}
pub trait StateSpace: DiscreteSpace {}
impl<T: DiscreteSpace> StateSpace for T {}
pub trait ActionSpace: DiscreteSpace + Default {
fn sample(rng: &mut impl Rng) -> Self;
}