smilesun / rlR

Deep Reinforcement Learning in R (Deep Q Learning, Policy Gradient, Actor-Critic Method, etc)
https://smilesun.github.io/rlR
Other
26 stars 4 forks source link

user interface environments #6

Closed markusdumke closed 6 years ago

markusdumke commented 6 years ago

@smilesun

What do you think is better for the user interface? Having one function makeEnvironment which then calls the corresponding environment subclass as in 1. or exposing all the subclasses to the user as in 2.?

# 1. ---- user calls only this function
makeEnvironment = function(subclass, argsofsubclass) {
  switch(subclass, 
    "Mdp" = MdpEnvironment$new(argsofsubclass))  # etc
}

# examples
makeEnvironment("custom", step = step, reset = reset)
makeEnvironment("Mdp", transitions, rewards)
makeEnvironment("Gym", gym.name = "MountainCar-v0")

# 2. ---- user calls subclass directly
# examples
Environment$new(step, reset)
MdpEnvironment$new(transitions, rewards)
GymEnvironment$new(gym.name = "MountainCar-v0")
smilesun commented 6 years ago

Use 2, but embed 2 into 1. We can decide whether to expose 2 to the user.

markusdumke commented 6 years ago

Ok, I have a draft now online, integrating the new object-oriented environments into the master thesis package version:

https://github.com/markdumke/reinforcelearn/blob/yet_another_branch/R/environment.R

You can install it with devtools::install_github("markdumke/reinforcelearn", ref = "yet_another_branch") and then run e.g. ?makeEnvironment and ?GymEnvironment.