gymrl
v1.3.1
Published
OpenAI style Gym for javascript
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 gymrlEnvironments
GymRL currently supports the following environments:
- TwoThousandfortyeight
- Fourinarow
- Frozenlake
- Snake
- TicTacToe
- Rubik
- Pong
You can import an environment as follows:
CommonJS
const { Snake } = require("gymrl");ESM
import { TwoThousandfortyeight } from "gymrl";Usage
Here is an example of how to use the Snake environment:
import { Snake } from "gymrl";
const match = new Snake(10); // This creates a map of 10x10
let score = 0;
let done = false;
match.render();
while (!done) {
const randomAction = match.sampleAction();
const Stepinfo = match.step(randomAction);
const reward = Stepinfo[1];
done = Stepinfo[2];
score += reward;
match.render();
console.log(`Reward: ${reward}, Total Score: ${score}`);
}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.
