Reference no: EM132702782
An assignment that uses data structures to solve a triangular peg puzzle:
The puzzle we will solve is a simple peg jumping puzzle that looks like this:
There are a total of 15 holes in the board. One hole is always left open when setting up the pegs.
Pegs are removed by jumping as in checkers. You select one peg and jump over another to an open hole. The jumped peg is then removed. The arrow on the image shows a valid jump.
The goal is to empty all but one of the pegs off the board.
The open hole at the start of the puzzle can be any hole on the board. It is possible to clear all but one peg off regardless of where the starting hole is located.
Your program will get a solution for each of the 15 holes in the board and will display it as shown in the requirements.
It must find a solution for all 15 holes and not create one determined solution.
Requirements:
Must be in C# ONLY , no java or c++
You may use any of the data structures we have covered in class in your program. Your code MUST contain at least one data structure. (You will probably need more than one.)
You MAY NOT use arrays in your solution.
You will use a GUI to display your results.
The sole purpose of the GUI is to display the results.
The solution of the puzzle will take place in other classes. You will lose points if you do any of the puzzle solutions inside of the GUI event handler. Your event handler code should instantiate an object that solves the puzzle and can call the object's methods to solve the puzzle and get the results back.
You should update the text box in the GUI each time you solve for one of the holes. (Note that the update may not immediately appear in the textbox. That's not considered a problem.)
You will need to solve the puzzle for each available starting hole. For the sake of having a common frame of reference, we will number the holes in the board from 0 to 14, starting from the top.
As you get each solution, you will update the GUI with the sequence of jumps that were used to solve the puzzle. See the sample GUI image to see the format for the moves.
There is a performance requirement for this assignment: your program must be able to get a solution that leaves only a single peg for each of the 15 holes in less than 2 minutes. (That's 2 minutes to generate all 15 solutions, not 2 minutes for each one.) [In case you are worried about the performance requirement, the record for solving all 15 permutations of the puzzle is 6 milliseconds, done by a student four years ago.]
You may not hard code the solutions for each hole. Each must be generated by the program during execution.