FluxML / Gym.jl

Gym environments in Julia
MIT License
54 stars 19 forks source link

Box space equality is not correct #21

Open v-i-s-h opened 5 years ago

v-i-s-h commented 5 years ago

Box space with different datatypes are compared to be equal if range is same. MWE:

julia> box1 = Box(0, 255, (1,), Float32)
Box(Float32[0.0], Float32[255.0], (1,), Float32)

julia> box2 = Box(0, 255, (1,), UInt8)
Box(UInt8[0x00], UInt8[0xff], (1,), UInt8)

julia> sample(box1)
1-element Array{Float32,1}:
 168.51285

julia> sample(box2)
1-element Array{UInt8,1}:
 0x7d

julia> box1 == box2
true    # <--- This should be false!!

Maybe we should make Box(0, 255, (1,), UInt8) != Box(0, 255, (1,), UInt16) and Box(0, 255, (1,), UInt8) != Box(0, 255, (1,), Int8) as the return data type may cause typeistability down the line.

kraftpunk97-zz commented 5 years ago

Good point. While I agree with Box(0, 255, (1,), UInt8) != Box(0, 255, (1,), Int8), I'm not so sure about Box(0, 255, (1,), UInt8) != Box(0, 255, (1,), UInt16). I mean (and I may be completely wrong about this), a sample(Box(0, 255, (1,), UInt8)) in Box(0, 255, (1,), UInt16) should always be true, and vice versa. That should make Box(0, 255, (1,), UInt8) == Box(0, 255, (1,), UInt16) imo. But I'd defer to you and @tejank10, because I may be out of my depth here.