Negamax总是应该返回一个正值?

问题描述:

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总是应该返回一个正值?

negamax(origin, depth, -inf, +inf, 1) 

然后,将这个函数总是返回正值,无论我们称之为深度功能与。这是假设启发式价值本身总是正面的。

是的,如果叶子节点的评价分数是正值,则negamax将返回正值。这就是颜色值乘法的成就,它确保了如果存在奇数个递归negamax调用,总会有反向否定来反转最终的否定。这是因为在递归调用次数为奇数时,颜色始终为-1。如果存在偶数次递归调用,则所有的否定将被抵消,并且颜色将为1,这将使返回值不受影响。

请注意,如果您使用颜色== -1调用negamax(这是另一方轮流移动),您必须否定该调用才能获得正确的值。那就是:

-negamax(origin, depth, -inf, +inf, -1)