diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index f5123fcf..929757db 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -1110,7 +1110,7 @@ class Game(object): def leaveState(self, old_state): self.moves.state = old_state - def getSnapshot(self): + def getSnapshotHash(self): # generate hash (unique string) of current move sn = [] for stack in self.allstacks: @@ -1119,8 +1119,11 @@ class Game(object): s.append('%d%03d%d' % (card.suit, card.rank, card.face_up)) sn.append(''.join(s)) sn = '-'.join(sn) + return sn + + def getSnapshot(self): # optimisation - sn = hash(sn) + sn = hash(self.getSnapshotHash()) return sn def createSnGroups(self): diff --git a/pysollib/games/hitormiss.py b/pysollib/games/hitormiss.py index a147da39..ee6d97a0 100644 --- a/pysollib/games/hitormiss.py +++ b/pysollib/games/hitormiss.py @@ -154,6 +154,11 @@ class HitOrMiss(Game): # save vars (for undo/redo) return [self.rank, self.deadDeals] + def getSnapshotHash(self): + # Takes the chosen rank into account when determining + # if the game is stuck. + return Game.getSnapshotHash(self) + str(self.rank) + # register the game registerGame(GameInfo(774, HitOrMiss, "Hit or Miss",