As I understand, when implementing iterative deepening the best move at one depth should be used for ordering moves at higher depths. I have one issue with this: say I got the move m
as my best move at the depth n
, then when searching at the depth n + 1
should the move orderer only prioritize m
at the highest level of search or at every level where move m
is legal?
My current implementation of iterative deepening:
Search:
pvLine = None
for depth in range(1, self.maxDepth):
self.auxSearch(board, depth, initalHash)
# find the principal variation from the TT
pvLine = self.getPVLine(board, initalHash)
bestMove = pvLine[0][0]
bestValue = pvLine[0][1]
self.ordering.setBestMove(bestMove, depth + 1)
print(f'{depth=} | {bestValue=} | {bestMove=} | {pvLine=}')
return pvLine
Move ordering:
if((move, depth) == self.bestMove):
priority += self.BESTMOVE_BONUS
setBestMove function:
def setBestMove(self, move: chess.Move, depth: int) -> None:
self.bestMove = (move, depth)
self.BESTMOVE_BONUS
is a very big number, so the move will have the highest priority.
Currently, I am making sure that the move orderer only prioritizes the best move from previous shallower search at the highest level of the current search. I am not sure if my approach is correct or not?