Skip to content

Commit

Permalink
Fix carracing demo
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed Aug 10, 2023
1 parent 1834558 commit cfa6be5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/demo_carracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def register_input():
a[2] = 0

contexts = {i: {"VEHICLE_ID": i} for i in range(len(VEHICLE_NAMES))}
CARLVehicleRacing.render_mode = "human"
env = CARLVehicleRacing(contexts=contexts)

record_video = False
Expand All @@ -62,14 +63,14 @@ def register_input():
restart = False
while True:
register_input()
s, r, done, info = env.step(a)
s, r, truncated, terminated, info = env.step(a)
time.sleep(0.025)
total_reward += r
if steps % 200 == 0 or done:
if steps % 200 == 0 or terminated or truncated:
print("\naction " + str(["{:+0.2f}".format(x) for x in a]))
print("step {} total_reward {:+0.2f}".format(steps, total_reward))
steps += 1
isopen = env.render()
if done or restart or not isopen:
env.render()
if terminated or truncated or restart or not isopen:
break
env.close()

0 comments on commit cfa6be5

Please sign in to comment.