![]() Many of us might now the board game peg solitaire and might even have one of its many variants at home. Peg solitaire is a one-player game played on a board with holes and pegs. The number of holes depends on the board variant. For example, the English variant consists of 33 holes while the typical diamond variant consists of 41 holes. In each move the player selects one peg and jumps – either vertically or horizontally, not diagonally – with this peg over a directly neighboring one into an empty hole. The neighboring peg is then removed, leaving an empty hole. To clear a peg, jump over it into an empty space. Your goal is to clear all of the pegs but one. ![]() Remove pegs by jumping over them, just like Checkers, until only one peg remains in the center of the board. So, in each move, one peg jumps 2 holes further and the peg in-between is removed. Peg solitaire is a Chinese-Checkers-style logic and strategy puzzle. Once no move is possible any longer, the game is over. This is the case when there is no pair of pegs which are orthogonally adjacent or if only one peg is left. The English variant, as shown below, has one additional rule: In order to win, it is not sufficient that only one peg is left in the end this peg also has to be located in the center of the board. The English variant is shown in the figure below.Įven though the rules of the game are rather simple, finding a solution is not trivial. Many players need quite a few attempts in order to find the solution for the English peg solitaire. The solution for the diamond shaped board is even more tricky. When I started programming a few years ago, English peg solitaire was one of my first projects. Since I could never solve the game myself I decided to write a solver for the problem. The code is attached at the end of this post. It is not nice nor efficient, but surprisingly finds the solution in less than a second.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |