Fail-softalpha-beta

xiaoxiao2021-02-28  58

alphabeta(depth,alpha,beta),如果一开始就将alpha,beta限定得较小,那么整个搜索过程将减去更多的枝条。

但是,可能得到3种结果,一种是要找目标就落在alpha,beta的范围之内,这样花费了很少的时间就得到结果,还有两种情况就那么幸运了,要找的值要么比alpha小,或者比beta大.

int  FAlpah(int depth,int alpha,int beta)

{

    int current =-INFINITY;   //current=负无穷

     if(game over or depth <=0)   //游戏是否结束

         return eval();    //返回估值

     if(depth <=0)   //是否是叶子节点

          return eval();   //返回估值

     for(each  possible move m)  //对所有可能的走法

     {

             make move m;   //产生子节点

             score =-FAlpahBeta(depth-1,-beta,-alpha)  //递归搜索新节点

             unmake move m;   //恢复当前局面

                        if(score >current)

                         {

                                      current =score;   //保留极大值

                                      if(score >=alpha)

                                                 alpha=score;  //修改alpha边界

                                        if(score>=beta)

                                                     break;  //beta剪枝

                         }

    }

       return current;  //返回最佳值或是边界

}

转载请注明原文地址: https://www.6miu.com/read-600011.html

最新回复(0)