class BakersDozen(CastlesInSpain): RowStack_Class = StackWrapper(RK_RowStack, max_move=1, max_accept=1, base_rank=NO_RANK) Solver_Class = FreeCellSolverWrapper(preset='bakers_dozen') def _shuffleHook(self, cards): # move Kings to bottom of each stack i, n = 0, len(self.s.rows) kings = [] for c in cards: if c.rank == KING: kings.append(i) i = i + 1 for i in kings: j = i % n while j < i: if cards[j].rank != KING: cards[i], cards[j] = cards[j], cards[i] break j = j + n cards.reverse() return cards def startGame(self): CastlesInSpain.startGame(self, flip=(1, 1, 1)) shallHighlightMatch = Game._shallHighlightMatch_RK
class Kentish(Kings): Solver_Class = FreeCellSolverWrapper(sbb='rank', sm='unlimited') def createGame(self, rows=8): # create layout l, s = Layout(self), self.s # set size self.setSize(l.XM + (rows+2)*l.XS, l.YM + 5*l.YS) # playcards = 4*l.YS // l.YOFFSET xoffset, yoffset = [], [] for i in range(playcards): xoffset.append(0) yoffset.append(l.YOFFSET) for i in range(104-playcards): xoffset.append(l.XOFFSET) yoffset.append(0) # create stacks x, y = l.XM, l.YM for i in range(rows): stack = RK_RowStack(x, y, self) stack.CARD_XOFFSET = xoffset stack.CARD_YOFFSET = yoffset s.rows.append(stack) x += l.XS x, y = l.XM + rows*l.XS, l.YM for suit in range(4): for i in range(2): s.foundations.append(RK_FoundationStack(x+i*l.XS, y, self, suit=suit)) y += l.YS self.setRegion(self.s.foundations, (x - l.CW // 2, -999, 999999, y), priority=1) x, y = self.width-3*l.XS//2, self.height-l.YS s.talon = InitialDealTalonStack(x, y, self) # define stack-groups l.defaultStackGroups() def _shuffleHook(self, cards): for c in cards[:]: if c.rank == ACE: cards.remove(c) break cards.insert(0, c) return cards def startGame(self): self.startDealSample() i = 0 while self.s.talon.cards: r = self.s.talon.cards[-1].rank self.s.talon.dealRow(rows=[self.s.rows[i]], frames=4) if r == ACE: i += 1 shallHighlightMatch = Game._shallHighlightMatch_RK
class CastlesInSpain(Game): Layout_Method = staticmethod(Layout.bakersDozenLayout) Talon_Class = InitialDealTalonStack Foundation_Class = SS_FoundationStack RowStack_Class = SuperMoveAC_RowStack Hint_Class = CautiousDefaultHint Solver_Class = FreeCellSolverWrapper() # # game layout # def createGame(self, **layout): # create layout l, s = Layout(self), self.s kwdefault(layout, rows=13, playcards=9) self.Layout_Method(l, **layout) self.setSize(l.size[0], l.size[1]) # create stacks s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self) for r in l.s.foundations: s.foundations.append( self.Foundation_Class(r.x, r.y, self, suit=r.suit)) for r in l.s.rows: s.rows.append(self.RowStack_Class(r.x, r.y, self)) # default l.defaultAll() return l def startGame(self, flip=(0, 0, 0)): for f in flip: self.s.talon.dealRow(flip=f, frames=0) self._startAndDealRow() shallHighlightMatch = Game._shallHighlightMatch_AC
class ForeCell(FreeCell): RowStack_Class = StackWrapper(FreeCell_AC_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(esf='kings') def startGame(self): self._startDealNumRows(5) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.reserves)
class Deep(DerKatzenschwanz): RowStack_Class = StackWrapper(AC_RowStack, base_rank=ANY_RANK) Solver_Class = FreeCellSolverWrapper(sm='unlimited') def createGame(self): return DerKatzenschwanz.createGame(self, rows=8, reserves=8) def startGame(self): self._startDealNumRowsAndDealSingleRow(12)
class ForeCell(FreeCell): RowStack_Class = StackWrapper(FreeCell_AC_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(esf='kings') def startGame(self): for i in range(5): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.reserves)
class Repair(FreeCell): Solver_Class = FreeCellSolverWrapper(sm='unlimited') RowStack_Class = AC_RowStack def createGame(self): FreeCell.createGame(self, rows=10, reserves=4, playcards=26) def startGame(self): self._startDealNumRows(9) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.reserves)
class Deep(DerKatzenschwanz): RowStack_Class = StackWrapper(AC_RowStack, base_rank=ANY_RANK) Solver_Class = FreeCellSolverWrapper(sm='unlimited') def createGame(self): return DerKatzenschwanz.createGame(self, rows=8, reserves=8) def startGame(self): for i in range(12): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow()
class OceanTowers(TripleFreecell): Solver_Class = FreeCellSolverWrapper(esf='kings', sbb='suit') RowStack_Class = StackWrapper(FreeCell_SS_RowStack, base_rank=KING) def createGame(self): TripleFreecell.createGame(self, rows=14, reserves=8, playcards=20) def startGame(self): self._startDealNumRows(6) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.reserves[1:-1]) shallHighlightMatch = Game._shallHighlightMatch_SS
class Bath(FreeCell): Solver_Class = FreeCellSolverWrapper(esf='kings') RowStack_Class = StackWrapper(SuperMoveAC_RowStack, base_rank=KING) def createGame(self): FreeCell.createGame(self, rows=10, reserves=2) def startGame(self): for i in range(6): self.s.talon.dealRow(rows=self.s.rows[i:], frames=0) self.startDealSample() self.s.talon.dealRow(rows=self.s.rows[6:]) self.s.talon.dealRow(rows=self.s.rows[7:])
class Retinue(DieSchlange, Kings): RowStack_Class = StackWrapper(FreeCell_AC_RowStack, base_rank=NO_RANK) Solver_Class = FreeCellSolverWrapper(esf='none') def createGame(self): return DerKatzenschwanz.createGame(self, rows=8, reserves=8) def _shuffleHook(self, cards): return Kings._shuffleHook(self, cards) def startGame(self): return DieSchlange.startGame(self)
class Tuxedo(Game): RowStack_Class = StackWrapper(SS_RowStack, mod=13) ReserveStack_Class = ReserveStack Foundation_Class = StackWrapper(SS_FoundationStack, mod=13, max_move=0) Hint_Class = FreeCellType_Hint Solver_Class = FreeCellSolverWrapper(sbb='suit', sm='unlimited') def createGame(self, rows=7, reserves=7): # create layout l, s = Layout(self), self.s # set window # (piles up to 16 cards are playable without # overlap in default window size) h = max(3 * l.YS, l.YS + (16 - 1) * l.YOFFSET) maxrows = max(rows, reserves) self.setSize(l.XM + (maxrows + 1) * l.XS, l.YM + h + l.YS) # extra settings self.base_card = None # create stacks x, y = self.width - l.XS, l.YM for i in range(4): s.foundations.append(self.Foundation_Class(x, y, self, suit=i)) y = y + l.YS self.setRegion(s.foundations, (x - l.CW / 2, -999, 999999, 999999)) x, y = l.XM + (maxrows - rows) * l.XS / 2, l.YM for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x = x + l.XS x, y = l.XM + (maxrows - reserves) * l.XS / 2, self.height - l.YS for i in range(reserves): s.reserves.append(self.ReserveStack_Class(x, y, self)) x = x + l.XS self.setRegion(s.reserves, (-999, y - l.CH / 2, 999999, 999999)) s.talon = InitialDealTalonStack(l.XM + 1, y, self) # define stack-groups l.defaultStackGroups() def startGame(self): for i in range(6): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.rows[::3]) shallHighlightMatch = Game._shallHighlightMatch_SSW
class Kings(DerKatzenschwanz): RowStack_Class = StackWrapper(AC_RowStack, base_rank=NO_RANK) Solver_Class = FreeCellSolverWrapper(esf='none', sm='unlimited') def createGame(self): return DerKatzenschwanz.createGame(self, rows=8, reserves=8) def _shuffleHook(self, cards): for c in cards[:]: if c.rank == KING: cards.remove(c) break cards.append(c) return cards
class FreeCell(Game): Layout_Method = staticmethod(Layout.freeCellLayout) Talon_Class = InitialDealTalonStack Foundation_Class = SS_FoundationStack RowStack_Class = SuperMoveAC_RowStack ReserveStack_Class = ReserveStack Hint_Class = FreeCellType_Hint Solver_Class = FreeCellSolverWrapper() # # game layout # def createGame(self, **layout): # create layout l, s = Layout(self), self.s kwdefault(layout, rows=8, reserves=4, texts=0) self.Layout_Method(l, **layout) # self.__class__.__dict__['Layout_Method'](l, **layout) # self.__class__.Layout_Method(l, **layout) self.setSize(l.size[0], l.size[1]) # create stacks s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self) for r in l.s.foundations: s.foundations.append( self.Foundation_Class(r.x, r.y, self, suit=r.suit)) for r in l.s.rows: s.rows.append(self.RowStack_Class(r.x, r.y, self)) for r in l.s.reserves: s.reserves.append(self.ReserveStack_Class(r.x, r.y, self)) # default l.defaultAll() # # game overrides # def startGame(self): for i in range(5): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow() r = self.s.rows # self.s.talon.dealRow(rows=(r[0], r[2], r[4], r[6])) self.s.talon.dealRow(rows=r[:4]) shallHighlightMatch = Game._shallHighlightMatch_AC
class Penguin(Tuxedo): GAME_VERSION = 2 Solver_Class = FreeCellSolverWrapper(sbb='suit', esf='kings', sm='unlimited') def _shuffleHook(self, cards): # move base cards to top of the Talon (i.e. first cards to be dealt) return self._shuffleHookMoveToTop(cards, lambda c, rank=cards[-1].rank: (c.rank == rank, 0)) def _updateStacks(self): for s in self.s.foundations: s.cap.base_rank = self.base_card.rank for s in self.s.rows: s.cap.base_rank = (self.base_card.rank - 1) % 13 def startGame(self): self.base_card = self.s.talon.cards[-4] self._updateStacks() # deal base cards to Foundations for i in range(3): c = self.s.talon.getCard() assert c.rank == self.base_card.rank to_stack = self.s.foundations[c.suit * self.gameinfo.decks] self.flipMove(self.s.talon) self.moveMove(1, self.s.talon, to_stack, frames=0) # deal rows for i in range(6): self.s.talon.dealRow(frames=0) self.startDealSample() self.s.talon.dealRow() def _restoreGameHook(self, game): self.base_card = self.cards[game.loadinfo.base_card_id] self._updateStacks() def _loadGameHook(self, p): self.loadinfo.addattr(base_card_id=None) # register extra load var. self.loadinfo.base_card_id = p.load() def _saveGameHook(self, p): p.dump(self.base_card.id)
class BoxFan(Fan): RowStack_Class = KingAC_RowStack Solver_Class = FreeCellSolverWrapper(esf='kings') def createGame(self): Fan.createGame(self, rows=(4, 4, 4, 4)) def startGame(self): self._startDealNumRows(2) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.foundations) def _shuffleHook(self, cards): # move Aces to bottom of the Talon (i.e. last cards to be dealt) return self._shuffleHookMoveToBottom(cards, lambda c: (c.rank == 0, c.suit)) shallHighlightMatch = Game._shallHighlightMatch_AC
class GoodMeasure(BakersDozen): Solver_Class = FreeCellSolverWrapper(preset='good_measure') def createGame(self): CastlesInSpain.createGame(self, rows=10) def _shuffleHook(self, cards): cards = BakersDozen._shuffleHook(self, cards) # move 2 Aces to bottom of the Talon (i.e. last cards to be dealt) return self._shuffleHookMoveToBottom(cards, lambda c: (c.rank == 0, c.suit), 2) def startGame(self): CastlesInSpain.startGame(self, flip=(1, 1, 1, 1)) for i in range(2): c = self.s.talon.cards[-1] assert c.rank == ACE self.flipMove(self.s.talon) self.moveMove(1, self.s.talon, self.s.foundations[c.suit])
class Lightweight(StreetsAndAlleys): DEAL = (7, 1) RowStack_Class = StackWrapper(RK_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(sbb='rank', esf='kings', sm='unlimited') def createGame(self, rows=12, playcards=20): l, s = Layout(self), self.s decks = self.gameinfo.decks max_rows = max(decks * 4, rows) self.setSize(l.XM + max_rows * l.XS, l.YM + 2 * l.YS + playcards * l.YOFFSET) x, y = l.XM + (max_rows - decks * 4) * l.XS / 2, l.YM for i in range(4): for j in range(decks): s.foundations.append( SS_FoundationStack(x, y, self, suit=i, max_move=0)) x += l.XS x, y = l.XM + (max_rows - rows) * l.XS / 2, l.YM + l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS s.talon = InitialDealTalonStack(self.width - l.XS, self.height - l.YS, self) l.defaultAll() def _shuffleHook(self, cards): # move Aces to top of the Talon (i.e. first cards to be dealt) return self._shuffleHookMoveToTop(cards, lambda c: (c.rank == ACE, c.suit)) def startGame(self): self.s.talon.dealRow(rows=self.s.foundations, frames=0) for i in range(self.DEAL[0]): self.s.talon.dealRow(frames=0) self.startDealSample() for i in range(self.DEAL[1]): self.s.talon.dealRowAvail()
class DieSchlange(DerKatzenschwanz): RowStack_Class = StackWrapper(FreeCell_AC_RowStack, base_rank=NO_RANK) Solver_Class = FreeCellSolverWrapper(esf='none') def createGame(self): DerKatzenschwanz.createGame(self, rows=9, reserves=7) def startGame(self): self.startDealSample() i = 0 while self.s.talon.cards: c = self.s.talon.cards[-1] if c.rank == ACE: to_stack = self.s.foundations[c.suit*2] if to_stack.cards: to_stack = self.s.foundations[c.suit*2+1] else: if c.rank == KING and self.s.rows[i].cards: i = i + 1 to_stack = self.s.rows[i] self.s.talon.dealRow(rows=(to_stack,), frames=4)
class ExiledKings(Citadel): Hint_Class = BeleagueredCastleType_Hint Solver_Class = FreeCellSolverWrapper(sbb='rank', esf='kings') RowStack_Class = StackWrapper(RK_RowStack, base_rank=KING)
class FreeFan(Fan): RowStack_Class = FullStackWrapper(SuperMoveSS_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(esf='kings', sbb='suit') def createGame(self): Fan.createGame(self, reserves=2, playcards=8)
class FanGame(Fan): Solver_Class = FreeCellSolverWrapper(preset='fan')
class KingOnlyBakersGame(BakersGame): RowStack_Class = StackWrapper(FreeCell_SS_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(sbb='suit', esf='kings')
class StreetsAndAlleys(Game): Hint_Class = BeleagueredCastleType_Hint Solver_Class = FreeCellSolverWrapper(preset='streets_and_alleys') Foundation_Class = SS_FoundationStack # RowStack_Class = RK_RowStack RowStack_Class = SuperMoveRK_RowStack # # game layout # def createGame(self, playcards=13, reserves=0, texts=False): # create layout l, s = Layout(self), self.s # set window # (set size so that at least 13 cards are fully playable) w = max(3*l.XS, l.XS+(playcards-1)*l.XOFFSET) x0 = l.XM x1 = x0 + w + 2*l.XM x2 = x1 + l.XS + 2*l.XM x3 = x2 + w + l.XM h = l.YM + (4+int(reserves != 0))*l.YS + int(texts)*l.TEXT_HEIGHT self.setSize(x3, h) # create stacks y = l.YM if reserves: x = x1 - int(l.XS*(reserves-1)/2) for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x += l.XS y += l.YS x = x1 for i in range(4): s.foundations.append( self.Foundation_Class(x, y, self, suit=i, max_move=0)) y += l.YS if texts: tx, ty, ta, tf = l.getTextAttr(None, "ss") tx, ty = x+tx, y-l.YS+ty font = self.app.getFont("canvas_default") self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font) for x in (x0, x2): y = l.YM+l.YS*int(reserves != 0) for i in range(4): stack = self.RowStack_Class(x, y, self) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) y += l.YS x, y = self.width - l.XS, self.height - l.YS s.talon = InitialDealTalonStack(x, y, self) if reserves: l.setRegion( s.rows[:4], (-999, l.YM+l.YS-l.CH//2, x1-l.CW//2, 999999)) else: l.setRegion(s.rows[:4], (-999, -999, x1-l.CW//2, 999999)) # default l.defaultAll() # # game overrides # def startGame(self): self._startDealNumRows(4) for i in range(3): self.s.talon.dealRowAvail() shallHighlightMatch = Game._shallHighlightMatch_RK
class SpanishPatienceII(PortugueseSolitaire): RowStack_Class = StackWrapper(RK_RowStack, max_move=1) Solver_Class = FreeCellSolverWrapper(sbb='rank')
class Siegecraft(BeleagueredCastle): Hint_Class = FreeCellType_Hint Solver_Class = FreeCellSolverWrapper(sbb='rank') def createGame(self): BeleagueredCastle.createGame(self, reserves=1)
class Fastness(StreetsAndAlleys): Hint_Class = FreeCellType_Hint Solver_Class = FreeCellSolverWrapper(sbb='rank') def createGame(self): StreetsAndAlleys.createGame(self, reserves=2)
class RelaxedSeahavenTowers(SeahavenTowers): RowStack_Class = KingSS_RowStack Solver_Class = FreeCellSolverWrapper( sbb='suit', esf='kings', sm='unlimited')
class PenelopesWeb(StreetsAndAlleys): RowStack_Class = StackWrapper(RK_RowStack, base_rank=KING) Solver_Class = FreeCellSolverWrapper(sbb='rank', esf='kings')
class BakersGame(FreeCell): RowStack_Class = SuperMoveSS_RowStack Solver_Class = FreeCellSolverWrapper(sbb='suit') shallHighlightMatch = Game._shallHighlightMatch_SS