From 31e2469d84f10e5e0e81a2d56aab38d70c51cf7d Mon Sep 17 00:00:00 2001 From: Prometheus3375 <35541026+Prometheus3375@users.noreply.github.com> Date: Wed, 17 Jul 2024 06:45:27 +0300 Subject: [PATCH] [printer] Print shape collecting in solo rooms --- solve/printer.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/solve/printer.py b/solve/printer.py index be98022..989c920 100644 --- a/solve/printer.py +++ b/solve/printer.py @@ -13,14 +13,34 @@ def print_pass_moves( Prints pass moves to the console. If ``interactive`` is ``True``, prompts the user before continuing. """ - print('--- STEPS IN SOLO ROOMS ---') + # Solo rooms must always be solvable in 6 passes. + # This assertion is required for correct filling of dicts + # initial_collect and final_collect. + assert len(moves) == 6, f'expected 6 moves for solo rooms, got {len(moves)}' + initial_collect = {} + final_collect = {} + for m in moves: + if m.departure in initial_collect: + final_collect[m.departure] = m.shape + else: + initial_collect[m.departure] = m.shape + + initial_msg = ', '.join( + f'Player {aliases[position]} collects {shape}' + for position, shape in initial_collect.items() + ) print_move = input if interactive else print + print('--- STEPS IN SOLO ROOMS ---') + print_move(initial_msg) for m in moves: print_move( - f'Player {aliases[m.departure]} ({m.departure}): ' + f'Player {aliases[m.departure]}: ' f'pass {m.shape} to {m.destination}' ) + shape = final_collect.pop(m.departure, None) + if shape: + print_move(f'Player {aliases[m.departure]}: collect {shape}') print( '--- SOLO ROOMS ARE DONE ---\n' @@ -36,9 +56,9 @@ def print_dissect_moves(moves: Sequence[DissectMove], /, interactive: bool) -> N Prints dissect moves to the console. If ``interactive`` is ``True``, prompts the user before continuing. """ - print('--- STEPS FOR DISSECTION ---') - print_move = input if interactive else print + + print('--- STEPS FOR DISSECTION ---') for m in moves: print_move(f'Dissect {m.shape} from {m.destination}')