22# bitrl
33
44``` bitrl ``` is an effort to provide implementations and wrappers of environments suitable for training reinforcement learning agents
5- using C++.
5+ using C++. The documentation for the library can be found < a href = " https://pockerman.github.io/bitrl/index.html " >here</ a >.
66
7- Furthermore, there is some minimal support for working with Arduino UNO boards over USB or WiFi.
8- See also <a href =" https://rlenvscpp.readthedocs.io/en/latest/working_with_webots.html " >Working with Webots</a >
9- for how to integrate ``` bitrl ``` with <a href =" https://cyberbotics.com/doc/guide/installing-webots " >Webots</a >.
10-
11- Various RL algorithms using the environments can be found at <a href =" https://github.com/pockerman/cuberl/tree/master " >cuberl</a >.
12-
13- The documentation for the library can be found <a href =" https://pockerman.github.io/bitrl/index.html " >here</a >.
147The following is an example how to use the
158`` FrozenLake `` environment from <a href =" https://github.com/Farama-Foundation/Gymnasium/tree/main " >Gymnasium</a >.
169
1710```
1811
1912#include "bitrl/bitrl_types.h"
2013#include "bitrl/envs/gymnasium/toy_text/frozen_lake_env.h"
21- #include "bitrl/envs/api_server/apiserver .h"
14+ #include "bitrl/network/rest_rl_env_client .h"
2215
2316#include <iostream>
2417#include <string>
@@ -32,29 +25,33 @@ const std::string SERVER_URL = "http://0.0.0.0:8001/api";
3225using bitrl::envs::gymnasium::FrozenLake;
3326using bitrl::envs::RESTApiServerWrapper;
3427
35-
3628void test_frozen_lake(const RESTApiServerWrapper& server){
3729
3830 FrozenLake<4> env(server);
3931
4032 std::cout<<"Environame URL: "<<env.get_url()<<std::endl;
4133
4234 // make the environment
43- std::unordered_map<std::string, std::any> options;
44- options.insert({"is_slippery", false});
45- env.make("v1", options);
35+ std::unordered_map<std::string, std::any> make_ops;
36+ make_ops.insert({"is_slippery", false});
37+
38+ std::unordered_map<std::string, std::any> reset_ops;
39+ reset_ops.insert({"seed", static_cast<uint_t>(42)});
40+ env.make("v1", make_ops, reset_ops);
4641
4742 std::cout<<"Is environment created? "<<env.is_created()<<std::endl;
4843 std::cout<<"Is environment alive? "<<env.is_alive()<<std::endl;
4944 std::cout<<"Number of valid actions? "<<env.n_actions()<<std::endl;
5045 std::cout<<"Number of states? "<<env.n_states()<<std::endl;
46+ std::cout<<"Env idx: "<<env.idx()<<std::endl;
5147
5248 // reset the environment
53- auto time_step = env.reset(42, std::unordered_map<std::string, std::any>() );
49+ auto time_step = env.reset();
5450
5551 std::cout<<"Reward on reset: "<<time_step.reward()<<std::endl;
5652 std::cout<<"Observation on reset: "<<time_step.observation()<<std::endl;
5753 std::cout<<"Is terminal state: "<<time_step.done()<<std::endl;
54+ std::cout<<"Env idx: "<<env.idx()<<std::endl;
5855
5956 //...print the time_step
6057 std::cout<<time_step<<std::endl;
@@ -73,7 +70,6 @@ void test_frozen_lake(const RESTApiServerWrapper& server){
7370 std::cout<<"Dynamics for state="<<state<<" and action="<<action<<std::endl;
7471
7572 for(auto item:dynamics){
76-
7773 std::cout<<std::get<0>(item)<<std::endl;
7874 std::cout<<std::get<1>(item)<<std::endl;
7975 std::cout<<std::get<2>(item)<<std::endl;
@@ -85,13 +81,10 @@ void test_frozen_lake(const RESTApiServerWrapper& server){
8581
8682 new_time_step = env.step(action);
8783 std::cout<<new_time_step<<std::endl;
88-
89- std::cout<<"env cidx: "<<env.cidx()<<std::endl;
9084
9185 // close the environment
9286 env.close();
9387}
94-
9588}
9689
9790
@@ -109,3 +102,11 @@ int main(){
109102}
110103
111104```
105+
106+ Gymnasium environments exposed over a REST like API can be found at: <href="https://github.com/pockerman/bitrl-rest-api">bitrl-rest-api </a >
107+ Various RL algorithms using the environments can be found at <a href =" https://github.com/pockerman/cuberl/tree/master " >cuberl</a >.
108+
109+ Furthermore, there is some minimal support for working with Arduino UNO boards over USB or WiFi.
110+ See also <a href =" https://rlenvscpp.readthedocs.io/en/latest/working_with_webots.html " >Working with Webots</a >
111+ for how to integrate ``` bitrl ``` with <a href =" https://cyberbotics.com/doc/guide/installing-webots " >Webots</a >.
112+
0 commit comments