Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Use forward speed rather than speed in highway-v0 reward calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
eleurent committed Feb 18, 2022
1 parent c80e2a2 commit 1a04c6a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion highway_env/envs/highway_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def _reward(self, action: Action) -> float:
neighbours = self.road.network.all_side_lanes(self.vehicle.lane_index)
lane = self.vehicle.target_lane_index[2] if isinstance(self.vehicle, ControlledVehicle) \
else self.vehicle.lane_index[2]
scaled_speed = utils.lmap(self.vehicle.speed, self.config["reward_speed_range"], [0, 1])
# Use forward speed rather than speed, see https://github.com/eleurent/highway-env/issues/268
forward_speed = self.vehicle.speed * np.cos(self.vehicle.heading)
scaled_speed = utils.lmap(forward_speed, self.config["reward_speed_range"], [0, 1])
reward = \
+ self.config["collision_reward"] * self.vehicle.crashed \
+ self.config["right_lane_reward"] * lane / max(len(neighbours) - 1, 1) \
Expand Down

0 comments on commit 1a04c6a

Please sign in to comment.