关于不同的主要变体搜索实现的问题

问题描述

维基百科的 PVS 伪代码是:

function pvs(node,depth,α,β,color) is
    if depth = 0 or node is a terminal node then
        return color × the heuristic value of node
    for each child of node do
        if child is first child then
            score := −pvs(child,depth − 1,−β,−α,−color)
        else
            score := −pvs(child,−α − 1,−color) (* search with a null window *)
            if α < score < β then
                score := −pvs(child,−score,−color) (* if it Failed high,do a full re-search *)
        α := max(α,score)
        if α ≥ β then
            break (* beta cut-off *)
    return α

然而 chessprogramming.org pseudocode

int pvSearch( int alpha,int beta,int depth ) {
   if( depth == 0 ) return quiesce( alpha,beta );
   bool bSearchPv = true;
   for ( all moves)  {
      make
      if ( bSearchPv ) {
         score = -pvSearch(-beta,-alpha,depth - 1);
      } else {
         score = -pvSearch(-alpha-1,depth - 1);
         if ( score > alpha ) // in fail-soft ... && score < beta ) is common
            score = -pvSearch(-beta,depth - 1); // re-search
      }
      unmake
      if( score >= beta )
         return beta;   // fail-hard beta-cutoff
      if( score > alpha ) {
         alpha = score; // alpha acts like max in MiniMax
         bSearchPv = false;  // *1)
      }
   }
   return alpha; // fail-hard
}

这里有两个明显的差异,我试图理解它们的含义及其影响。

首先,第一个代码将简单地搜索一个移动,然后将使用空窗口尝试之后的每个移动。但是,第二个代码仅在找到带有 bSearchPv 的移动时才将 false 设置为 score>alpha,因此如果搜索的第一个移动未触发此操作,则也将自动完全搜索下一步。

第二个区别在于递归调用函数时传递的参数,比较行score := −pvs(child,−color)score = -pvSearch(-beta,depth - 1); // re-search。在第一个中,我们将 -score 作为 beta 传递,而在第二个中,我们传递 -alpha

这两个实现是否“正确”,因为它们总是为给定位置返回相同的结果?如果是这样,我猜测差异是出于效率原因,即会遍历更多节点。是否存在 PVS 的“规范”实现,因为我猜这些差异一定只是主观问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)