From 8a17546378c6b9481e81a27a7b3c9c6c5f794c0b Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Sun, 18 Oct 2020 22:48:20 +0800 Subject: [PATCH 1/2] minor fix --- src/extensions/ElasticArrays.jl | 1 + src/utils/reservoir_array_buffer.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extensions/ElasticArrays.jl b/src/extensions/ElasticArrays.jl index 5a67d22..a3fd3ad 100644 --- a/src/extensions/ElasticArrays.jl +++ b/src/extensions/ElasticArrays.jl @@ -1,6 +1,7 @@ using ElasticArrays Base.push!(a::ElasticArray, x) = append!(a, x) +Base.push!(a::ElasticArray{T,1}, x) where T = append!(a, [x]) Base.empty!(a::ElasticArray) = ElasticArrays.resize_lastdim!(a, 0) function Base.pop!(a::ElasticArray) diff --git a/src/utils/reservoir_array_buffer.jl b/src/utils/reservoir_array_buffer.jl index 5283a85..16d6f02 100644 --- a/src/utils/reservoir_array_buffer.jl +++ b/src/utils/reservoir_array_buffer.jl @@ -26,7 +26,7 @@ Base.IndexStyle function Base.push!(b::ReservoirArrayBuffer{T,N}, x) where {T,N} b.n += 1 if b.n <= b.capacity - append!(b.buffer, x) + push!(b.buffer, x) else i = rand(b.rng, 1:b.n) if i <= b.capacity From 1887b2cb8d3c279bf1b0c57b75448fec1d596add Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 19 Oct 2020 13:29:41 +0800 Subject: [PATCH 2/2] split the logic of run into two steps --- src/core/run.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/run.jl b/src/core/run.jl index ea46452..39ef1f3 100644 --- a/src/core/run.jl +++ b/src/core/run.jl @@ -2,10 +2,11 @@ export expected_policy_values import Base: run -run(agent, env::AbstractEnv, args...) = - run(DynamicStyle(env), NumAgentStyle(env), agent, env, args...) +run(agent, env::AbstractEnv, args...) = _run(agent, env, args...) -function run( +_run(agent, env, args...) = _run(DynamicStyle(env), NumAgentStyle(env), agent, env, args...) + +function _run( ::Sequential, ::SingleAgent, agent::AbstractAgent, @@ -45,7 +46,7 @@ function run( hook end -function run( +function _run( ::Sequential, ::SingleAgent, agent::AbstractAgent, @@ -71,7 +72,7 @@ function run( hook end -function run( +function _run( ::Sequential, ::MultiAgent, agents::Tuple{Vararg{<:AbstractAgent}},