Skip to content

sritee/CPPGym

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPPGym

C++ OpenAI Gym

Currently, Using C++ with OpenAI Gym involve having a communication channel/wrapper with the Python source code. This open-source project aims at developing some of the core functionalities of OpenAI gym in C++.

This README will be continuously updated as new features are added, bugs are fixed, and other changes are made.

Dependencies

  • C++17 Supported Compiler (Tested with GCC 7.1)
  • QMake (Tested with QMake 3.0)
  • Eigen3

Build (from Source)

git clone https://github.com/sritee/CPPGym
cd CPPGym
mkdir build
cd build
qmake ../CPPGym.pro
make -j8 (replace 8 with number of cores)

Usage

To start off, you can refer to the code in gym/main.cpp after building from source. You can also build the project and link with yours.

#include <Eigen/Core>
#include <string>
#include <tuple>
#include "gym/gym.h"

int main()
{
  Eigen::VectorXf state;
  float reward;
  bool done;
  std::string info;

  auto env = cppgym::gym::make("MountainCar1"); //env is a unique_ptr to a gym environment
  state = env->reset(); //call reset before simulating

  for(int i = 0; i < 10; ++i)
  {
    std::tie(state, reward, done, info) = env->step(0); //unpack tuple
  }
  return 0;
}

In the Works!

  • Tests and CI
  • 2D Rendering Support
  • Contributing Guidelines
  • More Environments!