1 function alphabeta(node, depth, α, β, maximizingPlayer)
2 if depth = 0 or node is a terminal node
3 return the heuristic value of node
4 if maximizingPlayer
5 v := -∞
6 for each child of node
7 v := max(v, alphabeta(child, depth - 1, α, β, FALSE))
8 α := max(α, v)
9 if β ≤ α
10 break (* β cut-off *)
11 return v
12 else
13 v := ∞
14 for each child of node
15 v := min(v, alphabeta(child, depth - 1, α, β, TRUE))
16 β := min(β, v)
17 if β ≤ α
18 break (* α cut-off *)
19 return v
来自https://en.wikipedia.org/wiki/Alpha–beta_pruning![]()