我在评估国际象棋的位置,其实并不重要。我插入了打印检查,以查看可以修剪多少条路径,但没有打印任何内容,这意味着我没有真正修剪任何内容
我已经理解了算法并严格遵循伪代码。有人知道出了什么问题吗
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
你的伪代码是什么? 我发现的那个代码有点不同:
由于我没有您的完整代码,因此无法运行:
一个完整的简单国际象棋程序可以在这里找到: https://andreasstckl.medium.com/writing-a-chess-program-in-one-day-30daff4610ec
相关问题 更多 >
编程相关推荐