Skip to content

Commit

Permalink
[printer] Print collect move when shapes available
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 20, 2024
1 parent 3585d10 commit 2ce3b42
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion solve/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def print_pass_moves(
print('--- FINAL SHAPES FROM LEFT TO RIGHT ---')
print(state.left.current_key, state.middle.current_key, state.right.current_key)

check_destination = set()
position2collect = defaultdict(deque)
for m in state.moves_made:
position2collect[m.departure].appendleft(m.shape)
Expand All @@ -34,9 +35,18 @@ def print_pass_moves(
f'Player {aliases[m.departure]}: '
f'pass {m.shape} to {m.destination}'
)

shapes = position2collect[m.departure]
if shapes:
print_move(f'Player {aliases[m.departure]}: collect {shapes.pop()}')
if shapes[-1] in m.departure_state:
print_move(f'Player {aliases[m.departure]}: collect {shapes.pop()}')
else:
check_destination.add(m.departure)

if m.destination in check_destination:
shapes = position2collect[m.destination]
print_move(f'Player {aliases[m.destination]}: collect {shapes.pop()}')
check_destination.remove(m.destination)

print(
'--- SOLO ROOMS ARE DONE ---\n'
Expand Down

0 comments on commit 2ce3b42

Please sign in to comment.