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

Commit b306a3b

Browse files
authored
MountainCarEnv: fix recipe (#34)
Fix #33
1 parent 22c7b98 commit b306a3b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/envs/mountain_car.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ end
8383
# ------------------------------------------------------------------------
8484
height(xs) = sin(3 * xs)*0.45 + 0.55
8585
rotate(xs::Array{Float64}, ys::Array{Float64}, Θ::Float64) =
86-
xs*cos(Θ) - ys*sin(Θ), ys*cos(Θ) + xs*sin(Θ)
86+
xs.*cos(Θ) .- ys.*sin(Θ), ys.*cos(Θ) .+ xs.*sin(Θ)
8787

8888
translate(xs::Array{Float64}, ys::Array{Float64}, t::Array{Float64}) =
89-
xs + t[1], ys + t[2]
89+
xs .+ t[1], ys .+ t[2]
9090

9191
@recipe function f(env::MountainCar)
9292
legend := false
@@ -97,8 +97,8 @@ translate(xs::Array{Float64}, ys::Array{Float64}, t::Array{Float64}) =
9797

9898
# Mountain
9999
@series begin
100-
xs = range(min_position, max_position, length=100)
101-
ys = height(xs)
100+
xs = range(min_position, stop = max_position, length = 100)
101+
ys = height.(xs)
102102
seriestype := :path
103103
linecolor --> :blue
104104
xs, ys
@@ -111,8 +111,7 @@ translate(xs::Array{Float64}, ys::Array{Float64}, t::Array{Float64}) =
111111

112112
θ = cos(3 * env.state.position)
113113
xs = [-car_width/2, -car_width/2, car_width/2, car_width/2]
114-
ys = [0, car_height, car_height, 0]
115-
ys += clearance
114+
ys = [0, car_height, car_height, 0] .+ clearance
116115
xs, ys = rotate(xs, ys, θ)
117116
translate(xs, ys, [env.state.position, height(env.state.position)])
118117
end

0 commit comments

Comments
 (0)