Closed
Description
Haven't found any docs about this.
Can't figure how to use the following code in src/environments/3rd_party/atari.jl:
imshowgrey(x::AbstractArray{UInt8,2}) = imshowgrey(reshape(x, :), size(x))
imshowgrey(x::AbstractArray{UInt8,1}, dims) = imshow(reshape(x, dims), colormap = 2)
imshowcolor(x::AbstractArray{UInt8,3}) = imshowcolor(reshape(x, :), size(x))
function imshowcolor(x::AbstractArray{UInt8,1}, dims)
clearws()
setviewport(0, dims[1] / dims[2], 0, 1)
setwindow(0, 1, 0, 1)
y = (zeros(UInt32, dims...) .+ 0xff) .<< 24
img = UInt32.(x)
@simd for i in 1:length(y)
@inbounds y[i] += img[3*(i-1)+1] + img[3*(i-1)+2] << 8 + img[3*i] << 16
end
drawimage(0, 1, 0, 1, dims..., y)
updatews()
end
function Base.show(io::IO, m::MIME"image/png", env::AtariEnv)
x = getScreenRGB(env.ale)
p = imshowcolor(x, (Int(getScreenWidth(env.ale)), Int(getScreenHeight(env.ale))))
show(io, m, p)
end
Base.show(io::IO, t::MIME"text/plain", env::AbstractEnv) = show(
IOContext(io, :is_show_state => false, :is_show_state_space => false),
MIME"text/markdown"(),
env,
)
Any help will be appreciated.
I suggested having a simple plot function like there is for MountainCar and CartPole:
using Images
using Plots
Plots.plot(env::AtariEnv) = plot(colorview(RGB{N0f8}, reshape(getScreenRGB(env.ale), (3, 160, 210)))', xlims=(0,160), ylims=(0, 210), border=:none, legend=false)
This works seamlessly. I can make a pull request.
Metadata
Metadata
Assignees
Labels
No labels