From d2ada8734fe5aa5106d749c6e5e13ca057cc6bd7 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 20 Dec 2023 23:59:21 +0100 Subject: [PATCH] Fix problem when initial depth > max_depth In deepening function --- src/classes/Engines.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/classes/Engines.py b/src/classes/Engines.py index 6be23b4..338d48b 100644 --- a/src/classes/Engines.py +++ b/src/classes/Engines.py @@ -214,7 +214,6 @@ class MinmaxDeepeningPlayerEngine(MinmaxPlayerEngine): # Get an alarm signal to stop iterations signal.signal(signal.SIGALRM, self.alarm_handler) signal.alarm(self.options['time_limit']) - depth = self.options['depth'] heuristic = -math.inf move = None @@ -223,6 +222,11 @@ class MinmaxDeepeningPlayerEngine(MinmaxPlayerEngine): max_depth = (board.get_board_size()**2) - ( board.get_nb_pieces()[0] + board.get_nb_pieces()[1]) + depth = self.options['depth'] if self.options['depth'] <= max_depth else max_depth + + # Iterate depth while our alarm does not trigger and there is enougth + # avaiable move to play + # Iterate depth while our alarm does not trigger and there is enougth # avaiable move to play while not self.interrupt_search and depth <= max_depth: @@ -254,7 +258,6 @@ class AlphaBetaDeepeningPlayerEngine(AlphabetaPlayerEngine): # Get an alarm signal to stop iterations signal.signal(signal.SIGALRM, self.alarm_handler) signal.alarm(self.options['time_limit']) - depth = self.options['depth'] heuristic = -math.inf move = None @@ -263,6 +266,8 @@ class AlphaBetaDeepeningPlayerEngine(AlphabetaPlayerEngine): max_depth = (board.get_board_size()**2) - ( board.get_nb_pieces()[0] + board.get_nb_pieces()[1]) + depth = self.options['depth'] if self.options['depth'] <= max_depth else max_depth + # Iterate depth while our alarm does not trigger and there is enougth # avaiable move to play while not self.interrupt_search and depth <= max_depth: