FluxML / Gym.jl

Gym environments in Julia
MIT License
54 stars 19 forks source link

Added a crude registry system for environments. #17

Closed kraftpunk97-zz closed 5 years ago

kraftpunk97-zz commented 5 years ago

PR added with reference to issue #10. Had to restructure the package. All the environments have been moved to src/Envs/classic_control/ directory. The utility for rendering has been relocated to src/vis/utils.jl

The global registry itself is defined in src/Envs/registration.jl. It can be accessed using two functions, make and register. register is used to register a new environment the call to which can be called from src/Envs/registry.jl. Each register calls requires a string to be used when calling via make, a symbol of the Environment type and the path to the file where the environment is defined.

make calls require just the name of the environment and any additional keyword arguments, but that needs to be tested/implemented.

@tejank10 Please review and provide feedback :)

tejank10 commented 5 years ago

Great work, @kraftpunk97 ! Regarding the returned environment, my idea was something as following:

mutable struct EnvWrapper
    done::Bool
    total_reward
    frames::Int
    trainable::Bool
   # any other metadata can be put here
    env::AbstractEnv
end

function step!(env_wrap::EnvWrapper, a)
    s', r, done, _ = step!(env_wrap.env, a)
    env_wrap.total_reward += r
    env_wrap.done = done
    env_wrap.frames += 1
    return s', r, done, _
end

function reset!(env_wrap::EnvWrapper)
    env_wrap.done = false
    env_wrap.total_reward = 0
    env_wrap.frames = 0
    reset!(env_wrap.env)
end

state(env_wrap::EnvWrapper) = env_wrap.env.state

How does returned environment of make compare with this?