def policy_evaluation(V, current_policy,
                      env, gamma, small_change):
    """
    Perform policy evaluation iterations until the smallest change is less than
    `smallest_change`

    Args:
        V: the value function table
        current_policy: current policy
        env: the OpenAI Tax-v3 environment
        gamma: future reward coefficient
        small_change: how small should the change be for the iterations to stop

    Returns:
        V: the value function after convergence of the evaluation
    """
    state_size = env.observation_space.n

    while True:
        biggest_change = 0
        # loop through every state present
        for state in range(state_size):
            old_V = V[state]
            # take the action according to the current policy
            action = current_policy[state]
            prob, new_state, reward, done = env.env.P[state][action][0]
            # use the bellman optimality equation to update V(s)
            V[state] = reward + gamma * V[new_state]
            # if the biggest change is small enough then it means
            # the policy has converged, so stop.
            biggest_change = max(biggest_change, abs(V[state] - old_V))
        if biggest_change < small_change:
            break
    return V