Skip to content

Commit

Permalink
Add basic hint to Crossword for stuck checking
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Nov 14, 2024
1 parent 0135e38 commit b6454ce
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pysollib/games/crossword.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from pysollib.game import Game
from pysollib.gamedb import GI, GameInfo, registerGame
from pysollib.hint import AbstractHint
from pysollib.layout import Layout
from pysollib.stack import \
OpenTalonStack, \
Expand All @@ -36,6 +37,20 @@
# ************************************************************************


class Crossword_Hint(AbstractHint):

def computeHints(self):
game = self.game
rows = game.s.rows
for i in range(len(rows)):
r = rows[i]
if r.cards:
continue
if game.isValidPlay(r.id, game.s.talon.getCard().rank + 1):
# TODO: Check a few moves ahead to get better hints.
self.addHint(5000, 1, game.s.talon, r)


class Crossword_RowStack(ReserveStack):
def clickHandler(self, event):
if (not self.cards and self.game.s.talon.cards and
Expand Down Expand Up @@ -85,7 +100,7 @@ class Crossword(Game):
Talon_Class = OpenTalonStack
RowStack_Class = StackWrapper(Crossword_RowStack, max_move=0)
FinalCards_Class = StackWrapper(Crossword_FinalCard, max_move=0)
Hint_Class = None
Hint_Class = Crossword_Hint

#
# game layout
Expand Down

0 comments on commit b6454ce

Please sign in to comment.