1#ifndef TOY_TEXT_BASE_ENV_H
2#define TOY_TEXT_BASE_ENV_H
4#include "bitrl/bitrl_config.h"
8#include "bitrl/extern/nlohmann/json/json.hpp"
14#include <unordered_map>
23namespace envs::gymnasium
31template <
typename TimeStepType, u
int_t state_end, u
int_t action_end>
33 :
public GymnasiumEnvBase<TimeStepType, ScalarDiscreteEnv<state_end, action_end, 0, 0>>
71 typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>>
dynamics_t;
112template <
typename TimeStepType, u
int_t state_end, u
int_t action_end>
119template <
typename TimeStepType, u
int_t state_end, u
int_t action_end>
126template <
typename TimeStepType, u
int_t state_end, u
int_t action_end>
132 assert(this->is_created() &&
"Environment has not been created");
135 auto response = this->get_api_server().dynamics(this->env_name(), this->idx(), sidx, aidx);
136 return build_dynamics_from_response_(response);
139template <
typename TimeStepType, u
int_t state_end, u
int_t action_end>
142 const nlohmann::json &response)
const
144 auto dynamics = response[
"dynamics"];
Base class for all Gymnasium environment wrappers.
Definition gymnasium_env_base.h:41
ToyTextEnvBase class. Base class for toy environments from Gymnasium. These environments have a discr...
Definition toy_text_base.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 toy_text_base.h:46
virtual ~ToyTextEnvBase()=default
~FrozenLake. Destructor.
std::vector< std::tuple< real_t, uint_t, real_t, bool > > dynamics_t
dynamics_t
Definition toy_text_base.h:71
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition toy_text_base.h:61
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition toy_text_base.h:56
base_type::state_type state_type
The type of the state.
Definition toy_text_base.h:66
ToyTextEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Constructor.
Definition toy_text_base.h:113
virtual dynamics_t build_dynamics_from_response_(const nlohmann::json &response) const
build the dynamics from response
Definition toy_text_base.h:141
GymnasiumEnvBase< TimeStepType, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >::base_type base_type
The base_type.
Definition toy_text_base.h:40
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition toy_text_base.h:51
uint_t n_states() const noexcept
Number of states.
Definition toy_text_base.h:93
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition toy_text_base.h:88
ToyTextEnvBase(const ToyTextEnvBase &other)
Copy constructor.
Definition toy_text_base.h:120
dynamics_t p(uint_t sidx, uint_t aidx) const
P.
Definition toy_text_base.h:128
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
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
Definition env_types.h:13