Skip to content

Commit

Permalink
fixed snapping (#12) I think (will add tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed May 9, 2016
1 parent 62e7700 commit 06ba9c9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/no_crash_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,18 @@ function generate_sr(mdp::NoCrashMDP, s::MLState, a::MLAction, rng::AbstractRNG,
# note lane change is updated above

# check if a lane was crossed and snap back to it
if floor(yp) >= ceil(car.y)
yp = ceil(car.y)
end
if ceil(yp) <= floor(car.y)
yp = floor(car.y)
if isinteger(car.y)
# prevent a multi-lane change in a single timestep
if abs(yp-car.y) > 1.
yp = car.y + sign(dys[i])
end
else # car.y is not an integer
if floor(yp) >= ceil(car.y)
yp = ceil(car.y)
end
if ceil(yp) <= floor(car.y)
yp = floor(car.y)
end
end

# enforce max/min y position constraints
Expand Down

0 comments on commit 06ba9c9

Please sign in to comment.