gymrl
v1.2.17
Published
OpenAI style Gym for javascript
Downloads
78
Maintainers
Readme
GymRL
GymRL is a package that provides various environments for reinforcement learning.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have installed Node.js
Installation
Install GymRL using npm:
$ npm install gymrl --save
Environments
GymRL currently supports the following environments:
- TwoThousandfortyeight
- Fourinarow
- Frozenlake
- Snake
- TicTacToe
You can import an environment as follows:
const {Snake} = require("gymrl")
const {TwoThousandfortyeight} = require("gymrl")
Usage
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();
}
Methods
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].
More Info About the Environments
You can see more info about the enviroments in our wiki
Contributing to GymRL
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.