Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include pysollib/tk/*.py pysollib/tile/*.py pysollib/pysolgtk/*.py
include pysollib/game/*.py
include pysollib/games/*.py pysollib/games/special/*.py
include pysollib/games/mahjongg/*.py
include pysollib/games/solvable_seeds/*.py
include data/tcl/*.tcl
include data/pysol.desktop
include data/pysolfc.glade
Expand Down
20 changes: 20 additions & 0 deletions html-src/rules/klondikealwayssolvable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<h1>Klondike (Always Solvable)</h1>
<p>
Klondike type. 1 deck. Unlimited redeals.

<h3>Object</h3>
<p>
Move all cards to the foundations.

<h3>Quick Description</h3>
<p>
Just like <a href="klondike.html">Klondike</a>, except new deals are
drawn from a pool of game numbers that have already been confirmed
solvable (winnable with <b></b>perfect</b> play), so you should never get stuck
with an unwinnable deal.

<h3>Notes</h3>
<p>
This only applies to fresh deals. If you manually enter a specific game
number, that exact number is dealt as-is and is not guaranteed to be
solvable.
1 change: 1 addition & 0 deletions pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def _callback(gi, gt=game_type):
(44, 526, 5906, 22399,)),
('fc-3.6', tuple(range(981, 991)) + tuple(range(19501, 19510)) +
(16686,)),
('dev', (991,)),
)

# deprecated - the correct way is to or a GI.GT_XXX flag
Expand Down
20 changes: 20 additions & 0 deletions pysollib/games/klondike.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
from pysollib.game import Game
from pysollib.gamedb import GI, GameInfo, registerGame
from pysollib.games.canfield import CanfieldRush_Talon
from pysollib.games.solvable_seeds.klondike_solvable_seeds import \
SOLVABLE_SEEDS
from pysollib.hint import CautiousDefaultHint
from pysollib.hint import FreeCellSolverWrapper
from pysollib.hint import KlondikeType_Hint
from pysollib.layout import Layout
from pysollib.mfxutil import Struct, kwdefault
from pysollib.mygettext import _
from pysollib.pysolrandom import construct_random
from pysollib.pysoltk import MfxCanvasText
from pysollib.stack import \
AC_RowStack, \
Expand Down Expand Up @@ -104,6 +107,20 @@ def startGame(self, flip=0, reverse=1):
shallHighlightMatch = Game._shallHighlightMatch_AC


# ************************************************************************
# * Klondike (Always Solvable)
# ************************************************************************

class KlondikeAlwaysSolvable(Klondike):
# picks a known-solvable seed for a fresh deal; leaves explicit
# seeds (e.g. "enter game number") alone
def createRandom(self, random):
if random is None and SOLVABLE_SEEDS:
seed = self.app.gamerandom.choice(SOLVABLE_SEEDS)
random = construct_random(str(seed))
Game.createRandom(self, random)


# ************************************************************************
# * Vegas Klondike
# ************************************************************************
Expand Down Expand Up @@ -1658,6 +1675,9 @@ def startGame(self):
registerGame(GameInfo(2, Klondike, "Klondike",
GI.GT_KLONDIKE, 1, -1, GI.SL_BALANCED,
altnames=("Classic Solitaire", "American Patience")))
registerGame(GameInfo(991, KlondikeAlwaysSolvable,
"Klondike (Always Solvable)",
GI.GT_KLONDIKE, 1, -1, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(61, CasinoKlondike, "Casino Klondike",
GI.GT_KLONDIKE | GI.GT_SCORE, 1, 2, GI.SL_BALANCED))
registerGame(GameInfo(129, VegasKlondike, "Vegas Klondike",
Expand Down
22 changes: 22 additions & 0 deletions pysollib/games/solvable_seeds/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------##
#
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co.
# Copyright (C) 2005-2009 Skomoroh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------------##
Loading