Custom Reinforcement Learning Environment
step | [ |
---|---|
reset | [ |
visualize | [ |
discount | [ |
action.names | [ |
makeEnvironment("custom", step, reset, visualize = NULL, discount = 1, action.names = NULL)
$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).
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()#> $mean #> [1] 0 #> #> $sd #> [1] 1 #>env$step(100)#> $state #> $state$mean #> [1] 98.59996 #> #> $state$sd #> [1] 0.6007609 #> #> #> $reward #> [1] 97.99559 #> #> $done #> [1] FALSE #>