【发布时间】:2020-12-20 15:10:19
【问题描述】:
我正在评估国际象棋位置,实施并不真正相关。我已插入打印检查以查看我可以修剪多少条路径,但没有打印任何内容,这意味着我并没有真正修剪任何东西。
我已经理解了算法,并且完全按照伪代码进行了操作。有人知道出了什么问题吗?
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, alpha,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, self.alphabeta(child,depth-1,True, alpha,beta))
beta = min(beta,value)
if(beta <= alpha):
print("Pruned black")
break
return value
【问题讨论】:
标签: python artificial-intelligence chess pruning