Black Hole Solitaire Solver
About
This is a solver, written in C, to solve Golf solitaire, the Solitaire variant called “Black Hole” and the one called “All in a Row”. It provides a portable C library, and a command line application that after being fed with a layout will emit the cards to move.
Download
- black-hole-solver-1.10.1.tar.xz - requires CMake to be built.
- The Games-Solitaire-BlackHole-Solver CPAN Distribution - an older version of the solver written as a proof-of-concept, which produces identical results, but is much slower and consumes more memory. It is still maintained and enhanced for prototyping ideas and new features.
- black_hole_solver.dump.xz - results from running the solver on the first 1 million PySolFC deals - inside the dump of an SQLite database.
Solving Data
We’ve ran the solver on the first 1 million PySolFC Black Hole Solitaire deals and one can download the data from that as a compressed textual dump of an SQLite database.
Here’s a description of the tables of the database:
bhs_runs - this table contains the results and statistics of running the solver on the boards. Its columns are:
- idx - the index of the PySolFC deal.
- status - a character representing the verdict - ‘U’ for unsolved, ‘S’ for solved.
- num_checked - the number of iterations that were checked (“num_times”). If the game was unsolved, then it will be equal to num_generated (see below).
- num_generated - the number of states generated (and not necessarily checked). May only be different if the deal was solved.
bhs_solutions - this table contains the compacted solutions for the solved boards. Its columns are:
- idx - the index of the deal (that must be ‘S’ on “bhs_runs”).
- solution - this is the compacted solution. The 0,2,4 etc. characters are the indices of the stacks moved in the range 1-17. The 1,3,5 etc. characters are the corresponding moved cards after calculating
chr(1 + $suits_to_n{$s} * 13 + $ranks_to_n{$r})
where the suits are orderedH,C,D,S
. It will total 51*2 characters. Here’s the script that was used to generate them from the more verbose solution files.
Project Links
- GitHub Repository - contains version control and other resources.
- Games-Solitaire-BlackHole-Solver on MetaCPAN - download, documentation, browsing and information.
- Freecode Record
Similar Projects
- Freecell Solver and other Solitaire solvers.
- Games::Solitaire::Verify::Golf - validate solutions as correct.
Licence
The Black Hole Solitaire Solver is free and open-source software (FOSS) distributed under the MIT/Expat License, a permissive software licence.
News
Version 1.10.1
: Version 1.10.1 was released featuring a compile-time and run-time option to determine the maximal number of playable cards, which is primarily of interest for impossible deals. This feature was inspired by Jon Wolter’s article titled Experimental Analysis of Black Hole and All-In-A-Row Solitaire
over on the Polymorphic Solitaire site (Thanks!).
Version 1.8.0
Version 1.8.0 was released with some fixes and enhancements, and while featuring a new wrapper of the C library for Python which is also open source.
Version 1.4.0
Version 1.4.0 was released with some optimisations and cleanups.
Version 1.0.0
Version 1.0.0 was released with some relatively minor changes and cleanups, but a new major version digit.
Version 0.22.0
Version 0.22.0 was released with hopefully better handling of failed memory allocations, as well as a refactored test suite.
Version 0.20.0
Version 0.20.0 was released with recycling instances support and some speed improvements.
Version 0.18.0
Version 0.18.0 was released with added support for three variants of Golf.
Version 0.16.0
Version 0.16.0 was released with a fix for a crash and some code cleanups.
Version 0.14.0
Version 0.14.0 of Black Hole Solitaire Solver was released. The highlights of this release are setting an SOVERSION to the shared library, some bug fixes and moving the repository to Git and GitHub and enabling Travis-CI.
Version 0.12.0
Version 0.12.0 of Black Hole Solitaire Solver was released. The highlights of this release are an improved API, many cleanups (the code requires “-std=gnu99” from now on), and an ability to be built as an RPM.
Version 0.10.0
Version 0.10.0 of Black Hole Solitaire Solver was released. The highlights of this release are the new --display-iters-step
flag, which allows for monitoring the progress of the solutions, and fixes for the build system with version 3.0.0 of CMake.
Version 0.8.0
Version 0.8.0 of Black Hole Solitaire Solver was released. The highlights of this release are the new --version
flag, and the --rank-reach-prune
flag, which can improve performance.
Version 0.6.0
Version 0.6.0 of Black Hole Solitaire Solver was released. The highlights of this release are the inclusion of the NEWS file, the --help
flag and most importantly the --display-boards
flag that displays the intermediate board layouts after every move.
Version 0.4.0
Version 0.4.0 of Black Hole Solitaire Solver was released. The highlight of this release is the fact that it can now also solve All in a Row solitaire. As a result of this effort, we have run the solver on the first 1 million PySolFC deals of All in a Row Solitaire and have drawn some conclusions:
Version 0.2.0
Version 0.2.0 of Black Hole Solitaire Solver was released. The highlight of this release is the porting of the solver from Perl to C which yields a very dramatic gain in speed and memory consumption. As a result of this effort, we have run the solver on the first 1 million PySolFC deals of Black Hole Solitaire and have drawn some conclusions: