Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

reset current_t upon resetting MaxTimeoutEnv #115

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/environments/wrappers/MaxTimeoutEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function (env::MaxTimeoutEnv)(args...; kwargs...)
end

for f in vcat(RLBase.ENV_API, RLBase.MULTI_AGENT_ENV_API)
if f != :terminal
if f ∉ (:is_terminated, :reset!)
@eval RLBase.$f(x::MaxTimeoutEnv, args...; kwargs...) =
$f(x.env, args...; kwargs...)
end
Expand All @@ -29,6 +29,10 @@ end
RLBase.is_terminated(env::MaxTimeoutEnv) =
(env.current_t > env.max_t) || is_terminated(env.env)

function RLBase.reset!(env::MaxTimeoutEnv)
env.current_t = 1
RLBase.reset!(env.env)
end

RLBase.state(env::MaxTimeoutEnv, ss::RLBase.AbstractStateStyle) = state(env.env, ss)
RLBase.state_space(env::MaxTimeoutEnv, ss::RLBase.AbstractStateStyle) =
Expand Down
4 changes: 4 additions & 0 deletions test/environments/wrappers/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
n -= 1
@test n >= 0
end

reset!(env′)
@test env′.current_t == 1
@test is_terminated(env′) == false
end

@testset "RewardOverriddenEnv" begin
Expand Down