diff --git a/pysollib/hint.py b/pysollib/hint.py index b1f48173..99cdbd11 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -32,6 +32,7 @@ from io import BytesIO # PySol imports from pysollib.settings import DEBUG, FCS_COMMAND +from pysollib.pysolrandom import constructRandom from pysollib.mfxutil import destruct from pysollib.util import KING @@ -854,9 +855,12 @@ class FreeCellSolver_Hint(Base_Solver_Hint): def importFile(solver, fh, s_game, self): s_game.endGame() + s_game.random = constructRandom('Custom') s_game.newGame( shuffle=True, + random=constructRandom('Custom'), dealer=lambda: solver.importFileHelper(fh, s_game)) + s_game.random = constructRandom('Custom') def importFileHelper(solver, fh, s_game): game = s_game.s diff --git a/pysollib/pysolrandom.py b/pysollib/pysolrandom.py index c4c23c25..28fd6aa7 100644 --- a/pysollib/pysolrandom.py +++ b/pysollib/pysolrandom.py @@ -205,12 +205,35 @@ class LCRandom64(MFXRandom): return ((self.seed >> 21) & 0x7fffffff) / 2147483648.0 +MS_LONG_BIT = (long(1) << 1000) +CUSTOM_BIT = (long(1) << 999) + + +class CustomRandom(BasicRandom): + def __init__(self): + self.initial_seed = self.seed = MS_LONG_BIT | CUSTOM_BIT + self.origin = self.ORIGIN_UNKNOWN + self.setSeedAsStr('Custom') + + def reset(self): + pass + + def shuffle(self, seq): + pass + + def getstate(self): + return self.seed + + def setstate(self, state): + self.seed = state + # ************************************************************************ # * Linear Congruential random generator # * In PySol this is only used for 0 <= seed <= 32000 # * for Windows FreeCell compatibility # ************************************************************************ + class LCRandom31(MFXRandom): MAX_SEED = long('0x1ffffffff', 0) # 33 bits @@ -274,6 +297,8 @@ def _match_ms(s): # construct Random from seed string def constructRandom(s): + if s == 'Custom': + return CustomRandom() m = _match_ms(s) if m: seed = long(m.group(1)) @@ -294,10 +319,6 @@ def constructRandom(s): return PysolRandom(seed) -MS_LONG_BIT = (long(1) << 1000) -CUSTOM_BIT = (long(1) << 999) - - def random__str2long(s): if s == 'Custom': return CUSTOM_BIT | MS_LONG_BIT