prolog alpha-beta意外结果

问题描述

我将一本书的通用alpha-beta修改为受深度限制。当打印出最佳位置搜索结果时,它有时会起作用,有时我会得到讨厌的结果,例如数字8。

这是“人工智能的序言”中非常通用的alpha-beta。我正试图缩小问题的范围,以解决alpha-beta还是代码中的其他问题。

有人可以告诉我这个深度受限的alpha-beta是否可以吗?

代码如下:

alphabeta(Pos,Alpha,Beta,GoodPos,Val,Depth):-
   Depth > 0,moves(Pos,PosList),!,boundedbest(PosList,Depth);
   get_pos_value(Pos,Val).                              % static value of position

boundedbest([Pos | PosList],GoodVal,Depth):-
   NewDepth is Depth - 1,alphabeta(Pos,_,NewDepth),goodenough(PosList,Pos,Depth).

goodenough([],_):- !.                % no other candidate

goodenough(_,_) :-
   min_to_move(Pos),Val > Beta,!;                 % Maximizer attainded upper bound
   max_to_move(Pos),Val < Alpha,!.                 % Minimizer attained lower bound

goodenough(PosList,Depth):-
   newbounds(Alpha,NewAlpha,NewBeta),% refine bounds
   boundedbest(PosList,NewBeta,Pos1,Val1,Depth),betterof(Pos,GoodVal).

newbounds(Alpha,Beta):-
   min_to_move(Pos),Val > Alpha,!.                    % Maximizer increased lower bound

newbounds(Alpha,Val):-
   max_to_move(Pos),Val < Beta,!.                 % Minimizer decreased upper bound

newbounds(Alpha,Beta).             % otherwise bounds unchanged

betterof(Pos,Val):-               % Pos better than Pos1
   min_to_move(Pos),Val > Val1,!;
   max_to_move(Pos),Val < Val1,!.

betterof(_,Val1).                      % Otherwise Pos1 better

解决方法

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

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

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