def get_state(self):
    'See class definition.'
    obs = [0 for _ in range((((4 * self.num_rl) * self.num_lanes) + (2 * self.num_rl)))]
    self.visible = []
    self.update_veh_id()
    speeds = []
    for (i, rl_id) in enumerate(self.rl_veh):
        x = self.k.vehicle.get_x_by_id(rl_id)
        if (x == (- 1001)):
            continue
        speed = self.k.vehicle.get_speed(rl_id)
        obs[(((- 2) * i) - 1)] = speed
        speeds.append(speed)
        obs[(((- 2) * i) - 2)] = x
        max_length = self.k.network.length()
        max_speed = self.k.network.max_speed()
        headway = ([1] * self.num_lanes)
        tailway = ([1] * self.num_lanes)
        vel_in_front = ([0] * self.num_lanes)
        vel_behind = ([0] * self.num_lanes)
        lane_leaders = self.k.vehicle.get_lane_leaders(rl_id)
        lane_followers = self.k.vehicle.get_lane_followers(rl_id)
        lane_headways = self.k.vehicle.get_lane_headways(rl_id)
        lane_tailways = self.k.vehicle.get_lane_tailways(rl_id)
        headway[0:len(lane_headways)] = lane_headways
        tailway[0:len(lane_tailways)] = lane_tailways
        for (j, lane_leader) in enumerate(lane_leaders):
            if (lane_leader != ''):
                lane_headways[j] /= max_length
                vel_in_front[j] = (self.k.vehicle.get_speed(lane_leader) / max_speed)
                self.visible.extend([lane_leader])
        for (j, lane_follower) in enumerate(lane_followers):
            if (lane_follower != ''):
                lane_headways[j] /= max_length
                vel_behind[j] = (self.k.vehicle.get_speed(lane_follower) / max_speed)
                self.visible.extend([lane_follower])
        obs[((4 * self.num_lanes) * i):((4 * self.num_lanes) * (i + 1))] = np.concatenate((headway, tailway, vel_in_front, vel_behind))
    obs = np.array(obs)
    np.clip(obs, (- 1000), 3000, out=obs)
    return obs
See class definition.
def get_state(self):
    
    obs = [0 for _ in range((((4 * self.num_rl) * self.num_lanes) + (2 * self.num_rl)))]
    self.visible = []
    self.update_veh_id()
    speeds = []
    for (i, rl_id) in enumerate(self.rl_veh):
        x = self.k.vehicle.get_x_by_id(rl_id)
        if (x == (- 1001)):
            continue
        speed = self.k.vehicle.get_speed(rl_id)
        obs[(((- 2) * i) - 1)] = speed
        speeds.append(speed)
        obs[(((- 2) * i) - 2)] = x
        max_length = self.k.network.length()
        max_speed = self.k.network.max_speed()
        headway = ([1] * self.num_lanes)
        tailway = ([1] * self.num_lanes)
        vel_in_front = ([0] * self.num_lanes)
        vel_behind = ([0] * self.num_lanes)
        lane_leaders = self.k.vehicle.get_lane_leaders(rl_id)
        lane_followers = self.k.vehicle.get_lane_followers(rl_id)
        lane_headways = self.k.vehicle.get_lane_headways(rl_id)
        lane_tailways = self.k.vehicle.get_lane_tailways(rl_id)
        headway[0:len(lane_headways)] = lane_headways
        tailway[0:len(lane_tailways)] = lane_tailways
        for (j, lane_leader) in enumerate(lane_leaders):
            if (lane_leader != ):
                lane_headways[j] /= max_length
                vel_in_front[j] = (self.k.vehicle.get_speed(lane_leader) / max_speed)
                self.visible.extend([lane_leader])
        for (j, lane_follower) in enumerate(lane_followers):
            if (lane_follower != ):
                lane_headways[j] /= max_length
                vel_behind[j] = (self.k.vehicle.get_speed(lane_follower) / max_speed)
                self.visible.extend([lane_follower])
        obs[((4 * self.num_lanes) * i):((4 * self.num_lanes) * (i + 1))] = np.concatenate((headway, tailway, vel_in_front, vel_behind))
    obs = np.array(obs)
    np.clip(obs, (- 1000), 3000, out=obs)
    return obs