1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Add basic hint to Crossword for stuck checking

This commit is contained in:
Joe R 2024-11-14 17:58:17 -05:00
parent 0135e386c2
commit b6454ce541

View file

@ -23,6 +23,7 @@
from pysollib.game import Game from pysollib.game import Game
from pysollib.gamedb import GI, GameInfo, registerGame from pysollib.gamedb import GI, GameInfo, registerGame
from pysollib.hint import AbstractHint
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.stack import \ from pysollib.stack import \
OpenTalonStack, \ OpenTalonStack, \
@ -36,6 +37,20 @@ from pysollib.stack import \
# ************************************************************************ # ************************************************************************
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): class Crossword_RowStack(ReserveStack):
def clickHandler(self, event): def clickHandler(self, event):
if (not self.cards and self.game.s.talon.cards and if (not self.cards and self.game.s.talon.cards and
@ -85,7 +100,7 @@ class Crossword(Game):
Talon_Class = OpenTalonStack Talon_Class = OpenTalonStack
RowStack_Class = StackWrapper(Crossword_RowStack, max_move=0) RowStack_Class = StackWrapper(Crossword_RowStack, max_move=0)
FinalCards_Class = StackWrapper(Crossword_FinalCard, max_move=0) FinalCards_Class = StackWrapper(Crossword_FinalCard, max_move=0)
Hint_Class = None Hint_Class = Crossword_Hint
# #
# game layout # game layout