Python Value Iteration Algorithm