JuliaML / OpenAIGym.jl

OpenAI's Gym binding for Julia
Other
105 stars 20 forks source link

Please add Bsuite #40

Open bionicles opened 4 years ago

bionicles commented 4 years ago

How could we add the DeepMind BSuite envs?

They have a wrapper for OpenAI Gym: https://github.com/deepmind/bsuite#using-bsuite-in-openai-gym-format

Got ProcGen to work if anyone wants it:

using OpenAIGym

function run_env(env_name, n_episodes)
    println("Run $n_episodes of $env_name") 
    env = GymEnv(env_name)
    for i ∈ 1:n_episodes
      T = 0
      R = run_episode(env, RandomPolicy()) do (s, a, r, s′)
        render(env)
        T += 1
      end
      @info("Episode $i finished after $T steps. Total reward: $R")
    end
    close(env)
end

env_names = ["procgen:procgen-$stub-v0" for stub in ["bigfish","bossfight","caveflyer","chaser","climber","coinrun","dodgeball","fruitbot",
    "heist","jumper","leaper","maze","miner","ninja","plunder","starpilot"]]
get_env_name() = env_names[rand(1:length(env_names))]

function run_envs(n_envs, n_episodes)
    println("Run $n_envs procgen envs")
    for i ∈ 1:n_envs
        T = 0
        env_name = get_env_name()
        run_env(env_name, n_episodes)
    end
end
n_envs, n_episodes = 10,5
run_envs(n_envs, n_episodes)

I also have custom envs for molecular dynamics, NLP, causality, [self]supervised learning, etc if anyone wants them