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

distinguish between intractable and unsolvable.

This commit is contained in:
Shlomi Fish 2014-10-14 11:37:16 +03:00
parent 415c65194c
commit 5da836e778
3 changed files with 17 additions and 4 deletions

View file

@ -95,6 +95,7 @@ class AbstractHint(HintInterface):
self.hints = []
self.max_score = 0
self.__destructClones()
self.solver_state = 'not_started';
#
# stack cloning
@ -821,7 +822,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
#
args = []
##args += ['-sam', '-p', '-opt', '--display-10-as-t']
args += ['-m', '-p', '-opt']
args += ['-m', '-p', '-opt', '-sel']
if progress:
args += ['--iter-output']
if DEBUG:
@ -884,7 +885,13 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
if iter % 100 == 0:
self.dialog.setText(iter=iter, depth=depth,
states=states)
elif re.search('^(?:-=-=|I could not solve this game)', s):
elif re.search('^(?:-=-=)', s):
break
elif re.search('^(?:Iterations count exceeded)', s):
self.solver_state = 'intractable'
break
elif re.search('^(?:I could not solve this game)', s):
self.solver_state = 'unsolved'
break
self.dialog.setText(iter=iter, depth=depth, states=states)
@ -952,6 +959,8 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
##print perr.read(),
self.hints = hints
if len(hints) > 0:
self.solver_state = 'solved'
self.hints.append(None) # XXX
##print self.hints
@ -1029,10 +1038,14 @@ class BlackHoleSolver_Hint(Base_Solver_Hint):
self.dialog.setText(iter=iter, depth=depth, states=states)
if (result == 'Intractable!'):
self.solver_state = 'intractable'
return
if (result == 'Unsolved!'):
self.solver_state = 'unsolved'
return
self.solver_state = 'solved'
hints = []
for s in pout:
if DEBUG:

View file

@ -245,7 +245,7 @@ class SolverDialog(MfxDialog):
self.result_label['text'] = t
self.play_button.config(state='normal')
else:
self.result_label['text'] = _('I could not solve this game.')
self.result_label['text'] = (_('I could not solve this game.') if solver.solver_state == 'unsolved' else _('Iterations count exceeded (Intractable)'))
self.play_button.config(state='disabled')
def startPlay(self):

View file

@ -248,7 +248,7 @@ class SolverDialog(MfxDialog):
self.result_label['text'] = t
self.play_button.config(state='normal')
else:
self.result_label['text'] = _('I could not solve this game.')
self.result_label['text'] = (_('I could not solve this game.') if solver.solver_state == 'unsolved' else _('Iterations count exceeded (Intractable)'))
self.play_button.config(state='disabled')
def startPlay(self):