Notes on solving and playing peg solitaire on a computer
We consider the one-person game of peg solitaire played on a computer. Two popular board shapes are the 33-hole cross-shaped board, and the 15-hole triangle board—we use them as examples throughout. The basic game begins from a full board with one peg missing and the goal is to finish at a board position with one peg. First, we discuss ways to solve the basic game on a computer. Then we consider the problem of quickly distinguishing board positions where the goal can still be reached (“winning” board positions) from those where it cannot. This enables a computer to alert the player if a jump under consideration leads to a dead end. On the 15-hole triangle board, it is possible to identify all winning board positions (from any single vacancy start) by storing a key set of 437 board positions. For the “central game” on the 33-hole cross-shaped board, we can identify all winning board positions by storing 839,536 board positions. By viewing a successful game as a traversal of a directed graph of winning board positions, we apply a simple algorithm to count the number of ways to traverse this graph, and calculate that the total number of solutions to the central game is 40,861,647,040,079,968. Our analysis can also determine how quickly we can reach a “dead board position”, where a one peg finish is no longer possible.
💡 Research Summary
The paper investigates the classic one‑person puzzle Peg Solitaire from a computational perspective, focusing on two widely studied board geometries: the 33‑hole cross‑shaped board (often called the English board) and the 15‑hole triangular board (the Cracker Barrel board). The authors begin by formalizing the game: a board is represented as a binary vector where each bit indicates the presence or absence of a peg. For the cross board this yields a 33‑bit mask (stored in a 32‑bit integer with one spare bit), and for the triangle board a 15‑bit mask. This compact representation enables constant‑time evaluation of legal jumps using simple bit‑wise operations.
Two algorithmic approaches are described. The first is a straightforward depth‑first search (DFS) that recursively enumerates all possible jumps from a given position, backtracking when no further moves are possible. To avoid revisiting identical configurations, a hash table (or a bit‑set) records visited states. While this method is sufficient for the 15‑hole board—where the total number of reachable positions is modest—it becomes infeasible for the 33‑hole board because the search space explodes into the billions.
To overcome this limitation the authors introduce the concept of a “winning board set.” Starting from the goal configuration (a single peg) they perform a reverse search: each reverse move restores a peg that was previously jumped over and removes the peg that performed the jump. By iteratively applying all reverse moves they generate every board position from which a one‑peg finish is still possible. The resulting set is dramatically smaller than the full state space: 437 positions for the triangular board and 839,536 positions for the cross board. Storing this set in memory allows an O(1) lookup to decide whether a given position is “winning” or “dead.” Consequently a computer opponent can instantly warn a human player if a contemplated jump would lead to a dead end.
With the winning set in hand the authors construct a directed acyclic graph (DAG) whose vertices are the winning positions and whose edges correspond to legal forward jumps. Because the graph contains no cycles, a topological ordering exists. By processing vertices in topological order and applying dynamic programming, the number of distinct solution paths from any start position to the goal can be accumulated. For the classic “central game” on the 33‑hole board (initial vacancy at the central hole) this calculation yields exactly 40,861,647,040,079,968 distinct solutions—an exact count that fits comfortably within a 64‑bit integer.
The paper also formalizes the notion of a “dead board,” defined as any configuration that does not belong to the winning set. Detecting a dead board reduces to a single membership test. Moreover, the authors compute the minimal number of moves required to reach a dead board from any given position using a breadth‑first search on the reverse graph. This information can be used to provide real‑time feedback in interactive solitaire software, alerting the player when a move brings the game dangerously close to an inevitable loss.
In the discussion, the authors argue that their techniques are not limited to the two boards studied. Any peg‑solitaire variant that can be encoded as a finite binary mask can be analyzed with the same reverse‑search and DAG‑counting methodology. They suggest extensions such as parallelizing the reverse search across multiple cores, exploiting GPU‑accelerated bit operations, and integrating machine‑learning models to predict promising moves based on the structure of the winning graph. Finally, they propose that the exact solution counts and the size of the winning sets provide new quantitative measures of puzzle difficulty, which could be useful for designing new board layouts or for benchmarking AI solvers.
Comments & Academic Discussion
Loading comments...
Leave a Comment