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

Commit 8141ddb

Browse files
authored
Remove space (#114)
* update dependency of RLBase * bump version
1 parent 5b1343d commit 8141ddb

File tree

2 files changed

+2
-65
lines changed

2 files changed

+2
-65
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ReinforcementLearningEnvironments"
22
uuid = "25e41dd2-4622-11e9-1641-f1adca772921"
33
authors = ["Jun Tian <[email protected]>"]
4-
version = "0.4.2"
4+
version = "0.4.3"
55

66
[deps]
77
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
@@ -19,7 +19,7 @@ GR = "0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53"
1919
IntervalSets = "0.5"
2020
MacroTools = "0.5"
2121
OrdinaryDiffEq = "5"
22-
ReinforcementLearningBase = "0.9"
22+
ReinforcementLearningBase = "0.9.1"
2323
Requires = "1.0"
2424
StatsBase = "0.32, 0.33"
2525
julia = "1.3"

src/base.jl

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ end
1616
# WorldSpace
1717
#####
1818

19-
export WorldSpace
20-
21-
"""
22-
In some cases, we may not be interested in the action/state space.
23-
One can return `WorldSpace()` to keep the interface consistent.
24-
"""
25-
struct WorldSpace{T} end
26-
27-
WorldSpace() = WorldSpace{Any}()
28-
29-
Base.in(x, ::WorldSpace{T}) where {T} = x isa T
30-
3119
#####
3220
# ZeroTo
3321
#####
@@ -58,57 +46,6 @@ end
5846
# Space
5947
#####
6048

61-
export Space
62-
63-
"""
64-
A wrapper to treat each element as a sub-space which supports:
65-
66-
- `Base.in`
67-
- `Random.rand`
68-
"""
69-
struct Space{T}
70-
s::T
71-
end
72-
73-
@forward Space.s Base.getindex, Base.setindex!, Base.size, Base.length
74-
75-
Base.similar(s::Space, args...) = Space(similar(s.s, args...))
76-
77-
Random.rand(s::Space) = rand(Random.GLOBAL_RNG, s)
78-
79-
Random.rand(rng::AbstractRNG, s::Space) =
80-
map(s.s) do x
81-
rand(rng, x)
82-
end
83-
84-
Random.rand(rng::AbstractRNG, s::Space{<:Dict}) = Dict(k => rand(rng, v) for (k, v) in s.s)
85-
86-
function Base.in(X, S::Space)
87-
if length(X) == length(S.s)
88-
for (x, s) in zip(X, S.s)
89-
if x s
90-
return false
91-
end
92-
end
93-
return true
94-
else
95-
return false
96-
end
97-
end
98-
99-
function Base.in(X::Dict, S::Space{<:Dict})
100-
if keys(X) == keys(S.s)
101-
for k in keys(X)
102-
if X[k] S.s[k]
103-
return false
104-
end
105-
end
106-
return true
107-
else
108-
return false
109-
end
110-
end
111-
11249
#####
11350
# Generate README
11451
#####

0 commit comments

Comments
 (0)