Prog 2: Great 13

Create a text-based version of the Great 13 puzzle (scroll down on that page to find "Hoppers Board"), patented by William Breitenbach in 1899, distributed more recently by ThinkFun games.

Get started using the starter code given in Zybooks section 4.33 Prog2: Great 13

Multiple examples of running this program are shown at the bottom of this page.

9/12 Added clarifying remark (shown in blue) that adjacent pieces must be in a horizontal, vertical or diagonal line
9/24 The winning configuration can be a single piece anywhere on the board. It doesn't have to be in the middle. This is in contradiction to the instructions given in the sample output.

Starter Code and Test Cases

Among other things, the starter code comments provide the proper sequence of error checking that will ensure your output matches the test cases. The error-checking sequence and the inputs used in testing and the points per test are as given below:

  1. (2 points) See if 'X' to exit was selected. Test input: x

  2. (3 points) See if 'R' to reset was selected. Test input: acg ida r acg x

  3. (5 points) Verify that pieces are adjacent and in a horizontal, vertical or diagonal line. Test input: feg ejg efg GAE HGF X

  4. (5 points) Verify the source has a piece. Test input: efg MJE hgf gkm lkj x

  5. (5 points) Verify the square being jumped has a piece. Test input: FGH efg hgf hgf ihg mkg x

  6. (5 points) Verify the destination is blank. Test input: efg hgf ACG gfe fgh kgc mli mkg x

  7. (10 points) Hidden input and output. This test makes multiple moves and then exits.

  8. (15 points) Hidden input and output. This test makes multiple moves.

  9. (5 points) Win the game. Test input: mkg ejm dgj mje lhd acg ida bgl efg lgb abe

The provided starter code also gives an example of how user input can be converted into uppercase using toupper(), which simplifies later comparisons since you now only need to compare against uppercase characters.

Notes:

  1. You should break up your program into pieces using functions. Suggestions for some of these are already given in the starter code.

  2. The board must be displayed and manipulated by using 13 separate variables representing the 13 locations on the board. You may not use arrays or vectors or C++ string variables to represent or manipulate the board. Failure to follow this constraint will result in a 15 point deduction.

  3. You may (but don't have to) make your program variables global variables. Global variables will be disallowed in future programs.

  4. Program inputs use an input buffer so your program should work correctly whether inputs are given one at a time or all pasted in when prompted for the first input. You don't have to do anything special for this as long as you are using cin into character variables to store your user input.

  5. When prompted for a move the user might enter 'x' or 'X' to exit the program, or 'r' or 'R' to reset the board. The starter code gives you an idea how to read in the first user input and check if it is 'X' or 'R' before reading in the other inputs.

  6. Output Messages: See the samples of output shown above on this page to make sure your output exactly matches the spacing and blank lines needed to pass the test cases.

    1. No matter the input or program behavior, at the very end your program should display Done.

    2. When the user enters 'x' or 'X' to exit the program, your program should display Exiting

    3. When the user enters 'r' or 'R' to restart the program, your program should display *** Restarting

    4. When the selected move pieces are not a valid adjacent combination, your program should display *** Pieces must be adjacent. Please retry

    5. When the source move piece is empty, your program should display *** Source must have a piece. Please retry

    6. When the jumped move piece is empty, your program should display *** Must jump a piece. Please retry

    7. When the destination move piece is not empty, your program should display *** Destination must be blank. Retry

    8. When the user wins the game display an extra blank line and then the message: Congratulations, you did it!

    9. When the user exits the program without winning then your program should display an extra blank line and the message Better luck next time.

  7. Don't forget to review the program grading criteria given in the syllabus. Once you've passed all the tests in Zybooks don't forget to submit your program into Gradescope so you can earn execution points.

Samples of Running Program

For your convenience you can also download the output shown below as a google document.
9/24: The winning configuration can be a single piece anywhere on the board. It doesn't have to be in the middle. This is in contradiction to the instructions given in the sample output that is shown below.

Program 2: Great 13 Samples of program running