Skip to content

Commit

Permalink
Use speed instead of speed_index in merge env
Browse files Browse the repository at this point in the history
Fix #519
  • Loading branch information
eleurent authored Oct 14, 2023
1 parent 86320a3 commit 085f8c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion highway_env/envs/merge_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def default_config(cls) -> dict:
"collision_reward": -1,
"right_lane_reward": 0.1,
"high_speed_reward": 0.2,
"reward_speed_range": [20, 30],
"merging_speed_reward": -0.5,
"lane_change_reward": -0.05,
})
Expand All @@ -48,10 +49,11 @@ def _reward(self, action: int) -> float:
[0, 1])

def _rewards(self, action: int) -> Dict[Text, float]:
scaled_speed = utils.lmap(self.vehicle.speed, self.config["reward_speed_range"], [0, 1])
return {
"collision_reward": self.vehicle.crashed,
"right_lane_reward": self.vehicle.lane_index[2] / 1,
"high_speed_reward": self.vehicle.speed_index / (self.vehicle.target_speeds.size - 1),
"high_speed_reward": scaled_speed,
"lane_change_reward": action in [0, 2],
"merging_speed_reward": sum( # Altruistic penalty
(vehicle.target_speed - vehicle.speed) / vehicle.target_speed
Expand Down

0 comments on commit 085f8c8

Please sign in to comment.