Skip to content

Commit

Permalink
Add hint logic to account for multi-waste pile games (like Display or…
Browse files Browse the repository at this point in the history
… Rosamund's Bower)
  • Loading branch information
joeraz committed Dec 21, 2024
1 parent 180d3d5 commit abb9605
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pysollib/hint.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ def getHints(self, taken_hint=None):
if self.level >= 2:
if game.canDealCards():
self.addHint(self.SCORE_DEAL, 0, game.s.talon, None)
# A few games have multiple waste stacks. In these games,
# reserves are used for the waste stacks. This logic will
# handle for those games.
if (not game.canDealCards() and game.s.waste is not None and
len(game.s.waste.cards) > 0 and len(game.s.reserves) > 0):
max_cards = 0
reserve = None
for r in game.s.reserves:
if r.acceptsCards(game.s.waste, game.s.waste.cards):
if len(r.cards) < max_cards or reserve is None:
max_cards = len(r.cards)
reserve = r

if reserve is not None:
self.addHint(self.SCORE_DEAL, 1, game.s.waste, reserve)

return self._returnHints()

# subclass
Expand Down

0 comments on commit abb9605

Please sign in to comment.