How would the basic alpha beta pruning algorithm would look like if a player has no legal moves and must pass its turn to its opponent? (if neither player had legal moves then the game finishes and the search shall return the payoff of the position)
Thanks in advance
Here’s the basic:
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)
the problem is that I’m not clear on how to recurse, by max or min if turn is same.
Carlos Briceño is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.