1#ifndef GYMNASIUM_ENV_BASE_H
2#define GYMNASIUM_ENV_BASE_H
8#include "bitrl/base/bitrl_config.h"
13#include "bitsim/extern/nlohmann/json/json.hpp"
18#include <unordered_map>
39template <
typename TimeStepType,
typename SpaceType>
138template <
typename TimeStepType,
typename SpaceType>
140 const std::string &name)
145template <
typename TimeStepType,
typename SpaceType>
152template <
typename TimeStepType,
typename SpaceType>
165template <
typename TimeStepType,
typename SpaceType>
169 return response[
"result"];
171template <
typename TimeStepType,
typename SpaceType>
175 return response[
"copies"];
178template <
typename TimeStepType,
typename SpaceType>
191template <
typename TimeStepType,
typename SpaceType>
199 assert(this->
is_created() &&
"Environment has not been created");
215template <
typename TimeStepType,
typename SpaceType>
SpaceType::state_space state_space_type
Type describing the environment state space.
Definition env_base.h:45
void invalidate_is_created_flag_() noexcept
Mark environment as not created.
Definition env_base.h:203
SpaceType::state_type state_type
Type describing an individual state.
Definition env_base.h:48
EnvBase(const std::string &idx=bitsim::consts::INVALID_STR, const std::string &name=bitsim::consts::INVALID_STR)
Constructor (protected — for subclassing only).
Definition env_base.h:227
SpaceType::action_space action_space_type
Type describing the environment action space.
Definition env_base.h:51
virtual time_step_type reset()=0
Reset the environment to an initial state using the reset options specified during make.
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:42
uint_t next_reset_seed_()
The seed for the next reset: the "seed" reset option, or DEFAULT_ENV_SEED, plus the number of resets ...
Definition env_base.h:193
SpaceType::action_type action_type
Type representing an individual action.
Definition env_base.h:54
time_step_type & get_current_time_step_() noexcept
Mutable access to the current time step.
Definition env_base.h:209
std::string idx() const noexcept
Get the id identifying this environment within a simulation batch. The id is valid only if make has b...
Definition env_base.h:125
bool is_created() const noexcept
Check if make() has successfully initialized the environment.
Definition env_base.h:131
std::string env_name() const noexcept
Get the name of this environment instance.
Definition env_base.h:137
base_type::action_type action_type
Definition gymnasium_env_base.h:56
GymnasiumEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Constructor.
Definition gymnasium_env_base.h:139
base_type::time_step_type time_step_type
Definition gymnasium_env_base.h:47
network::RESTRLEnvClient * api_server_
Definition gymnasium_env_base.h:123
std::string get_url() const
Get the full URL for this environment endpoint on the server.
Definition gymnasium_env_base.h:216
EnvBase< TimeStepType, SpaceType > base_type
Definition gymnasium_env_base.h:44
virtual ~GymnasiumEnvBase()
Virtual destructor.
Definition gymnasium_env_base.h:153
uint_t n_copies() const
Definition gymnasium_env_base.h:172
virtual void close() override
Close the environment on the server and release any resources.
Definition gymnasium_env_base.h:179
virtual time_step_type reset() override
Reset the environment to an initial state using the reset options specified during make.
Definition gymnasium_env_base.h:193
base_type::state_space_type state_space_type
Definition gymnasium_env_base.h:50
GymnasiumEnvBase(const GymnasiumEnvBase &)
Copy constructor.
Definition gymnasium_env_base.h:146
base_type::action_space_type action_space_type
Definition gymnasium_env_base.h:53
base_type::state_type state_type
Definition gymnasium_env_base.h:59
network::RESTRLEnvClient & get_api_server() const
Retrieve the REST API wrapper instance used for communication.
Definition gymnasium_env_base.h:98
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const =0
Build a TimeStepType instance from a server JSON response.
virtual bool is_alive() const
Check whether the environment is still alive/connected.
Definition gymnasium_env_base.h:166
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
Definition bitsim_consts.cpp:10
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
Various utilities for std::map.