From 7e8789538344c5ddc4e7393f5dec757a463282ab Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Dec 2020 22:22:19 +0800 Subject: [PATCH] Format .jl files (#107) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/converters.jl | 6 +++--- src/environments/wrappers/DefaultStateStyle.jl | 2 +- src/environments/wrappers/StateOverriddenEnv.jl | 4 ++-- src/environments/wrappers/StochasticEnv.jl | 13 ++++++++----- test/environments/3rd_party/snake_game.jl | 2 +- test/environments/wrappers/wrappers.jl | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/converters.jl b/src/converters.jl index f0111d3..9277a13 100644 --- a/src/converters.jl +++ b/src/converters.jl @@ -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" diff --git a/src/environments/wrappers/DefaultStateStyle.jl b/src/environments/wrappers/DefaultStateStyle.jl index 235cb6b..d9234bd 100644 --- a/src/environments/wrappers/DefaultStateStyle.jl +++ b/src/environments/wrappers/DefaultStateStyle.jl @@ -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 diff --git a/src/environments/wrappers/StateOverriddenEnv.jl b/src/environments/wrappers/StateOverriddenEnv.jl index a1ba29b..6192f72 100644 --- a/src/environments/wrappers/StateOverriddenEnv.jl +++ b/src/environments/wrappers/StateOverriddenEnv.jl @@ -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 @@ -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) \ No newline at end of file + state_space(env.env, ss) diff --git a/src/environments/wrappers/StochasticEnv.jl b/src/environments/wrappers/StochasticEnv.jl index 403781e..a5ebced 100644 --- a/src/environments/wrappers/StochasticEnv.jl +++ b/src/environments/wrappers/StochasticEnv.jl @@ -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 @@ -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) @@ -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) diff --git a/test/environments/3rd_party/snake_game.jl b/test/environments/3rd_party/snake_game.jl index 51b2d71..dfbc391 100644 --- a/test/environments/3rd_party/snake_game.jl +++ b/test/environments/3rd_party/snake_game.jl @@ -1,4 +1,4 @@ @testset "snake game env" begin # env = SnakeGameEnv() # RLBase.test_runnable!(env) -end \ No newline at end of file +end diff --git a/test/environments/wrappers/wrappers.jl b/test/environments/wrappers/wrappers.jl index 7651b22..09b862b 100644 --- a/test/environments/wrappers/wrappers.jl +++ b/test/environments/wrappers/wrappers.jl @@ -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′)