Fix problem when initial depth > max_depth
In deepening function
This commit is contained in:
parent
eb29f45de2
commit
d2ada8734f
1 changed files with 7 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue