This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update atari env to use max-pooling (#22)
* update atari env * add test cases for atari environments * add doc
- Loading branch information
Showing
5 changed files
with
190 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
@testset "atari" begin | ||
@testset "seed" begin | ||
env = AtariEnv(;name="pong", seed=(123,456)) | ||
old_states = [] | ||
actions = [rand(action_space(env)) for i in 1:10, j in 1:100] | ||
|
||
for i in 1:10 | ||
for j in 1:100 | ||
interact!(env, actions[i, j]) | ||
push!(old_states, copy(observe(env).state)) | ||
end | ||
reset!(env) | ||
end | ||
|
||
env = AtariEnv(;name="pong", seed=(123,456)) | ||
new_states = [] | ||
for i in 1:10 | ||
for j in 1:100 | ||
interact!(env, actions[i, j]) | ||
push!(new_states, copy(observe(env).state)) | ||
end | ||
reset!(env) | ||
end | ||
|
||
@test old_states == new_states | ||
end | ||
|
||
@testset "frame_skip" begin | ||
env = AtariEnv(;name="pong", frame_skip=4, seed=(123,456)) | ||
states = [] | ||
actions = [rand(action_space(env)) for _ in 1:100] | ||
|
||
for i in 1:100 | ||
interact!(env, actions[i]) | ||
push!(states, copy(observe(env).state)) | ||
end | ||
|
||
env = AtariEnv(;name="pong", frame_skip=1, seed=(123,456)) | ||
for i in 1:100 | ||
interact!(env, actions[i]) | ||
interact!(env, actions[i]) | ||
interact!(env, actions[i]) | ||
s1 = copy(observe(env).state) | ||
interact!(env, actions[i]) | ||
s2 = copy(observe(env).state) | ||
@test states[i] == max.(s1, s2) | ||
end | ||
end | ||
|
||
@testset "repeat_action_probability" begin | ||
env = AtariEnv(;name="pong", repeat_action_probability=1.0, seed=(123,456)) | ||
states = [] | ||
actions = [rand(action_space(env)) for _ in 1:100] | ||
for i in 1:100 | ||
interact!(env, actions[i]) | ||
push!(states, copy(observe(env).state)) | ||
end | ||
|
||
env = AtariEnv(;name="pong", repeat_action_probability=1.0, seed=(123,456)) | ||
for i in 1:100 | ||
interact!(env, actions[1]) | ||
@test states[i] == observe(env).state | ||
end | ||
end | ||
|
||
@testset "max_num_frames_per_episode" begin | ||
for i in 1:10 | ||
env = AtariEnv(;name="pong", max_num_frames_per_episode=i, seed=(123,456)) | ||
for _ in 1:i | ||
interact!(env, 1) | ||
end | ||
@test true == observe(env).terminal | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ using Hanabi | |
|
||
include("spaces.jl") | ||
include("environments.jl") | ||
|
||
include("atari.jl") | ||
end |