Explore Library
Code QuizIntermediate

Policy Evaluation Bug

Spot why this policy-evaluation step behaves like value iteration instead.

Codejavascript
function evaluatePolicy(policy, V, gamma) {
  for (let s = 0; s < states.length; s++) {
    let bestValue = -Infinity;
    for (const a of actions) {
      bestValue = Math.max(bestValue, reward(s, a) + gamma * V[nextState(s, a)]);
    }
    V[s] = bestValue;
  }
  return V;
}

This is supposed to evaluate a FIXED policy. What is the bug?