def value_calc(stop, value=0.5):
    """returns a value between 0 and 1 based on an input value and a "stop"
    value (between 0 and 3) which corresponds to 2 equidistant points between
    value and zero, and 2 equidistant points between 0 and 1
    for example: input value 0.5

    stop    result
    0       0.16
    1       0.33
    2       0.66
    3       0.83
    """
    possible_stops = [0, 1, 2, 3]
    if not stop in possible_stops:
        return "error"
    if stop == 0:
        x = value / 3
        return value - 2 * x
    if stop == 1:
        x = value / 3
        return value - x
    if stop == 2:
        x = (1 - value) / 3
        return value + x
    if stop == 3:
        x = (1 - value) / 3
        return value + x * 2