def linear_force_fn(zero_intercept,
                    slope,
                    apply_distant_force=False,
                    apply_nearby_force=True):
    """Force is a linear function of distance.
    
    Args:
        zero_intercept: Scalar. Magnitude of force between sprites a distance
            zero apart.
        slope: Scalar. Slope of linear change in force with respect to distance.
        apply_distant_force: Bool. Whether to apply force at distances greater
            than the event horizon (distance at which the force is zero).
        apply_distant_force: Bool. Whether to apply force at distances less than
            the event horizon.

    Returns:
        force_fn: Function distance -> force magnitude.
    """
    event_horizon = -1. * zero_intercept / slope
    def force_fn(distance):
        force_magnitude = zero_intercept + slope * distance
        if not apply_distant_force and distance > event_horizon:
            force_magnitude = 0
        if not apply_nearby_force and distance < event_horizon:
            force_magnitude = 0
        return force_magnitude
    return force_fn