Skip to content

Commit

Permalink
add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrea committed Aug 10, 2018
1 parent d83a5f1 commit bf6663a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/RLEnvGym.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
interact!(action, env::GymEnv) = interactgym!(action, env)
interact!(action::Int64, env::GymEnv) = interactgym!(action - 1, env)
reset!(env::GymEnv) = env.pyobj[:reset]()
getstate(env::GymEnv) = (env.pyobj[:env][:state], false) # doesn't work for all envs
getstate(env::GymEnv) = (Float64[env.pyobj[:env][:state]...], false) # doesn't work for all envs

plotenv(env::GymEnv, s, a, r, d) = env.pyobj[:render]()
listallenvs() = gym.envs[:registry][:all]()
Expand Down
9 changes: 7 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ else
using Test
end

# write your own tests here
@test 1 == 2
import RLEnvGym: reset!, interact!, getstate
for x in ["CartPole-v0"]
env = GymEnv(x)
reset!(env)
@test typeof(interact!(1, env)) == Tuple{Array{Float64, 1}, Float64, Bool}
@test typeof(getstate(env)) == Tuple{Array{Float64, 1}, Bool}
end

0 comments on commit bf6663a

Please sign in to comment.