aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2025-02-18 22:48:30 +0100
committerTimo Wilken2025-02-18 22:48:30 +0100
commit453fba86293865e2145a1989696be67db043e26a (patch)
treeb562f556b5533adaeffb862138f7a93fd1cdf3bb
parentd0d8bfee98e34a804fb8c86061b7a44ce4f3909c (diff)
Simplify autocollect functionHEADmaster
-rw-r--r--src/szio_solitaire/solver.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/szio_solitaire/solver.py b/src/szio_solitaire/solver.py
index f43fb1e..a794e98 100644
--- a/src/szio_solitaire/solver.py
+++ b/src/szio_solitaire/solver.py
@@ -167,14 +167,11 @@ def autocollect_1(game: Game) -> Iterable[Move]:
def autocollect(game: Game) -> None:
'''Discard any discardable cards evenly in place, ignoring dragons.'''
- done = False
# Keep discarding until we can't any more. This behaviour is needed in case
# discarding a card means another one can then be discarded.
- while not done:
- done = True # Quit once we have nothing more to do.
- for ac_move in autocollect_1(game):
+ while (moves := tuple(autocollect_1(game))):
+ for ac_move in moves:
make_move(game, ac_move)
- done = False # If we're still doing something, don't quit yet.
def game_is_solved(game: Game) -> bool: