Peg Solitaire

Automatic resolution of Peg Solitaire

I had a Peg Solitaire board and I remind that I solved it only once, that is, to leave only a piece at the end. After that, I couldn't solve the problem again. I developed the program below to solve the problem automatically. I had the curiosity of knowing which steps were the necessary to solve the problem and leave a only piece at the end.

The program that I wrote solves not only the standard english initial configuration pattern, but it also solve other possible initial configurations through a definition file (Problem.txt). The program will analyze the possibilities and indicate the solution that it finds.

Figura: The input configuration file Problem.txt

To execute the program it is necessary to download the 2001-02-PegSolitaire.zip file below and to expand it in some directory. In the "bin" directory there will be a file called PegSolitaire.jar. If there is a "Java Runtime Environment" already installed then it is only necessary to double click the PegSolitaire.jar file. The program will read the "Problem.txt" file automatically. To see the execution of the program I recommend to open a DOS window, to go to the "bin" directory and to execute java -jar PegSolitaire.jar.

Figura: Reading the Problem.txt file and execution of the program.

When the window appears there will be two buttons "Start" and "Stop." Obviously, the "Start" button begins the search for a solution.

Figura: Control window.

During the search for a solution the program show how many possibilities have been analyzed.

Figura: Control window.

To stop the search for a solution it is only necessary to click on the "Stop" button. If the program finds a solution then he will create a "Solution.txt" file with the indication of each movement of the solution.

Figura: Execution of the program.

Download the Peg Solitaire
Information Content

Name

Automatic resolution of Peg Solitaire

Implementation date

Fevereiro 2001

Size

137Kb

Executable and source code

2001-02-PegSolitaire.zip

Language or Compiler

Java