mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-22 03:04:09 -04:00
Extract the calcBoard methods.
This commit is contained in:
parent
ef6b0d7892
commit
8a5b8de137
1 changed files with 26 additions and 14 deletions
|
@ -790,15 +790,13 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def computeHints(self):
|
def _calcBoard(self):
|
||||||
game = self.game
|
game = self.game
|
||||||
game_type = self.game_type
|
|
||||||
progress = self.options['progress']
|
|
||||||
board = ''
|
board = ''
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
b = ''
|
b = ''
|
||||||
for s in self.game.s.foundations:
|
for s in game.s.foundations:
|
||||||
if s.cards:
|
if s.cards:
|
||||||
if 'preset' in game_type and game_type['preset'] == 'simple_simon':
|
if 'preset' in game_type and game_type['preset'] == 'simple_simon':
|
||||||
ss = self.card2str2(s.cards[0])
|
ss = self.card2str2(s.cards[0])
|
||||||
|
@ -809,7 +807,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
board += 'Founds:' + b + '\n'
|
board += 'Founds:' + b + '\n'
|
||||||
#
|
#
|
||||||
b = ''
|
b = ''
|
||||||
for s in self.game.s.reserves:
|
for s in game.s.reserves:
|
||||||
if s.cards:
|
if s.cards:
|
||||||
cs = self.card2str1(s.cards[-1])
|
cs = self.card2str1(s.cards[-1])
|
||||||
b += ' ' + cs
|
b += ' ' + cs
|
||||||
|
@ -818,14 +816,24 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
if b:
|
if b:
|
||||||
board += 'FC:' + b + '\n'
|
board += 'FC:' + b + '\n'
|
||||||
#
|
#
|
||||||
for s in self.game.s.rows:
|
for s in game.s.rows:
|
||||||
b = ''
|
b = ''
|
||||||
for c in s.cards:
|
for c in s.cards:
|
||||||
cs = self.card2str1(c)
|
cs = self.card2str1(c)
|
||||||
if not c.face_up:
|
if not c.face_up:
|
||||||
cs = '<%s>' % cs
|
cs = '<%s>' % cs
|
||||||
b += cs + ' '
|
b += cs + ' '
|
||||||
board = board + b.strip() + '\n'
|
board += b.strip() + '\n'
|
||||||
|
|
||||||
|
return board
|
||||||
|
|
||||||
|
|
||||||
|
def computeHints(self):
|
||||||
|
game = self.game
|
||||||
|
game_type = self.game_type
|
||||||
|
progress = self.options['progress']
|
||||||
|
|
||||||
|
board = self._calcBoard()
|
||||||
#
|
#
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print '--------------------\n', board, '--------------------'
|
print '--------------------\n', board, '--------------------'
|
||||||
|
@ -980,14 +988,9 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
|
|
||||||
class BlackHoleSolver_Hint(Base_Solver_Hint):
|
class BlackHoleSolver_Hint(Base_Solver_Hint):
|
||||||
BLACK_HOLE_SOLVER_COMMAND = 'black-hole-solve'
|
BLACK_HOLE_SOLVER_COMMAND = 'black-hole-solve'
|
||||||
def computeHints(self):
|
|
||||||
game = self.game
|
|
||||||
game_type = self.game_type
|
|
||||||
progress = self.options['progress']
|
|
||||||
board = ''
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
|
def _calcBoard(self):
|
||||||
|
board = ''
|
||||||
cards = self.game.s.foundations[0].cards
|
cards = self.game.s.foundations[0].cards
|
||||||
s = '-'
|
s = '-'
|
||||||
if (len(cards) > 0):
|
if (len(cards) > 0):
|
||||||
|
@ -1002,6 +1005,15 @@ class BlackHoleSolver_Hint(Base_Solver_Hint):
|
||||||
cs = '<%s>' % cs
|
cs = '<%s>' % cs
|
||||||
b += cs + ' '
|
b += cs + ' '
|
||||||
board += b.strip() + '\n'
|
board += b.strip() + '\n'
|
||||||
|
|
||||||
|
return board;
|
||||||
|
|
||||||
|
def computeHints(self):
|
||||||
|
game = self.game
|
||||||
|
game_type = self.game_type
|
||||||
|
progress = self.options['progress']
|
||||||
|
|
||||||
|
board = self._calcBoard()
|
||||||
#
|
#
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print '--------------------\n', board, '--------------------'
|
print '--------------------\n', board, '--------------------'
|
||||||
|
|
Loading…
Add table
Reference in a new issue