USE THIS INSTEAD OF GET_ACTION for computing the actual controls.
Prevents crashes.
return min(self.get_action(env), self.safe_velocity(env))
def safe_velocity(self, env):
Finds maximum velocity such that if the lead vehicle breaks
with max acceleration, we can bring the following vehicle to rest
After Change
if this_vel + self.get_action(env)*time_step > safe_velocity:
return (safe_velocity - this_vel)/time_step
else:
return self.get_action(env)
def safe_velocity(self, env):
Finds maximum velocity such that if the lead vehicle breaks