Skip to content

Commit

Permalink
[printer] Print shape collecting in solo rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 17, 2024
1 parent b6efa13 commit 31e2469
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions solve/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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}')

Expand Down

0 comments on commit 31e2469

Please sign in to comment.