python中的Alpha-Beta剪枝算法不剪枝

问题描述

我正在评估国际象棋位置,实施并不真正相关。我插入了打印检查以查看我可以修剪多少条路径,但没有打印任何内容,这意味着我并没有真正修剪任何东西。

我已经理解了算法并遵循了伪代码。任何人都知道出了什么问题?

def alphabeta(self,node,depth,white,alpha,beta):
    ch = Chessgen()
    if(depth == 0 or self.is_end(node)):
        return self.stockfish_evaluation(node.board)


    if (white):
        value = Cp(-10000)
        for child in ch.chessgen(node):
            value = max(value,self.alphabeta(child,depth-1,False,beta))
            alpha = max(alpha,value)
            if (alpha >= beta):
                print("Pruned white")
                break
        return value

    else:
        value = Cp(10000)
        for child in ch.chessgen(node):
            value = min(value,True,beta))
            beta = min(beta,value)
            if(beta <= alpha):
                print("Pruned black")
                break
        return value

解决方法

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

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

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