add command-line flag to enable verbose printing to terminal
This commit is contained in:
parent
746b30dbeb
commit
2c874275db
2 changed files with 9 additions and 4 deletions
|
@ -51,7 +51,7 @@ def check_game(game_id: int) -> Tuple[int, GameState]:
|
|||
game = HanabLiveGameState(instance)
|
||||
solvable, solution = solve_sat(game)
|
||||
if not solvable:
|
||||
logger.debug("Returning: Instance {} is not feasible")
|
||||
logger.debug("Returning: Instance {} is not feasible.")
|
||||
return 0, solution
|
||||
logger.verbose("Instance {} is feasible after 0 turns: {}".format(game_id, link(solution)))
|
||||
|
||||
|
@ -61,16 +61,17 @@ def check_game(game_id: int) -> Tuple[int, GameState]:
|
|||
assert(len(try_game.actions) == solvable_turn)
|
||||
for a in range(solvable_turn, try_turn):
|
||||
try_game.make_action(actions[a])
|
||||
logger.debug("Checking if instance {} is feasible after {} turs".format(game_id, try_turn))
|
||||
logger.debug("Checking if instance {} is feasible after {} turns.".format(game_id, try_turn))
|
||||
solvable, potential_sol = solve_sat(try_game)
|
||||
if solvable:
|
||||
solution = potential_sol
|
||||
game = try_game
|
||||
solvable_turn = try_turn
|
||||
logger.verbose("Instance {} is feasible after {} turns: {}".format(game_id, solvable_turn, link(solution)))
|
||||
logger.verbose("Instance {} is feasible after {} turns: {}#{}"
|
||||
.format(game_id, solvable_turn, link(solution), solvable_turn + 1))
|
||||
else:
|
||||
unsolvable_turn = try_turn
|
||||
logger.verbose("Instance {} is not feasible after {} turns".format(game_id, unsolvable_turn))
|
||||
logger.verbose("Instance {} is not feasible after {} turns.".format(game_id, unsolvable_turn))
|
||||
|
||||
assert unsolvable_turn - 1 == solvable_turn, "Programming error"
|
||||
return unsolvable_turn, solution
|
||||
|
|
|
@ -58,6 +58,7 @@ def main_parser() -> argparse.ArgumentParser:
|
|||
prog='hanabi_suite',
|
||||
description='High-level interface for analysis of hanabi instances.'
|
||||
)
|
||||
parser.add_argument('--verbose', '-v', help='Enable verbose logging to console', action='store_true')
|
||||
subparsers = parser.add_subparsers(dest='command', required=True, help='select subcommand')
|
||||
|
||||
add_init_subparser(subparsers)
|
||||
|
@ -72,6 +73,9 @@ if __name__ == "__main__":
|
|||
switcher = {
|
||||
'analyze': analyze_game
|
||||
}
|
||||
if args.verbose:
|
||||
logger_manager.set_console_level(verboselogs.VERBOSE)
|
||||
method_args = dict(vars(args))
|
||||
method_args.pop('command')
|
||||
method_args.pop('verbose')
|
||||
switcher[args.command](**method_args)
|
||||
|
|
Loading…
Reference in a new issue