8#ifndef GYMNASIUM_VECTOR_ENV_BASE_H
9#define GYMNASIUM_VECTOR_ENV_BASE_H
11#include "../../network/rest_rl_env_client.h"
12#include "bitrl/bitrl_config.h"
16#include "bitrl/extern/nlohmann/json/json.hpp"
31template <
typename VectorTimeStepType,
typename SpaceType>
68 const std::unordered_map<std::string, std::any> &options,
69 const std::unordered_map<std::string, std::any> &
reset_options) = 0;
101 bool reset_if_any_done_{
false};
104template <
typename VectorTimeStepType,
typename SpaceType>
111template <
typename VectorTimeStepType,
typename SpaceType>
114 :
GymnasiumEnvBase<VectorTimeStepType, SpaceType>(other), n_envs_(other.n_envs_),
115 reset_if_any_done_(other.reset_if_any_done_)
119template <
typename VectorTimeStepType,
typename SpaceType>
121 const std::string &version,
const std::unordered_map<std::string, std::any> &options,
122 const std::unordered_map<std::string, std::any> &reset_options)
125 auto reset_if_any_done_itr = options.find(
"reset_if_any_done");
127 if (reset_if_any_done_itr != options.end())
129 reset_if_any_done_ = std::any_cast<bool>(reset_if_any_done_itr->second);
132 auto n_envs_itr = options.find(
"num_envs");
134 if (n_envs_itr != options.end())
136 n_envs_ = std::any_cast<uint_t>(n_envs_itr->second);
140 throw std::logic_error(
"num_envs variable is not provided");
Base class interface for Reinforcement Learning environments.
Definition env_base.h:30
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Access the configuration options provided to make().
Definition env_base.h:104
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
Definition gymnasium_vector_env_base.h:33
uint_t get_n_envs() const noexcept
Returns the number of environments.
Definition gymnasium_vector_env_base.h:74
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)=0
Construct the environment instance.
Definition gymnasium_vector_env_base.h:120
GymnasiumVecEnvBase(const GymnasiumVecEnvBase &other)
Definition gymnasium_vector_env_base.h:112
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition gymnasium_vector_env_base.h:45
void reset_if_any_done(bool flag) noexcept
Definition gymnasium_vector_env_base.h:79
base_type::state_type state_type
The type of the state.
Definition gymnasium_vector_env_base.h:65
GymnasiumEnvBase< VectorTimeStepType, SpaceType >::base_type base_type
The base type.
Definition gymnasium_vector_env_base.h:39
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition gymnasium_vector_env_base.h:60
bool get_reset_if_any_done() const noexcept
Definition gymnasium_vector_env_base.h:84
GymnasiumVecEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Constructor.
Definition gymnasium_vector_env_base.h:105
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition gymnasium_vector_env_base.h:55
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition gymnasium_vector_env_base.h:50
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