load_gym_env: Load a gym environment

Description Creating the gym Using the gym Examples

Description

A gym environment is designed to work with functions to optimise decisions through reinforcement learning. It is designed to be able to plug in functions to tackle new reinforcement learning tasks, and to take care of the running of these functions using R6 classes.

Creating the gym

A gym environment is an R6 object, that can be created with gym_env$new(). It has the following arguments:

env

The environment we want to perform reinforcement learning on. This is a function object that determines rewards and new states based on input states and actions.

length

The number of actions within the environment until it is considered to be done. By default this is 1,000 actions.

Using the gym

There are three key functions to use with a gym class.

gym_env$step(a)

This function allows us to step through the environment we have defined above. We supply an action, and gym then runs this action through the environment

gym_env$reset()

When we don't want to worry about recreating a gym object, we can just reset the object back to the state of creation. This clears all cumulative rewards etc.

gym_env$get()

This function allows us to extract the private values within the R6 class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 

# simple gym environment with nchain
myfunc <- load_gym_env$new(nchain)

# run through one step of the environment
myfunc$step(1)

# get the results
myfunc$get()

## End(Not run)

liamgilbey/gymr documentation built on June 1, 2019, 3:56 a.m.