def potential(r, r_c, r_e, r_a):
    """Potential (Eq. 4)
    Args:
        r: distance between agent i and j
        r_c: hard-core repulsion distance
        r_e: equilibrium (preferred) distance
        r_a: maximum interaction range
    Returns:
        potential: attractive/repulsive potential
    """
    if r < r_c:
        return -1  # should be -inf
    elif r < r_a:
        return 0.25 * (r - r_e) / (r_a - r_c)
    else:
        return 1