bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
mountain_car_env.h
Go to the documentation of this file.
1#ifndef MOUNTAIN_CAR_H
2#define MOUNTAIN_CAR_H
3
4#include "bitrl/base/bitrl_config.h"
10#include "bitsim/extern/nlohmann/json/json.hpp"
11
12#include <any>
13#include <string>
14#include <unordered_map>
15#include <vector>
16
17namespace bitrl
18{
19namespace envs::gymnasium
20{
21
25class MountainCar final
26 : public GymnasiumEnvBase<TimeStep<std::vector<real_t>>,
27 ContinuousVectorStateDiscreteActionEnv<3, 2, 0, real_t>>
28{
29
30 public:
34 static const std::string name;
35
39 static const std::string URI;
40
46 2, // end of action space
47 0, // start of action space
48 real_t> // type of state
55
60
65
70
75
81
85 MountainCar(const MountainCar &other);
86
90 ~MountainCar() override = default;
91
95 virtual void
96 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
97 const std::unordered_map<std::string, std::any> &reset_options) override final;
98
102 virtual time_step_type step(const action_type &action) override final;
103
107 uint_t n_actions() const noexcept { return action_space_type::size; }
108
109 protected:
113 virtual time_step_type
114 create_time_step_from_response_(const nlohmann::json &response) const override final;
115};
116} // namespace envs::gymnasium
117} // namespace bitrl
118#endif // MOUNTAIN_CAR_H
SpaceType::state_space state_space_type
Type describing the environment state space.
Definition env_base.h:45
SpaceType::state_type state_type
Type describing an individual state.
Definition env_base.h:48
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Definition env_base.h:105
SpaceType::action_space action_space_type
Type describing the environment action space.
Definition env_base.h:51
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:42
SpaceType::action_type action_type
Type representing an individual action.
Definition env_base.h:54
GymnasiumEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Definition gymnasium_env_base.h:139
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
static const std::string name
name
Definition mountain_car_env.h:34
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition mountain_car_env.h:54
MountainCar(network::RESTRLEnvClient &api_server)
MountainCar. Constructor. Creates an environment.
~MountainCar() override=default
~MountainCar. Destructor.
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition mountain_car_env.h:107
static const std::string URI
The URI for accessing the environment.
Definition mountain_car_env.h:39
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition mountain_car_env.h:69
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition mountain_car_env.h:64
virtual time_step_type step(const action_type &action) override final
step
GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 3, 2, 0, real_t > >::base_type base_type
Base class type.
Definition mountain_car_env.h:49
MountainCar(const MountainCar &other)
copy ctor
base_type::state_type state_type
The type of the state.
Definition mountain_car_env.h:74
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition mountain_car_env.h:59
virtual void make(const std::string &version, const std::unordered_map< std::string, std::any > &options, const std::unordered_map< std::string, std::any > &reset_options) override final
make. Build the environment
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
Definition lunar_lander_env.h:18
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20