bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
black_jack_env.h
Go to the documentation of this file.
1#ifndef BLACK_JACK_H
2#define BLACK_JACK_H
3
9#include "bitrl/bitrl_types.h"
12#include "bitrl/extern/nlohmann/json/json.hpp"
14
15#include <any>
16#include <string>
17#include <tuple>
18#include <unordered_map>
19#include <vector>
20
21namespace bitrl
22{
23namespace envs::gymnasium
24{
25
65class BlackJack final : public ToyTextEnvBase<TimeStep<std::vector<uint_t>>, 48, 2>
66{
67
68 public:
72 static const std::string name;
73
77 static const std::string URI;
78
83
89
93 typedef typename base_type::state_space_type state_space_type;
94
98 typedef typename base_type::action_space_type action_space_type;
99
103 typedef typename base_type::action_type action_type;
104
108 typedef typename base_type::state_type state_type;
109
111
112 BlackJack(const BlackJack &other);
113
114 ~BlackJack() override = default;
115
120 virtual void
121 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
122 const std::unordered_map<std::string, std::any> &reset_options) override final;
123
129 virtual time_step_type step(const action_type &action) override final;
130 bool is_natural() const noexcept { return is_natural_; }
131 bool is_sab() const noexcept { return is_sab_; }
132
133 protected:
137 virtual dynamics_t build_dynamics_from_response_(const nlohmann::json &) const override final;
138
142 virtual time_step_type
143 create_time_step_from_response_(const nlohmann::json &) const override final;
144
145 private:
150 bool is_natural_{false};
151 bool is_sab_{false};
152
153 void make_natural() noexcept { is_natural_ = true; }
154 void make_sab() noexcept { is_sab_ = true; }
155};
156
157} // namespace envs::gymnasium
158} // namespace bitrl
159#endif // BLACK_JACK_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
Definition black_jack_env.h:66
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition black_jack_env.h:93
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition black_jack_env.h:88
virtual time_step_type create_time_step_from_response_(const nlohmann::json &) const override final
Handle the reset response from the environment server.
Definition black_jack_env.cpp:25
virtual dynamics_t build_dynamics_from_response_(const nlohmann::json &) const override final
build the dynamics from response
Definition black_jack_env.cpp:19
static const std::string URI
The URI for accessing the environment.
Definition black_jack_env.h:77
bool is_sab() const noexcept
Definition black_jack_env.h:131
virtual time_step_type step(const action_type &action) override final
step
Definition black_jack_env.cpp:85
ToyTextEnvBase< TimeStep< std::vector< uint_t > >, 48, 2 >::base_type base_type
The base type.
Definition black_jack_env.h:82
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
Definition black_jack_env.cpp:52
static const std::string name
name
Definition black_jack_env.h:72
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition black_jack_env.h:103
bool is_natural() const noexcept
Definition black_jack_env.h:130
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition black_jack_env.h:98
base_type::state_type state_type
The type of the action to be undertaken in the environment.
Definition black_jack_env.h:108
ToyTextEnvBase class. Base class for toy environments from Gymnasium. These environments have a discr...
Definition toy_text_base.h:34
std::vector< std::tuple< real_t, uint_t, real_t, bool > > dynamics_t
dynamics_t
Definition toy_text_base.h:71
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