Explore Library
Code QuizAdvanced

Depth-Limited Minimax With Eval

Identify the missing check that ignores the search depth limit.

Codejavascript
function minimax(node, depth, isMax) {
  if (node.isTerminal) return node.utility;
  // evaluate when depth budget is exhausted
  const scores = node.children.map(c => minimax(c, depth - 1, !isMax));
  return isMax ? Math.max(...scores) : Math.min(...scores);
}

function evaluate(node) { return node.heuristic; }

What is the bug in this depth-limited search?