mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-15 02:54:09 -04:00
Implement the --version conditional.
See https://github.com/shlomif/PySolFC/issues/90 .
This commit is contained in:
parent
4e7a653f67
commit
7407276829
1 changed files with 21 additions and 2 deletions
|
@ -36,6 +36,7 @@ from pysollib.pysolrandom import constructRandom
|
||||||
from pysollib.mfxutil import destruct
|
from pysollib.mfxutil import destruct
|
||||||
from pysollib.util import KING
|
from pysollib.util import KING
|
||||||
|
|
||||||
|
FCS_VERSION = None
|
||||||
if sys.version_info > (3,):
|
if sys.version_info > (3,):
|
||||||
unicode = str
|
unicode = str
|
||||||
|
|
||||||
|
@ -995,6 +996,17 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
def computeHints(self):
|
def computeHints(self):
|
||||||
game = self.game
|
game = self.game
|
||||||
game_type = self.game_type
|
game_type = self.game_type
|
||||||
|
global FCS_VERSION
|
||||||
|
if FCS_VERSION is None:
|
||||||
|
pout, _ = self.run_solver(FCS_COMMAND + ' --version', '')
|
||||||
|
s = unicode(pout.read(), encoding='utf-8')
|
||||||
|
m = re.search(r'version ([0-9]+)\.([0-9]+)\.([0-9]+)', s)
|
||||||
|
if m:
|
||||||
|
FCS_VERSION = (int(m.group(1)), int(m.group(2)),
|
||||||
|
int(m.group(3)))
|
||||||
|
else:
|
||||||
|
FCS_VERSION = (0, 0, 0)
|
||||||
|
|
||||||
progress = self.options['progress']
|
progress = self.options['progress']
|
||||||
|
|
||||||
board = self.calcBoardString()
|
board = self.calcBoardString()
|
||||||
|
@ -1004,9 +1016,16 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
#
|
#
|
||||||
args = []
|
args = []
|
||||||
# args += ['-sam', '-p', '-opt', '--display-10-as-t']
|
# args += ['-sam', '-p', '-opt', '--display-10-as-t']
|
||||||
args += ['-m', '-p', '-opt', '-sel', '-hoi']
|
args += ['-m', '-p', '-opt', '-sel']
|
||||||
|
if FCS_VERSION >= (4, 20, 0):
|
||||||
|
args += ['-hoi']
|
||||||
if progress:
|
if progress:
|
||||||
args += ['--iter-output']
|
args += ['--iter-output']
|
||||||
|
fcs_iter_output_step = None
|
||||||
|
if FCS_VERSION >= (4, 20, 0):
|
||||||
|
# fcs_iter_output_step = 10000
|
||||||
|
fcs_iter_output_step = 100
|
||||||
|
args += ['--iter-output-step', str(fcs_iter_output_step)]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
args += ['-s']
|
args += ['-s']
|
||||||
if self.options['preset'] and self.options['preset'] != 'none':
|
if self.options['preset'] and self.options['preset'] != 'none':
|
||||||
|
@ -1053,7 +1072,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
depth = self._v
|
depth = self._v
|
||||||
elif self.colonPrefixMatch('Stored-States', s):
|
elif self.colonPrefixMatch('Stored-States', s):
|
||||||
states = self._v
|
states = self._v
|
||||||
if iter_ % 100 == 0:
|
if iter_ % 100 == 0 or fcs_iter_output_step:
|
||||||
self.dialog.setText(iter=iter_, depth=depth,
|
self.dialog.setText(iter=iter_, depth=depth,
|
||||||
states=states)
|
states=states)
|
||||||
elif re.search('^(?:-=-=)', s):
|
elif re.search('^(?:-=-=)', s):
|
||||||
|
|
Loading…
Add table
Reference in a new issue