Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed Aug 10, 2023
1 parent da2308d commit c72734b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 85 deletions.
1 change: 0 additions & 1 deletion carl/envs/gymnasium/box2d/carl_bipedal_walker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import numpy as np
from Box2D.b2 import edgeShape, fixtureDef, polygonShape
from gymnasium.envs.box2d import bipedal_walker
from gymnasium.envs.box2d import bipedal_walker as bpw
Expand Down
1 change: 0 additions & 1 deletion carl/envs/gymnasium/box2d/carl_lunarlander.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import Box2D
from Box2D.b2 import vec2
from gymnasium.envs.box2d import lunar_lander
from gymnasium.envs.box2d.lunar_lander import LunarLander
Expand Down
1 change: 0 additions & 1 deletion carl/envs/gymnasium/box2d/carl_vehicle_racing.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,3 @@ def _update_context(self) -> None:
self.env: CustomCarRacing
vehicle_class_index = self.context["VEHICLE_ID"]
self.env.vehicle_class = PARKING_GARAGE[vehicle_class_index]
print(self.env.vehicle_class)
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 truncated or terminated:
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 truncated or terminated or restart or not isopen:
break
env.close()
2 changes: 1 addition & 1 deletion examples/demo_heuristic_bipedalwalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def demo_heuristic(env: CARLBipedalWalker | bipedal_walker.BipedalWalker) -> Non
CARLBipedalWalker.render_mode = "human"
env = CARLBipedalWalker(
# Play with leg height :)
contexts = {0: {"LEG_H": 4}}
contexts={0: {"LEG_H": 4}}
)
demo_heuristic(env)
env.close()
77 changes: 0 additions & 77 deletions examples/play_car_racing.py

This file was deleted.

0 comments on commit c72734b

Please sign in to comment.