From e019b29657a69c19121c6a145d065b7e23baf093 Mon Sep 17 00:00:00 2001 From: Marianne Chevrot Date: Sun, 17 May 2020 11:09:15 +0200 Subject: add a test to grid generator --- solver.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'solver.py') diff --git a/solver.py b/solver.py index 2132224..b42cbc4 100755 --- a/solver.py +++ b/solver.py @@ -354,6 +354,20 @@ def print_score_over(node, target_score): print_score_over(child, target_score) +def search_all_solution(args, kanagrid, target_score, max_actions): + grids = {} + generate_all_possible_grids(kanagrid, grids=grids, max_actions=max_actions) + for grid in grids.values(): + grid.update_score() + if grid.score >= target_score and grid.myst_count == 0: + print("="*80) + if args['-p']: + print(repr_grid_with_parents(grid)) + else: + print(grid) + return grid + + def main(): args = docopt.docopt(__doc__) @@ -371,18 +385,7 @@ def main(): if args['--print']: return - del input_dict - - grids = {} - generate_all_possible_grids(kanagrid, grids=grids, max_actions=max_actions) - for grid in grids.values(): - grid.update_score() - if grid.score >= target_score and grid.myst_count == 0: - print("="*80) - if args['-p']: - print(repr_grid_with_parents(grid)) - else: - print(grid) + search_all_solution(args, kanagrid, target_score, max_actions) if __name__ == '__main__': -- cgit v1.2.3