in my minimax function I have a first few lines looking something like this:
children = board.get_all_possible_moves(board) if depth = 0 or board.is_check_mate or board.is_draw: return None, evaluation(board)
The problem is that it takes time to calculate the children one "extra time" if the depth is 0 and the position is not draw or check mate. However, I want to know if the board state at depth 0 is check mate or draw.
As of now I detect check mate and draw by the following logic:
if not possible_moves: if board.is_check: board.is_check_mate = True else: board.is_draw = True
Is there a better way of finding whether a posisiton is check mate or not? Without having to calculate the opponents possible moves first, to save time in the minimax recursive function. Thank you in advance.