From a478b755f1a104eca91379108e57f84be96c7550 Mon Sep 17 00:00:00 2001 From: Karol Brejna Date: Tue, 8 Jun 2021 11:53:34 +0200 Subject: [PATCH] Fix resolving --strict value --- main.py | 1 + modules/puzzle/position_list.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 930d059..6451810 100755 --- a/main.py +++ b/main.py @@ -31,6 +31,7 @@ def prepare_settings(): parser.add_argument("--games", metavar="GAMES", default="games.pgn", help="A specific pgn with games") parser.add_argument("--strict", metavar="STRICT", default=True, + type=str2bool, const=True, nargs="?", help="If False then it will be generate more tactics but maybe a little ambiguous") parser.add_argument("--includeBlunder", metavar="INCLUDE_BLUNDER", default=True, type=str2bool, const=True, dest="include_blunder", nargs="?", diff --git a/modules/puzzle/position_list.py b/modules/puzzle/position_list.py index ad3582b..a622c2b 100644 --- a/modules/puzzle/position_list.py +++ b/modules/puzzle/position_list.py @@ -130,13 +130,14 @@ def is_complete(self, category, color, first_node, first_val): return False def ambiguous(self): - # If strict == False then it will generate more tactics but more ambiguous + # If strict == False then it will generate more tactics but more ambiguous move_number = 1 if self.strict else 2 if len(self.analysed_legals) > 1: if (self.analysed_legals[0].evaluation.cp is not None and self.analysed_legals[1].evaluation.cp is not None): if (self.analysed_legals[0].evaluation.cp > -210 - or self.analysed_legals[move_number].evaluation.cp < -90): + or (len(self.analysed_legals) >= move_number + and self.analysed_legals[move_number].evaluation.cp < -90)): return True if (self.analysed_legals[0].evaluation.mate is not None and self.analysed_legals[1].evaluation.mate is not None):