def get_dist(veh, lead):
    """Calculates distance from veh to the front of lead."""
    dist = lead.pos-veh.pos
    if veh.road != lead.road:
        dist += veh.lane.roadlen[lead.road]  # lead.road is hashable because its a string
    return dist