pyksolve package¶
A wrapper around the Klondike-Solver.
Submodules¶
pyksolve.solver module¶
Provides the wrapped main function of “KlondikeSolver.cpp”.
-
class
pyksolve.solver.
Solitaire
¶ Bases:
object
Wrapper around the Solitaire C++ class from Klondike-Solver.
-
draw_count
¶ int
-> Number of cards drawn for each draw move.- Setter:
int
-
foundation_count
¶ int
-> Output of “FoundationCount()”.
-
game_diagram
(self)¶ Get the current game diagram in the default format.
Returns: str
-> The game diagram in the default format.
-
game_diagram_pysol
(self)¶ Get the current game diagram in PySol format.
Returns: str
-> The game diagram in the PySol format.
-
get_move_info
(self, move_index)¶ Move info as KlondikeSolver provides it.
Parameters: move_index – int
-> valid move index.
-
get_pysol
(self)¶ Get the current card set in PySol format.
Returns: str
-> The card set in the PySol format.
-
get_solitaire
(self)¶ Get the current card set.
Returns: str
-> The card set in the default format.
-
load_pysol
(self, card_set)¶ Load a card set in the PySol format.
Parameters: card_set – str
-> The card set in the PySol format.
-
load_solitaire
(self, card_set)¶ Load a card set in the default format.
Parameters: card_set – str
-> The card set in the default format.
-
moves_made
(self)¶ Get a space delimited list of the moves made to solve.
Returns: str
-> The moves delimited by single spaces.
-
moves_made_count
¶ int
-> Output of “MovesMadeCount()”.
-
moves_made_normalized_count
¶ int
-> Output of “MovesMadeNormalizedCount()”.
-
reset_game
(self, draw_count=None)¶ Calls the ResetGame method.
Parameters: draw_count – int
-> Number of cards drawn for each draw move.
-
shuffle1
(self, deal_number=-1)¶ Calls the Shuffle1 method.
Parameters: deal_number – int
-> Optional random seed.Returns: int
-> Random seed used to shuffle.
-
shuffle2
(self, deal_number)¶ Calls the Shuffle2 method.
Parameters: deal_number – int
-> Random seed.
-
solve_fast
(self, two_shift=0, three_shift=0, max_closed_count=None)¶ Attempts to find a fast but possibly not minimal solution.
Parameters: - two_shift –
Optional[int]
-> - three_shift –
Optional[int]
-> - max_closed_count –
Optional[int]
-> Maximum number of game states to evaluate before terminating. Defaults to 5,000,000.
Returns: SolveResult
-> The result of the attempt.- two_shift –
-
solve_minimal
(self, max_closed_count=None)¶ Attempts to find a minimal solution.
Parameters: max_closed_count – Optional[int]
-> Maximum number of game states to evaluate before terminating. Defaults to 5,000,000.Returns: SolveResult
-> The result of the attempt.
-
solve_minimal_multithreaded
(self, num_threads, max_closed_count=None)¶ Attempts to find a minimal solution, using multiple threads.
Parameters: - num_threads –
int
-> Number of threads to use. - max_closed_count –
Optional[int]
-> Maximum number of game states to evaluate before terminating. Defaults to 5,000,000.
Returns: SolveResult
-> The result of the attempt.- num_threads –
-
pyksolve.deferred module¶
Provides the DeferredSolver class that generates a number of solvable games for faster access to a solvable seed on demand.
-
class
pyksolve.deferred.
DeferredSolver
(draw_counts: Tuple[int, ...] = (1, 3), cache_num: int = 5, threads: int = 3, max_closed: int = 1000000, seed: Optional[int] = None)[source]¶ Bases:
object
Provides a cache of solved games, that is kept at a user defined number of games for each specified draw count. To properly clean up, call
DeferredSolver.stop()
when the DeferredSolver is no longer needed.Parameters: - draw_counts –
Tuple[int, ...]
-> for which draw count a cache is generated. Defaults to (1, 3). - cache_num –
int
-> number of solvable games to cache at any time. Defaults to 5. - threads –
int
-> number of workers to run solvers. Defaults to 3. - max_closed –
int
-> max_closed argument to be passed to the usedpyksolve.solver.Solitaire.solve_fast()
method. Defaults to 1,000,000.
Warning
If you don’t call
DeferredSolver.stop()
, your program might hang until terminated forcefully. AfterDeferredSolver.stop()
was called, the class is defunct!- draw_counts –