This is a reprint from 2004 where I wrote a variation of the Triangle Peg Solitaire game that can be played online from a NUTS talker. Then, as part of my Artificial Intelligence class, or maybe just for fun–I don’t remember–I wrote a program using recursion to find the solution and then find out how many solutions there are to this puzzle.
Triangle Peg Solitaire (seen in picture above) has been around for a while.
My first experience with it occurred long ago when my Grandmother and Grandfather Brown brought me one of these games. They are easily made from wood and golf tees, so they probably picked it up, cheap. Basically, you start with an empty hole and jump pegs until there is only one peg left. If you would like to play one of these games, but don’t want one of your own, they have the games on the tables at Cracker Barrel restaurants.
I labeled all of the holes A through O, and named combinations of three pegs (the jumper’s original hole, the peg being jumped and the ending hole) as moves. I modeled this and then wrote a C++ class to represent a board with holes. There were booleans that indicated whether there was a peg hole or not. Next, I produced some output functions to draw a picture of the peg board. Then, some functions that handled the moves and produced the history of moves made. Finally, I made the program store and produce a pegboard score based on the pegs left behind.
Now that I had a working PegBoard program to play Triangle Peg Solitaire, I remembered a story told by my Artificial Intelligence professor, Dr. Adams, in 2003 and how a relation of his was asked to write a program to solve something about this game. I figured it would be a good idea to make my program count the number of ways to leave just one peg. I added an additional function that would replay a history of moves so i could pass a recursing object the history file and start from the same point. Then, using the set of “resulting available moves”, I used the old recursion saying “Work on the CAR, Recurse with the CDR”. I pulled off the first move and recursed the rest.
Okay, unfortunately, when the hard drive for the server crashed, so did all my PegBoard stuff. I was able to recover some of the stuff from my “backups” and from the Google cache. I re-linked the files and all as you can see, but this page is not complete. When time permits or inspiration hits, I may come back to this and fix it up, but unfortunately, I’ve got other projects that need time. Feel free to email me or contact me if you want more information on this project though and I’ll try to help you out, but unless there’s some demand, this page is going to stay in its current form.
I said in this section that there were 438,984 possible solutions, all of which are listed in the attached text file.
Here are some of the files that I was able to recover:
- PegBoard.cpp Triangle Peg Solitaire Code
- http://rec-puzzles.org/new/sol.pl/competition/games/peg.solitaire Dead Link to someone else’s page. I don’t remember why I linked to this guy, but I did.
NUTS Talker Pegboard:
Here is some NUTS 2.3 Talker code for Triangle Peg Solitaire:
Unfortunately, most of the page is gone. But you get the general idea. Map the search space and then blind search through the whole thing until you get a result.