sorted_ids = np.array(self.ids)[sorted_indx]
sorted_rl_cars = np.array([0] * len(sorted_ids))
sorted_rl_cars[:len(self.rl_ids)] = np.sort([self.vehicles[veh_id]["absolute_position"]
for veh_id in self.rl_ids])
state = np.array([[self.vehicles[veh_id]["speed"],
self.vehicles[veh_id]["lane"],
self.vehicles[veh_id]["absolute_position"]] for veh_id in sorted_ids]).T
// state = np.vstack((state, sorted_rl_cars))
return state
else:
return np.array([[self.vehicles[veh_id]["speed"],
self.vehicles[veh_id]["lane"],
self.vehicles[veh_id]["absolute_position"]] for veh_id in self.ids]).T
After Change
sorted_indx = np.argsort([self.vehicles[veh_id]["absolute_position"] for veh_id in self.ids])
sorted_ids = np.array(self.ids)[sorted_indx]
return np.array([[self.vehicles[veh_id]["speed"] + normal(0, kwargs["observation_vel_std"]),
self.vehicles[veh_id]["absolute_position"] + normal(0, kwargs["observation_pos_std"]),
self.vehicles[veh_id]["lane"]] for veh_id in sorted_ids]).T