Skip to content

Commit

Permalink
Merge pull request #596 from Farama-Foundation/bugfix-593
Browse files Browse the repository at this point in the history
Set one goal per controlled vehicle in ParkingEnv
  • Loading branch information
eleurent committed Apr 27, 2024
2 parents af23919 + 7ea8523 commit 7415379
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion highway_env/envs/common/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ def observe(self) -> Dict[str, np.ndarray]:
pd.DataFrame.from_records([self.observer_vehicle.to_dict()])[self.features]
)
goal = np.ravel(
pd.DataFrame.from_records([self.env.goal.to_dict()])[self.features]
pd.DataFrame.from_records([self.observer_vehicle.goal.to_dict()])[
self.features
]
)
obs = OrderedDict(
[
Expand Down
15 changes: 8 additions & 7 deletions highway_env/envs/parking_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ def _create_vehicles(self) -> None:
empty_spots.remove(vehicle.lane_index)

# Goal
lane_index = empty_spots[self.np_random.choice(np.arange(len(empty_spots)))]
lane = self.road.network.get_lane(lane_index)
self.goal = Landmark(
self.road, lane.position(lane.length / 2, 0), heading=lane.heading
)
self.road.objects.append(self.goal)
empty_spots.remove(lane_index)
for vehicle in self.controlled_vehicles:
lane_index = empty_spots[self.np_random.choice(np.arange(len(empty_spots)))]
lane = self.road.network.get_lane(lane_index)
vehicle.goal = Landmark(
self.road, lane.position(lane.length / 2, 0), heading=lane.heading
)
self.road.objects.append(vehicle.goal)
empty_spots.remove(lane_index)

# Other vehicles
for i in range(self.config["vehicles_count"]):
Expand Down

0 comments on commit 7415379

Please sign in to comment.