I'm evaluating chess positions, the implementation isn't really relevant. I've inserted print checks to see how many paths I'm able to prune, but nothing is printed, meaning I don't really prune anything.
I've understood the algorithm and followed the pseudo-code to the letter. Anyone has any idea on what's going wrong?
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