Below is the driver code.
#ifdef BITSIM_DEBUG
#include <cassert>
#endif
#include <iostream>
#include <random>
#include <string>
#include <unordered_map>
{
{
<< std::endl;
std::cout << "Name: " << env.name << std::endl;
std::cout << "Number of actions: " << env.n_actions() << std::endl;
std::unordered_map<std::string, std::any> options;
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
env.make("v1", options, reset_ops);
auto time_step = env.reset();
std::cout << "Time step: " << time_step << std::endl;
time_step = env.step(0);
std::cout << "Time step after action: " << time_step << std::endl;
env.close();
}
{
std::cout <<
"Is environment registered: " << server.is_env_registered(
Acrobot::name)
<< std::endl;
std::cout <<
"Name: " <<
env.name << std::endl;
std::cout <<
"Number of actions: " <<
env.n_actions() << std::endl;
std::unordered_map<std::string, std::any> options;
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
env.make(
"v1", options, reset_ops);
auto time_step =
env.reset();
std::cout << "Time step: " << time_step << std::endl;
std::cout << "Time step after action: " << time_step << std::endl;
}
{
std::cout <<
"Is environment registered: " << server.is_env_registered(
Pendulum::name)
<< std::endl;
std::cout <<
"Name: " <<
env.name << std::endl;
std::cout <<
"Number of actions: " <<
env.n_actions() << std::endl;
std::unordered_map<std::string, std::any> options;
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
env.make(
"v1", options, reset_ops);
auto time_step =
env.reset();
std::cout << "Time step: " << time_step << std::endl;
time_step =
env.step(0.0);
std::cout << "Time step after action: " << time_step << std::endl;
}
{
std::cout <<
"Is environment registered: " << server.is_env_registered(
MountainCar::name)
<< std::endl;
std::cout <<
"Name: " <<
env.name << std::endl;
std::cout <<
"Number of actions: " <<
env.n_actions() << std::endl;
std::unordered_map<std::string, std::any> options;
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
env.make(
"v0", options, reset_ops);
auto time_step =
env.reset();
std::cout << "Time step: " << time_step << std::endl;
time_step =
env.step(0.0);
std::cout << "Time step after action: " << time_step << std::endl;
}
}
{
const std::string
SERVER_URL =
"http://0.0.0.0:8001/api";
std::cout << "Testing CartPole..." << std::endl;
std::cout << "====================" << std::endl;
std::cout << "Testing Pendulum..." << std::endl;
std::cout << "====================" << std::endl;
std::cout << "Testing Acrobot..." << std::endl;
std::cout << "====================" << std::endl;
std::cout << "Testing MountainCar..." << std::endl;
std::cout << "====================" << std::endl;
return 0;
return 0;
}
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
class Acrobot. The Acrobot class. Interface for Gymnasium::Acrobot environment.
Definition acrobot_env.h:154
static const std::string name
The name of the environment.
Definition acrobot_env.h:160
The CartPole class Interface for CartPole environment.
Definition cart_pole_env.h:70
static const std::string name
name
Definition cart_pole_env.h:76
The MountainCar class.
Definition mountain_car_env.h:28
static const std::string name
name
Definition mountain_car_env.h:34
The Pendulum class. Interface for Pendulum environment.
Definition pendulum_env.h:106
static const std::string name
name
Definition pendulum_env.h:112
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
bool is_env_registered(const std::string &env_name) const noexcept
int main()
Definition discounted_returns.cpp:19
Definition lunar_lander_env.h:18
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
Definition pytorch_linear_regression.cpp:17
void test_pendulum(RESTRLEnvClient &server)
Definition gymnasium_part_2.cpp:79
void test_cart_pole(RESTRLEnvClient &server)
Definition gymnasium_part_2.cpp:25
void test_acrobot(RESTRLEnvClient &server)
Definition gymnasium_part_2.cpp:52
void test_mountain_car(RESTRLEnvClient &server)
Definition gymnasium_part_2.cpp:106
const std::string SERVER_URL
Definition gym_walk.cpp:14