Skip to content

Commit 9a311a0

Browse files
authored
Division by zero error if ply_count is zero
When running the program, I sometimes ran into two different division by zero problems, caused by the fact that ply_count = 0. My solution is that the minimum of the division with ply_count is 1, so a division by zero is not possible. I suppose it would be better to ensure that ply_count never is zero, but I'm not sure how hard that is as I haven't really looked into the problem.
1 parent b0d1efe commit 9a311a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

annotator/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def get_pass2_budget(total_budget, pass1_budget):
540540

541541

542542
def get_time_per_move(pass_budget, ply_count):
543-
return float(pass_budget) / float(ply_count)
543+
return float(pass_budget) / float(max(ply_count, 1))
544544

545545

546546
def analyze_game(game, arg_gametime, enginepath, threads):
@@ -702,7 +702,7 @@ def analyze_game(game, arg_gametime, enginepath, threads):
702702
except ZeroDivisionError:
703703
logger.debug("No errors found on first pass!")
704704
# There were no mistakes in the game, so deeply analyze all the moves
705-
time_per_move = pass2_budget / ply_count
705+
time_per_move = pass2_budget / max(ply_count, 1)
706706
node = game.end()
707707
while not node == root_node:
708708
prev_node = node.parent

0 commit comments

Comments
 (0)