bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
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/bitrl_config.h"
5#include "bitrl/bitrl_types.h"
9#include "bitrl/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
59 typedef typename base_type::state_space_type state_space_type;
60
64 typedef typename base_type::action_space_type action_space_type;
65
69 typedef typename base_type::action_type action_type;
70
74 typedef typename base_type::state_type state_type;
75
83
87 MountainCar(const MountainCar &other);
88
92 ~MountainCar() override = default;
93
97 virtual void
98 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
99 const std::unordered_map<std::string, std::any> &reset_options) override final;
100
104 virtual time_step_type step(const action_type &action) override final;
105
109 uint_t n_actions() const noexcept { return action_space_type::size; }
110
111 protected:
115 virtual time_step_type
116 create_time_step_from_response_(const nlohmann::json &response) const override final;
117};
118} // namespace envs::gymnasium
119} // namespace bitrl
120#endif // MOUNTAIN_CAR_H
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Access the configuration options provided to make().
Definition env_base.h:104
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:41
std::string version() const noexcept
Get the environment version set during make().
Definition env_base.h:142
Base class for all Gymnasium environment wrappers.
Definition gymnasium_env_base.h:41
The MountainCar class.
Definition mountain_car_env.h:28
static const std::string name
name
Definition mountain_car_env.h:34
virtual time_step_type step(const action_type &action) override final
step
Definition mountain_car_env.cpp:70
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
Definition mountain_car_env.cpp:25
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
Definition mountain_car_env.cpp:52
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() override=default
~MountainCar. Destructor.
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition mountain_car_env.h:109
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
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
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
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:29
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23
std::size_t uint_t
uint_t
Definition bitrl_types.h:43