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

Commit

Permalink
I still can't figure out how to display them... (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
findmyway authored Dec 25, 2020
1 parent e6f5075 commit fa87a29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/environments/examples/CartPoleEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions src/environments/examples/MountainCarEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

0 comments on commit fa87a29

Please sign in to comment.