![]() ![]() Solving this puzzle will require the use of a technique known as backtracking to search through all possible sequences of moves, which is easy to implement using recursion. In this assignment, you will write a program that solves a classic puzzle, sometimes called the triangle puzzle or peg solitaire. It also provides an object oriented vestment to backtracking, in the form of a reusable class holding all the backtracking logic. The main principle of this program is to demonstrate the concepts of recursive function, inherently recursive problem and backtracking. The program, in fact, implements a simple backtracking algorithm DFS to search for a solution starting from the current disposition of the pieces on the board. One of the spaces in the triangle is left empty, and the object is to jump pegs, removing each peg jumped, until you are left with only one. The game consists of 14 pegs set in a triangle shape with 15 holes like bowling pins, but with one more row. This program allows you play Solitaire puzzle also known as Peg Solitaire Puzzle. The puzzle gained in popularity when the restaurant put one on every table to amuse patrons waiting for their food. It is also known as peg solitaire or the Cracker Barrel puzzle. Smith patented a triangular version of the game in 1891. The 15-hole triangle peg board game is a modern version of a game that has been played in Europe since the end of the 17 th century. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |