After expanding all the children of B
, then A
has α=-4, β=∞
.
When you get to I
, then α=-4, β=-3
. α < β
so J
and K
are not pruned. They would need to be evaluated to make sure that they're not less than -3, lowering the evaluation of C
. The value of A
is updated to α=-3, β=∞
after C
is expanded. You can't use the updated alpha value of A
when evaluating J
because it wouldn't have been updated yet.
J
and K
would be pruned if I
was -5 instead. In that case it wouldn't matter what J
and K
are because we already know the evaluation of C
is worse than B
because -5 < -4
, and J
and K
can only make that worse.
Each node passes the alpha and beta values to its children. The children will then update their own copies of the alpha or beta value depending on whose turn it is and return the final evaluation of that node. That is then used to update the alpha or beta value of the parent.
See Alpha-Beta pruning for example:
function alphabeta(node, depth, α, β, Player)
if depth = 0 or node is a terminal node
return the heuristic value of node
if Player = MaxPlayer
for each child of node
α := max(α, alphabeta(child, depth-1, α, β, not(Player)))
if β ≤ α
break // Beta cut-off
return α
else
for each child of node
β := min(β, alphabeta(child, depth-1, α, β, not(Player)))
if β ≤ α
break // Alpha cut-off
return β
// Initial call
alphabeta(origin, depth, -infinity, +infinity, MaxPlayer)