Skip to content

Commit

Permalink
[printer] Functions accept states
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 19, 2024
1 parent a00414d commit 485f4b1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions solve/printer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from collections import defaultdict, deque
from collections.abc import Sequence

from .players import AliasMappingType
from .states import DissectMove, PassMove
from .states import StateOfAllRooms, StateOfAllStatues


def print_pass_moves(
state: StateOfAllRooms,
aliases: AliasMappingType,
moves: Sequence[PassMove],
/,
interactive: bool,
) -> None:
Expand All @@ -16,7 +15,7 @@ def print_pass_moves(
If ``interactive`` is ``True``, prompts the user before continuing.
"""
position2collect = defaultdict(deque)
for m in moves:
for m in state.moves_made:
position2collect[m.departure].appendleft(m.shape)

initial_msg = ', '.join(
Expand All @@ -27,7 +26,7 @@ def print_pass_moves(
print_move = input if interactive else print
print('--- STEPS IN SOLO ROOMS ---')
print_move(initial_msg)
for m in moves:
for m in state.moves_made:
print_move(
f'Player {aliases[m.departure]}: '
f'pass {m.shape} to {m.destination}'
Expand All @@ -41,26 +40,26 @@ def print_pass_moves(
'All player in the solo rooms must collect two shapes and wait\n'
'Proceed with dissection\n'
'--- LAST POSITION ---\n'
f'{moves[-1].destination}'
f'{state.last_position}'
)


def print_dissect_moves(moves: Sequence[DissectMove], /, interactive: bool) -> None:
def print_dissect_moves(state: StateOfAllStatues, /, interactive: bool) -> None:
"""
Prints dissect moves to the console.
If ``interactive`` is ``True``, prompts the user before continuing.
"""
print_move = input if interactive else print

print('--- STEPS FOR DISSECTION ---')
for m in moves:
for m in state.moves_made:
print_move(f'Dissect {m.shape} from {m.destination}')

print(
'--- DISSECTION IS DONE ---\n'
'All players in the solo rooms must leave them\n'
'--- LAST POSITION ---\n'
f'{moves[-1].destination}'
f'{state.last_position}'
)


Expand Down

0 comments on commit 485f4b1

Please sign in to comment.