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

Commit

Permalink
Format .jl files (#107)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] authored Dec 25, 2020
1 parent fa87a29 commit 7e87895
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/converters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ function discrete2standard_discrete(env::AbstractEnv)
if is_discrete_space(A)
AS = ActionStyle(env)
if AS === FULL_ACTION_SET
mapping = Dict(x => i for (i,x) in enumerate(A))
mapping = Dict(x => i for (i, x) in enumerate(A))
ActionTransformedEnv(
env;
action_space_mapping = a -> map(x -> mapping[x], a),
action_mapping = i -> A[i]
action_mapping = i -> A[i],
)
elseif AS === MINIMAL_ACTION_SET
ActionTransformedEnv(
env;
action_space_mapping = x -> Base.OneTo(length(A)),
action_mapping = i -> A[i]
action_mapping = i -> A[i],
)
else
@error "unknown ActionStyle $AS"
Expand Down
2 changes: 1 addition & 1 deletion src/environments/wrappers/DefaultStateStyle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DefaultStateStyleEnv{S}(env::E) where {S,E} = DefaultStateStyleEnv{S,E}(env)
RLBase.DefaultStateStyle(::DefaultStateStyleEnv{S}) where {S} = S

for f in vcat(RLBase.ENV_API, RLBase.MULTI_AGENT_ENV_API)
if f (:DefaultStateStyle, )
if f (:DefaultStateStyle,)
@eval RLBase.$f(x::DefaultStateStyleEnv, args...; kwargs...) =
$f(x.env, args...; kwargs...)
end
Expand Down
4 changes: 2 additions & 2 deletions src/environments/wrappers/StateOverriddenEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ StateOverriddenEnv(f) = env -> StateOverriddenEnv(f, env)
(env::StateOverriddenEnv)(args...; kwargs...) = env.env(args...; kwargs...)

for f in vcat(RLBase.ENV_API, RLBase.MULTI_AGENT_ENV_API)
if f (:state, )
if f (:state,)
@eval RLBase.$f(x::StateOverriddenEnv, args...; kwargs...) =
$f(x.env, args...; kwargs...)
end
Expand All @@ -32,4 +32,4 @@ RLBase.state(env::StateOverriddenEnv, ss::RLBase.AbstractStateStyle) =
env.f(state(env.env, ss))

RLBase.state_space(env::StateOverriddenEnv, ss::RLBase.AbstractStateStyle) =
state_space(env.env, ss)
state_space(env.env, ss)
13 changes: 8 additions & 5 deletions src/environments/wrappers/StochasticEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ struct StochasticEnv{E<:AbstractEnv,R} <: AbstractEnv
rng::R
end

function StochasticEnv(env;rng=Random.GLOBAL_RNG)
ChanceStyle(env) === EXPLICIT_STOCHASTIC || throw(ArgumentError("only environments of EXPLICIT_STOCHASTIC style is supported"))
env = StochasticEnv(env,rng)
function StochasticEnv(env; rng = Random.GLOBAL_RNG)
ChanceStyle(env) === EXPLICIT_STOCHASTIC ||
throw(ArgumentError("only environments of EXPLICIT_STOCHASTIC style is supported"))
env = StochasticEnv(env, rng)
reset!(env)
env
end
Expand All @@ -35,7 +36,8 @@ function (env::StochasticEnv)(a)
end

RLBase.ChanceStyle(::StochasticEnv) = STOCHASTIC
RLBase.players(env::StochasticEnv) = [p for p in players(env.env) if p != chance_player(env.env)]
RLBase.players(env::StochasticEnv) =
[p for p in players(env.env) if p != chance_player(env.env)]
Random.seed!(env::StochasticEnv, s) = Random.seed!(env.rng, s)

for f in vcat(RLBase.ENV_API, RLBase.MULTI_AGENT_ENV_API)
Expand All @@ -46,4 +48,5 @@ for f in vcat(RLBase.ENV_API, RLBase.MULTI_AGENT_ENV_API)
end

RLBase.state(env::StochasticEnv, ss::RLBase.AbstractStateStyle) = state(env.env, ss)
RLBase.state_space(env::StochasticEnv, ss::RLBase.AbstractStateStyle) = state_space(env.env, ss)
RLBase.state_space(env::StochasticEnv, ss::RLBase.AbstractStateStyle) =
state_space(env.env, ss)
2 changes: 1 addition & 1 deletion test/environments/3rd_party/snake_game.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "snake game env" begin
# env = SnakeGameEnv()
# RLBase.test_runnable!(env)
end
end
2 changes: 1 addition & 1 deletion test/environments/wrappers/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
@testset "StochasticEnv" begin
env = KuhnPokerEnv()
rng = StableRNG(123)
env′ = StochasticEnv(env;rng=rng)
env′ = StochasticEnv(env; rng = rng)

RLBase.test_interfaces!(env′)
RLBase.test_runnable!(env′)
Expand Down

0 comments on commit 7e87895

Please sign in to comment.