Skip to content

Commit b55d5b2

Browse files
committed
added back 0 reward if off road to reproduce previous behaviour
1 parent 9bb7ebd commit b55d5b2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

examples/game_of_tag/tag_adapters.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,12 @@ def predator_reward_adapter(observations, env_reward_signal):
179179
if events.off_road:
180180
rew -= global_rewards.offroad
181181

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

185189

186190
def prey_reward_adapter(observations, env_reward_signal):
@@ -212,4 +216,9 @@ def prey_reward_adapter(observations, env_reward_signal):
212216
if events.off_road:
213217
rew -= global_rewards.offroad
214218

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

0 commit comments

Comments
 (0)