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

Refactoring.

This commit is contained in:
Shlomi Fish 2018-03-13 10:28:12 +02:00
parent e522078072
commit c825c3c6df
3 changed files with 11 additions and 14 deletions

View file

@ -419,7 +419,7 @@ class DefaultHint(AbstractHint):
else: else:
d = (c.rank - t.cap.base_rank) % t.cap.mod d = (c.rank - t.cap.base_rank) % t.cap.mod
if d > t.cap.mod // 2: if d > t.cap.mod // 2:
d = d - t.cap.mod d -= t.cap.mod
if abs(d) <= 1: if abs(d) <= 1:
# drop Ace and 2 immediately # drop Ace and 2 immediately
score = 92000 score = 92000
@ -551,7 +551,7 @@ class DefaultHint(AbstractHint):
if stack and stack is not r: if stack and stack is not r:
assert ncards == 1 assert ncards == 1
drop_info.append((c, stack, ncards, i)) drop_info.append((c, stack, ncards, i))
i = i + 1 i += 1
# now try to make a move so that the drop-card will get free # now try to make a move so that the drop-card will get free
for di in drop_info: for di in drop_info:
c = di[0] c = di[0]
@ -565,7 +565,7 @@ class DefaultHint(AbstractHint):
continue continue
# print "drop move", r, t, sub_pile # print "drop move", r, t, sub_pile
score = 40000 score = 40000
score = score + 1000 + (self.K - r.getCard().rank) score += 1000 + (self.K - r.getCard().rank)
# force the drop (to avoid loops) # force the drop (to avoid loops)
force = (999999, 0, di[2], r, di[1], self.BLUE, None) force = (999999, 0, di[2], r, di[1], self.BLUE, None)
self.addHint( self.addHint(

View file

@ -609,13 +609,11 @@ class PysolMenubarTk:
filename = self.game.filename filename = self.game.filename
if not filename: if not filename:
filename = self.app.getGameSaveName(self.game.id) filename = self.app.getGameSaveName(self.game.id)
if os.name == 'posix': if os.name == 'posix' or os.path.supports_unicode_filenames:
filename = filename + '-' + self.game.getGameNumber(format=0) filename += '-' + self.game.getGameNumber(format=0)
elif os.path.supports_unicode_filenames: # new in python 2.3
filename = filename + '-' + self.game.getGameNumber(format=0)
else: else:
filename = filename + '-01' filename += '-01'
filename = filename + '.pso' filename += '.pso'
idir, ifile = os.path.split(os.path.normpath(filename)) idir, ifile = os.path.split(os.path.normpath(filename))
if not idir: if not idir:
idir = self.app.dn.savegames idir = self.app.dn.savegames

View file

@ -1681,7 +1681,7 @@ class DealRow_StackMethods:
for r in stacks: for r in stacks:
assert r is not self assert r is not self
while self.cards: while self.cards:
n = n + 1 n += 1
if flip: if flip:
self.game.flipMove(self) self.game.flipMove(self)
if flip and self.cards[-1].rank == rank: if flip and self.cards[-1].rank == rank:
@ -1728,7 +1728,7 @@ class DealBaseCard_StackMethods:
if not c.face_up: if not c.face_up:
self.game.flipMove(self) self.game.flipMove(self)
self.game.moveMove(1, self, s, frames=frames) self.game.moveMove(1, self, s, frames=frames)
ncards = ncards - 1 ncards -= 1
class RedealCards_StackMethods: class RedealCards_StackMethods:
@ -2781,9 +2781,8 @@ class SuperMoveStack_StackMethods:
return max_move return max_move
n = getNumberOfFreeStacks(self.game.s.rows) n = getNumberOfFreeStacks(self.game.s.rows)
if to_stack_ncards == 0: if to_stack_ncards == 0:
n = n - 1 n -= 1
max_move = max_move * (2 ** n) return max_move << max(n, 0)
return max_move
def _getNumSSSeq(self, cards): def _getNumSSSeq(self, cards):
# num of same-suit sequences (for SuperMoveSpider_RowStack) # num of same-suit sequences (for SuperMoveSpider_RowStack)