#include <iostream>
#include <unordered_map>
#include <vector>
{
const std::string
SERVER_URL =
"http://0.0.0.0:8001/api";
}
{
std::unordered_map<std::string, std::any> options;
options[
"wind_power"] = std::any(
static_cast<bitrl::real_t>(10.0));
options["enable_wind"] = std::any(static_cast<bool>(true));
options[
"gravity"] = std::any(
static_cast<bitrl::real_t>(-9.86));
options[
"turbulence_power"] = std::any(
static_cast<bitrl::real_t>(1.5));
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
{
std::cout<<"Working with LunarLanderDiscreteEnv..."<<std::endl;
std::cout << "Is environment registered: " << server.is_env_registered(LunarLanderDiscreteEnv::name)
<< std::endl;
env.make(
"v3", options, reset_ops);
std::cout<<
"Is environment created? "<<
env.is_created()<<std::endl;
std::cout<<
"Is environment alive? "<<
env.is_alive()<<std::endl;
std::cout<<
"Number of valid actions? "<<
env.n_actions()<<std::endl;
auto time_step =
env.reset();
std::cout<<"Time step: "<<time_step<<std::endl;
std::cout<<"Time step: "<<time_step<<std::endl;
}
{
std::cout << "Working with LunarLanderContinuousEnv..." << std::endl;
env.make(
"v3", options, reset_ops);
std::cout <<
"Is environment created? " <<
env.is_created() << std::endl;
std::cout <<
"Is environment alive? " <<
env.is_alive() << std::endl;
std::cout <<
"Action space size " <<
env.n_actions() << std::endl;
std::cout <<
"Environment URI: " << server.get_uri(
env.env_name()) << std::endl;
auto time_step =
env.reset();
std::cout << "Time step: " << time_step << std::endl;
std::vector<real_t>
action = {0.8, 0.9};
time_step =
env.step(action);
std::cout << "Time step: " << time_step << std::endl;
}
return 0;
}
Definition lunar_lander_env.h:271
LunarLanderDiscreteEnv environment with discrete action space.
Definition lunar_lander_env.h:202
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:29
int main()
Definition intro_example_1.cpp:31
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
Definition example_4.cpp:11
const std::string SERVER_URL
Definition example_4.cpp:13
dict action
Definition play.py:41