Prog 3: Pentago
2/19/17 Added further point breakdown to specify that your program must check for a tie, in the situation where a rotation gives winning configurations for both players at the same time. Shown in blue.
2/27/17 Added the naming convention if you are working with a partner, shown in red below.
Create the interface to allow two human players to play the game of Pentago. This is played on a 6 x 6 board, where the objective is to be the first to get 5 in a row. Instructions and sample play are shown below.
Running the program looks like:
Author: Dale Reed Program: #3, Pentago TA: Karla Templar, Tues 10 Feb 5, 2017 Play the two-player game of Pentago. Be the first to get 5 in a row. Pentago is played on a 6 by 6 board, divided into four 3 by 3 quadrants. There are two players, X and O, who alternate turns. The goal of each player is to get five of their pieces in a row, either horizontally, vertically, or diagonally. Players take turns placing one of their pieces into an empty space anywhere on the board, then choosing one of the four board quadrants to rotate 90 degrees left or right. If both players get five in a row at the same time, or the last move is played with no five in a row, the game is a tie. If a player makes five a row by placing a piece, there is no need to rotate a quadrant and the player wins immediately. Play online at: https://perfect-pentago.net Purchase at: www.mindtwisterusa.com For each move provide four inputs: row (A-F), column (1-6), quadrant (1-4), rotation direction (L or R) For instance input of B32R places the next piece at B3 and then would rotate quadrant 2 (upper-right) to the right (clockwise). At any point enter 'x' to exit the program. 1 1 2 3 4 5 6 2 ----------- A: . . . . . . :A B: . . . . . . :B C: . . . . . . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 1. Enter row, column, quadrant, direction for X: c31r 1 1 2 3 4 5 6 2 ----------- A: . . . . . . :A B: . . . . . . :B C: X . . . . . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 2. Enter row, column, quadrant, direction for O: A5 3R 1 1 2 3 4 5 6 2 ----------- A: . . . . O . :A B: . . . . . . :B C: X . . . . . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 3. Enter row, column, quadrant, direction for X: A51R *** That board location is already taken. Please retry. 3. Enter row, column, quadrant, direction for X: G05h *** Invalid move row. Please retry. 3. Enter row, column, quadrant, direction for X: c05h *** Invalid move column. Please retry. 3. Enter row, column, quadrant, direction for X: c25h *** Selected quadrant is invalid. Please retry. 3. Enter row, column, quadrant, direction for X: c21h *** Quadrant rotation direction is invalid. Please retry. 3. Enter row, column, quadrant, direction for X: c2 1r 1 1 2 3 4 5 6 2 ----------- A: X . . . O . :A B: X . . . . . :B C: . . . . . . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 4. Enter row, column, quadrant, direction for O: b 6 4 l 1 1 2 3 4 5 6 2 ----------- A: X . . . O . :A B: X . . . . O :B C: . . . . . . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 5. Enter row, column, quadrant, direction for X: c53l 1 1 2 3 4 5 6 2 ----------- A: X . . . O . :A B: X . . . . O :B C: . . . . X . :C D: . . . . . . :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 6. Enter row, column, quadrant, direction for O: d6 3r 1 1 2 3 4 5 6 2 ----------- A: X . . . O . :A B: X . . . . O :B C: . . . . X . :C D: . . . . . O :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 7. Enter row, column, quadrant, direction for X: c41r 1 1 2 3 4 5 6 2 ----------- A: . X X . O . :A B: . . . . . O :B C: . . . X X . :C D: . . . . . O :D E: . . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 8. Enter row, column, quadrant, direction for O: e14l 1 1 2 3 4 5 6 2 ----------- A: . X X . O . :A B: . . . . . O :B C: . . . X X . :C D: . . . O . . :D E: O . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 9. Enter row, column, quadrant, direction for X: c6 2r 1 1 2 3 4 5 6 2 ----------- A: . X X X . . :A B: . . . X . O :B C: . . . X O . :C D: . . . O . . :D E: O . . . . . :E F: . . . . . . :F ----------- 3 1 2 3 4 5 6 4 10. Enter row, column, quadrant, direction for O: f2 3l O has won the game! 1 1 2 3 4 5 6 2 ----------- A: . X X X . . :A B: . . . X . O :B C: . . . X O . :C D: . . . O . . :D E: . . O . . . :E F: . O . . . . :F ----------- 3 1 2 3 4 5 6 4 Thanks for playing. Exiting...
Notes & Recommended Steps
Your program must represent the board using an array, must do error checking on input as shown above and must detect when five in a row are detected.
(For those of you using Visual Studio, you may not submit code that includes scanf_s or #include stdafx.h which are Visual Studio-specific commands, and are not standard C. Using these will result in a 15 point deduction, since we then have to manually edit your programs before we can test them.)
I suggest you write your program using the following steps for the 55 points for program execution:
Print out your customized identifying information and the instructions exactly as shown above.
Declare the array you will use to store the board. Use a loop to initialize board array values to all be the '.' character.
(5 points) Display the board. Then put the board display lines of code in a function. No further points are possible without this working.
(5 points) Read in user input to allow placing an 'X' anywhere on the board
(10 points) Handle making a rotation of the chosen quadrant in the chosen direction. Without rotations working, points will not be awarded for checking for a win.
(2 points) Handle 'x' for exit as the first input. Input in both lower and upper case should be accepted. Input of 'x' is also needed if play reaches the end of the game without a win. Your program does not need to detect this condition, but can depend on the user to move entering 'x' to exit in that situation.
(5 points) Similar to the above now allow 'O' to make a move, along with a quadrant rotation
(3 points) Add the move number variable that updates each time a move is made.
(5 points) Use functions and a loop to repeat the move-making part of your program, appropriately eliminating redundant code while maintaining the clarity of your program.
(10 points) Detect input values that are out of range for 1. row, 2. column, 3. quadrant and 4. rotation direction. 5. Providing input all concatenated together must work, as well as input all separated by spaces. (2 points for each of the five listed checks.)
Since the instructions specify moving "into an empty space", failure to implement this check will result in a 2 point deduction.
(10 points) Detect when a sequence of 5 in a row is created on the board, either when placing a piece or after rotating a quadrant.
(3 points) A sequence of 5 in a row should be detected in any row, column or diagonal where it is found.
(4 points) If both players get a winning configuration at the same time, the program must indicate it is a tie.
(3 points)If a winning configuration is created when placing a piece, then the rotation part of the move should not be done.
Test Input
The following input was used the the above-given run of the program, testing input validation and resulting in a win for 'O':
c31r A5 3R G05h c05h c25h c21h c2 1r b 6 4 l c53l d6 3r c41r e14l c6 2r f2 3l
Both win at same time, resulting in a tie: b23r a53l b13l b63l b33l d63l e24l e12r e31r f23l
Submit your program
The name of the program you will turn in should be prog3Pentago followed by your netid and the .c file extension. In other words, if your netid is reed then your program would be called: prog3Pentagoreed.c
If you are working with a partner, include both of your netids, separated by an underscore. In other words if reed were working with jobs, then the name would be prog3Pentago_reed_jobs.c
You must also zip up the file you turn in, which typically is done by right-clicking on it and choosing the "compress" option. After zipping your program (e.g. prog3Pentagoreed.c), you will likely end up with a file called something like:
prog3Pentagoreed.zip
Only turn in this single file, turning it in on Blackboard into the assignment Program 3. Please do not put it into a folder before zipping it, rather zip the one file by itself.
After submitting your program to Blackboard, select it to download it from Blackboard so you can verify that you uploaded the correct file. You will not receive credit for this program if you submit the wrong file!
Failing to follow these naming conventions and failure to turn in a zip file will result in a 10 point deduction, even if everything else is perfect in your program.