Skip to content

Commit

Permalink
added back 0 reward if off road to reproduce previous behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
JingfeiPeng committed Apr 29, 2021
1 parent 9bb7ebd commit b55d5b2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/game_of_tag/tag_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ def predator_reward_adapter(observations, env_reward_signal):
if events.off_road:
rew -= global_rewards.offroad

# print(f"predator {ego.id.split('-')[0]} reward: {rew} distance {distance_to_target}, laneIndex: {ego.lane_index}")
return rew
# if no prey vehicle avaliable, have 0 reward instead
# TODO: Test to see if this is neccessary
prey_vehicles = list(filter(
lambda v: _is_vehicle_wanted(v.id, PREY_IDS), observations.neighborhood_vehicle_states,
))
return rew if len(prey_vehicles) > 0 else 0


def prey_reward_adapter(observations, env_reward_signal):
Expand Down Expand Up @@ -212,4 +216,9 @@ def prey_reward_adapter(observations, env_reward_signal):
if events.off_road:
rew -= global_rewards.offroad

return rew
# if no predator vehicle avaliable, have 0 reward instead
# TODO: Test to see if this is neccessary
predator_vehicles = list(filter(
lambda v: _is_vehicle_wanted(v.id, PREDATOR_IDS), observations.neighborhood_vehicle_states,
))
return rew if len(predator_vehicles) > 0 else 0

0 comments on commit b55d5b2

Please sign in to comment.