def tearDownClass(self): AnalysisEngine.quit()
game = chess.pgn.read_game(pgn) if game == None: exit(0) game_id += 1 log(Color.DIM, AnalysisEngine.name()) while True: game = chess.pgn.read_game(pgn) if game == None: break log(Color.MAGENTA, "\nGame index: %d" % game_id) log(Color.DARK_BLUE, str(game)) puzzles = find_puzzle_candidates(game, scan_depth=settings.scan_depth) n = len(puzzles) log(Color.YELLOW, "# positions to consider: %d" % n) if settings.scan_only: continue for i, puzzle in enumerate(puzzles): log(Color.MAGENTA, "\nConsidering position %d of %d..." % (i + 1, n)) puzzle.generate(settings.search_depth) if puzzle.is_complete(): print_puzzle_pgn(puzzle, pgn_headers=game.headers) n_puzzles += 1 game_id += 1 n_positions += n log( Color.MAGENTA, "\nGenerated %d puzzles from %d positions in %d games" % (n_puzzles, n_positions, game_id)) AnalysisEngine.quit()