diff --git a/src/environments/examples/CartPoleEnv.jl b/src/environments/examples/CartPoleEnv.jl index 4b4ded9..87f1e69 100644 --- a/src/environments/examples/CartPoleEnv.jl +++ b/src/environments/examples/CartPoleEnv.jl @@ -131,7 +131,8 @@ function plotendofepisode(x, y, d) end return nothing end -function Base.show(io::IO, m::MIME"image/png", env::CartPoleEnv) + +function GR.plot(env::CartPoleEnv) s, a, d = env.state, env.action, env.done x, xdot, theta, thetadot = s l = 2 * env.params.halflength @@ -146,6 +147,6 @@ function Base.show(io::IO, m::MIME"image/png", env::CartPoleEnv) setlinecolorind(2) drawarrow(x + (a == 1) - 0.5, -.025, x + 1.4 * (a == 1) - 0.7, -.025) plotendofepisode(xthreshold - 0.2, l, d) - p = updatews() - show(io, m, p) + updatews() + plot() end diff --git a/src/environments/examples/MountainCarEnv.jl b/src/environments/examples/MountainCarEnv.jl index 872d5a0..e100243 100644 --- a/src/environments/examples/MountainCarEnv.jl +++ b/src/environments/examples/MountainCarEnv.jl @@ -141,7 +141,7 @@ height(xs) = sin(3 * xs) * 0.45 + 0.55 rotate(xs, ys, θ) = xs * cos(θ) - ys * sin(θ), ys * cos(θ) + xs * sin(θ) translate(xs, ys, t) = xs .+ t[1], ys .+ t[2] -function Base.display(io::IO, m::MIME"image/png", env::MountainCarEnv) +function GR.plot(env::MountainCarEnv) s = env.state d = env.done clearws() @@ -167,6 +167,6 @@ function Base.display(io::IO, m::MIME"image/png", env::MountainCarEnv) xs, ys = translate(xs, ys, [x, height(x)]) fillarea(xs, ys) plotendofepisode(env.params.max_pos + 0.1, 0, d) - p = updatews() - show(io, m, p) + updatews() + plot() end