mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Refactoring
This commit is contained in:
parent
00ded37a0e
commit
780ac558d5
1 changed files with 4 additions and 4 deletions
|
@ -829,7 +829,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
RANKS_RE = '[' + RANKS_S + ']'
|
RANKS_RE = '[' + RANKS_S + ']'
|
||||||
SUITS_S = "CSHD"
|
SUITS_S = "CSHD"
|
||||||
SUITS_RE = '[' + SUITS_S + ']'
|
SUITS_RE = '[' + SUITS_S + ']'
|
||||||
CARD_RE = RANKS_RE + SUITS_RE
|
CARD_RE = r'(?:' + RANKS_RE + SUITS_RE + ')'
|
||||||
|
|
||||||
def cards():
|
def cards():
|
||||||
return game.talon.cards
|
return game.talon.cards
|
||||||
|
@ -857,7 +857,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
for gm in g:
|
for gm in g:
|
||||||
for foundat in game.foundations:
|
for foundat in game.foundations:
|
||||||
suit = foundat.cap.suit
|
suit = foundat.cap.suit
|
||||||
if "CSHD"[suit] == gm[0]:
|
if SUITS_S[suit] == gm[0]:
|
||||||
for r in range(RANKS0_S.index(gm[1])):
|
for r in range(RANKS0_S.index(gm[1])):
|
||||||
put(foundat, suit, r)
|
put(foundat, suit, r)
|
||||||
break
|
break
|
||||||
|
@ -865,7 +865,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
m = re.match(r'^(?:FC:|Freecells:)\s*(.*)', line)
|
m = re.match(r'^(?:FC:|Freecells:)\s*(.*)', line)
|
||||||
if m:
|
if m:
|
||||||
g = re.findall(
|
g = re.findall(
|
||||||
r'\b((?:' + CARD_RE + r')|\-)\b', m.group(1))
|
r'\b(' + CARD_RE + r'|\-)\b', m.group(1))
|
||||||
while len(g) < len(game.reserves):
|
while len(g) < len(game.reserves):
|
||||||
g.append('-')
|
g.append('-')
|
||||||
for i, gm in enumerate(g):
|
for i, gm in enumerate(g):
|
||||||
|
@ -873,7 +873,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
|
||||||
if str_ != '-':
|
if str_ != '-':
|
||||||
put_str(game.reserves[i], str_)
|
put_str(game.reserves[i], str_)
|
||||||
continue
|
continue
|
||||||
g = re.findall(r'\b((?:' + CARD_RE + r'))\b', line)
|
g = re.findall(r'\b(' + CARD_RE + r')\b', line)
|
||||||
for str_ in g:
|
for str_ in g:
|
||||||
put_str(game.rows[stack_idx], str_)
|
put_str(game.rows[stack_idx], str_)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue