bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
frozen_lake_env.h
Go to the documentation of this file.
1#ifndef FROZEN_LAKE_H
2#define FROZEN_LAKE_H
3
58
63#include "bitsim/extern/nlohmann/json/json.hpp"
64
65#include <any>
66#include <string>
67#include <tuple>
68#include <unordered_map>
69#include <vector>
70
71namespace bitrl
72{
73namespace envs::gymnasium
74{
75
80template <uint_t side_size> struct frozenlake_state_size;
81
85template <> struct frozenlake_state_size<4>
86{
87 static constexpr uint_t size = 16;
88};
89
93template <> struct frozenlake_state_size<8>
94{
95 static constexpr uint_t size = 64;
96};
97
101template <uint_t side_size>
102class FrozenLake final
103 : public ToyTextEnvBase<TimeStep<uint_t>, frozenlake_state_size<side_size>::size, 4>
104{
105 public:
109 static const std::string name;
110
114 static const std::string URI;
115
119 typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>> dynamics_t;
120
126
132
137
142
147
152
157
161 FrozenLake(const FrozenLake &other);
162
166 ~FrozenLake() override = default;
167
172 virtual void
173 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
174 const std::unordered_map<std::string, std::any> &reset_options) override final;
175
179 virtual time_step_type step(const action_type &action) override final;
180
185 std::string map_type() const noexcept { return side_size == 4 ? "4x4" : "8x8"; }
186
191 bool is_slippery() const;
192
193 protected:
197 virtual time_step_type
198 create_time_step_from_response_(const nlohmann::json &response) const override final;
199};
200
201} // namespace envs::gymnasium
202} // namespace bitrl
203#endif // FROZEN_LAKE_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
static const std::string URI
The URI for accessing the environment.
Definition frozen_lake_env.h:114
static const std::string name
name
Definition frozen_lake_env.h:109
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition frozen_lake_env.h:131
~FrozenLake() override=default
~FrozenLake. Destructor.
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. Builds the environment. Optionally we can choose if the environment will be slippery
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition frozen_lake_env.h:136
ToyTextEnvBase< TimeStep< uint_t >, frozenlake_state_size< side_size >::size, 4 >::base_type base_type
The base type.
Definition frozen_lake_env.h:125
std::vector< std::tuple< real_t, uint_t, real_t, bool > > dynamics_t
dynamics_t
Definition frozen_lake_env.h:119
bool is_slippery() const
is_slipery
FrozenLake(const FrozenLake &other)
copy constructor
FrozenLake(network::RESTRLEnvClient &api_server)
Constructor.
virtual time_step_type step(const action_type &action) override final
Step in the environment following the given action.
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition frozen_lake_env.h:141
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition frozen_lake_env.h:146
base_type::state_type state_type
The type of the action to be undertaken in the environment.
Definition frozen_lake_env.h:151
std::string map_type() const noexcept
map_type
Definition frozen_lake_env.h:185
ToyTextEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Definition toy_text_base.h:113
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
static constexpr uint_t size
Definition frozen_lake_env.h:87
static constexpr uint_t size
Definition frozen_lake_env.h:95
Definition frozen_lake_env.h:80