mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Display the deal of imported as 'Custom'.
See https://github.com/shlomif/PySolFC/issues/47 .
This commit is contained in:
parent
a8f297208b
commit
dc8adf8411
2 changed files with 29 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue