Prog 5: C GridMatch
(You may again work with a partner on this program. Note that you must send us an email with the partner names at least one week before the program due date.)
Again write the Grid Match program (Program #4) except this time write it in C using a text-based interface. Running the program should look like:
Author: Dale Reed Date: 3/29/12, CS 102 Spring '12 System: C++ Play the game of Grid Match. The object is to make as many squares as possible disappear from the board. On each move choose a particular square using the row,column coordinates. That square and any adjacent similar squares will all be blanked out if there are 3 or more of them. Squares above the empty squares then slide down. Empty columns slide to the left. Input of 'r' will restart the game and re-randomize the board, and input of 'x' will exit the game. 0 1 2 3 4 5 6 7 8 9 --------------------- A | # + - @ # @ - - - @ | A B | # # # + # + + - + @ | B C | + @ - # @ - # @ - + | C D | + - + - # @ + + + - | D E | + + - # # @ # + # @ | E F | + @ - # # + + # # - | F G | @ + - - @ - @ - @ @ | G H | - # - # - - - # # @ | H --------------------- 0 1 2 3 4 5 6 7 8 9 1. Enter the row and column (e.g. c5) or 'r' to reset or 'x' to exit -->
Notes & Grading:
If you have questions about what a C program like this might look like then please take a look at solutions from previous semester assignments for CS 102.
The 55 points for execution will be distributed as follows:
(5 points) Get the board to display as shown above, where the characters are randomly selected among the 4 characters: @ # - +
To do this you will want to use the C rand() function and then use mod to give the remainder when dividing by 4. Display the move number when prompting for the next move.
(5 points) User input of row and column serve to select an individual square which is blanked out. Exit and Reset should also work. I recommend you use two char variables to store the user input. Read the first user input and then check to see if it was 'r' or 'x'. If not then go on to read the second user input. You do not need to do any other error checking to validate input.
(15 points) When a square is selected check if it is part of a group of 3 or more. If so blank out all the characters in that group. If a square is not part of a group of 3 or more, then no square should be blanked out and a message should be given, allowing the user to retry the move without incrementing the move number.
(15 points) Once a cluster of squares are blanked out then have any squares above them "slide down".
(15 points) If an entire column is left blank, have all columns to the right of it slide left to fill in.
Turn this program in using Blackboard into the "Prog 5: GridMatch in C" Assignment.
Extra Credit: (up to 10 more points)
Find a graphics library in C and create a graphical interface for this program.