GymRL is a package that provides various environments for reinforcement learning.
Before you begin, ensure you have met the following requirements:
- You have installed Node.js
Install GymRL using npm:
$ npm install gymrl --save
GymRL currently supports the following environments:
- TwoThousandfortyeight
- Fourinarow
- Frozenlake
- Snake
- TicTacToe
- Rubik
- Pong
You can import an environment as follows:
const {Snake} = require("gymrl")
const {TwoThousandfortyeight} = require("gymrl")
Here is an example of how to use the Snake environment:
const {Snake} = require("gymrl")
let match = new Snake(10); // This creates a map of 10x10
let score = 0;
let done = false;
match.render();
let status = match.get_obs();
while(!done){
let randomAction = Snake.sampleAction();
let Stepinfo = match.step(randomAction);
status = Stepinfo[0];
let reward = Stepinfo[1];
done = Stepinfo[2];
let info = Stepinfo[3];
score += reward;
match.render();
}
The following methods are available in all environments:
- render(): Creates a string representation of the environment and displays it in the console.
- sampleAction(): Returns a random action from the environment.
- get_obs(): Returns the current observations of the environment.
- get_info(): Returns additional information about the observations of the environment.
- reset(): Resets the environment.
- step(action): Performs one step in the environment using the specified action and returns an array with four entries: [newStatus, Reward, Done, Info].
You can see more info about the enviroments in our wiki
If you want to contribute to GymRL, whether by adding a new environment or fixing bugs, please check out the source code and submit a pull request or issue.