Environment: Custom Reinforcement Learning Environment

EnvironmentR Documentation

Custom Reinforcement Learning Environment

Description

Custom Reinforcement Learning Environment

Arguments

step

[function(self, action)]
Custom step function.

reset

[function(self)]
Custom reset function.

visualize

[function(self)]
Optional custom visualization function.

discount

[numeric(1) in (0, 1)]
Discount factor.

action.names

[named integer]
Optional action names for a discrete action space.

Usage

makeEnvironment("custom", step, reset, visualize = NULL, discount = 1, action.names = NULL)

Methods

  • $step(action)
    Take action in environment. Returns a list with state, reward, done.

  • $reset()
    Resets the done flag of the environment and returns an initial state. Useful when starting a new episode.

  • $visualize()
    Visualizes the environment (if there is a visualization function).

Examples

step = function(self, action) {
  state = list(mean = action + rnorm(1), sd = runif(1))
  reward = rnorm(1, state[[1]], state[[2]])
  done = FALSE
  list(state, reward, done)
}

reset = function(self) {
  state = list(mean = 0, sd = 1)
  state
}

env = makeEnvironment(step = step, reset = reset)
env$reset()
env$step(100)

markdumke/reinforcelearn documentation built on Nov. 17, 2022, 12:53 a.m.