Struct gym_rs::envs::classical_control::mountain_car::MountainCarEnv
source · pub struct MountainCarEnv {
pub min_position: O64,
pub max_position: O64,
pub max_speed: O64,
pub goal_position: O64,
pub goal_velocity: O64,
pub force: O64,
pub gravity: O64,
pub render_mode: RenderMode,
pub action_space: Discrete,
pub observation_space: BoxR<MountainCarObservation>,
pub state: MountainCarObservation,
pub metadata: Metadata<Self>,
/* private fields */
}
Expand description
An implementation of the classical reinforcment learning environment, mountain car.
The problem involves moving a stochastically placed car on the bottom of a sinusoidal valley
to the top of the hill by applying left and right forces to the car. The car is given a reward
of -1
for each step taken by the agent, until a terminal step is reached.
An episode ends when one of the following conditions occur: 1. Termination: The car reaches the goal position. 2. Truncation: The episode exceeds 200 steps.
Fields§
§min_position: O64
The minimum position the car can be spawned at.
max_position: O64
The maximum position the cart can be spawned at.
max_speed: O64
The max speed the car can reach.
goal_position: O64
The position on the map, where when passed, an episode can be considered terminated.
goal_velocity: O64
The velocity at which an episode can be considered terminated.
force: O64
The force of the cart.
gravity: O64
The gravity constant applied to the environment.
render_mode: RenderMode
The type of renders produced.
action_space: Discrete
The set of actions which can be taken.
observation_space: BoxR<MountainCarObservation>
The range of values that can be observed.
state: MountainCarObservation
The state of the environment.
metadata: Metadata<Self>
Additional information provided by the environment.
Implementations§
source§impl MountainCarEnv
impl MountainCarEnv
sourcepub fn new(render_mode: RenderMode) -> Self
pub fn new(render_mode: RenderMode) -> Self
Generates an instance of the mountain car environment using the defaults provided in the paper.
Examples found in repository?
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let mut mc = MountainCarEnv::new(RenderMode::Human);
let _state = mc.reset(None, false, None);
let mut end: bool = false;
let mut episode_length = 0;
while !end {
if episode_length > 200 {
break;
}
let action = (&mut thread_rng()).gen_range(0..3);
let ActionReward { done, .. } = mc.step(action);
episode_length += 1;
end = done;
println!("episode_length: {}", episode_length);
}
mc.close();
for _ in 0..200 {
let action = (&mut thread_rng()).gen_range(0..3);
mc.step(action);
episode_length += 1;
println!("episode_length: {}", episode_length);
}
}
Trait Implementations§
source§impl Clone for MountainCarEnv
impl Clone for MountainCarEnv
source§impl Debug for MountainCarEnv
impl Debug for MountainCarEnv
source§impl Env for MountainCarEnv
impl Env for MountainCarEnv
§type Observation = MountainCarObservation
type Observation = MountainCarObservation
source§fn step(
&mut self,
action: Self::Action
) -> ActionReward<<Self as Env>::Observation, Self::Info>
fn step( &mut self, action: Self::Action ) -> ActionReward<<Self as Env>::Observation, Self::Info>
source§fn render(&mut self, mode: RenderMode) -> Renders
fn render(&mut self, mode: RenderMode) -> Renders
source§impl EnvProperties for MountainCarEnvwhere
Self: Sized,
impl EnvProperties for MountainCarEnvwhere Self: Sized,
§type ActionSpace = Discrete
type ActionSpace = Discrete
§type ObservationSpace = BoxR<<MountainCarEnv as Env>::Observation>
type ObservationSpace = BoxR<<MountainCarEnv as Env>::Observation>
source§fn metadata(&self) -> &Metadata<Self>
fn metadata(&self) -> &Metadata<Self>
source§fn rand_random(&self) -> &Pcg64
fn rand_random(&self) -> &Pcg64
source§fn action_space(&self) -> &Self::ActionSpace
fn action_space(&self) -> &Self::ActionSpace
source§fn observation_space(&self) -> &Self::ObservationSpace
fn observation_space(&self) -> &Self::ObservationSpace
source§fn render_mode(&self) -> &RenderMode
fn render_mode(&self) -> &RenderMode
source§fn reward_range(&self) -> &RewardRange
fn reward_range(&self) -> &RewardRange
Auto Trait Implementations§
impl RefUnwindSafe for MountainCarEnv
impl !Send for MountainCarEnv
impl !Sync for MountainCarEnv
impl Unpin for MountainCarEnv
impl UnwindSafe for MountainCarEnv
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.