function negamax(node, depth, α, β, color)
if node is a terminal node or depth = 0
return color * the heuristic value of node
else
foreach child of node
val := -negamax(child, depth-1, -β, -α, -color)
{the following if statement constitutes alpha-beta pruning}
if val≥β
return val
if val≥α
α:=val
return α
所以如果上面是我的 negamax 代码(从维基百科复制),它的调用如下:
negamax(origin, depth, -inf, +inf, 1)
那么,无论我们用什么深度调用这个函数,这个函数是否总是返回一个正值。这是假设启发式值本身始终为正。