A standard deck of 52 cards has four suits and thirteen ranks in each
suit. The suits are Clubs, Diamonds, Hearts and Spades. The
ranks are Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack,
Queen, King. In the game of Go Fish!, the suits have no impact on
the playing of the game; however, your program must maintain and show the
suit information for each card. For a shorthand notation of the cards,
each card is identified by a two character sequence. The first character
is the rank while the second character is the suit. The characters
for the ranks and suits are as follows. The alphabetic characters
could be in either upper or lower case.
Rank Characters | Suit Characters |
---|---|
|
|
At the start of the game each player is delt 5 cards. The cards held by a player are called the player's "hand". The remaining cards are placed in a pile called the "fishing pool". The user gets the first turn of the game. A turn consists of asking a specific player for a card of a specific rank. The rank asked for must be a rank of a card already held in the hand of the asking player. If the other player has one or more cards of this rank, all of these cards are given to the asking player and the asking player gets another turn. If the other player does not have a card of this rank, the asking player is told to "Go Fish!". The asking player then takes a card from the "fishing pool" and adds this card to the cards in the player's hand. If the cards taken from the "fishing pool" is of the same rank as what was asked for, the asking player gets another turn; otherwise, the turn passes to the player sho said "Go Fish!".
As soon as a player collects a book of 4 cards of the same rank, this must be shown and those cards are removed from the player's hand. The game continues until either a player has no cards left in their hand or the fishing pool is emptied. A player's hand can be reduced to no cards by either forming a book from all cards in the players hand, or giving up all of their cards to another player. If the other player now has book, the book is shown and removed from the player's hand before the game is over. The player with that created the most books during the game is the winner.
You are to write this program in C++. You are to use the C++ class elements for all type definition, except for any enumerated types you may create. This program will be interactive with the user (no data files will be used with this program). The interactive commands are bolded in the following descriptions. If the commands are alphabetic characters, they can be given in either upper or lower case.
n 4This example command would have 5 players, the user and 4 opponents. This command is will take effect at the start of the next game. Therefore you cannot add or remove an opponent during the middle of the game. If multiple n commands are given during the play of a game, the last n command given will be the one used.
a 3 tThis command is only valid during the playing of a game.
Your program is to automate the playing of the game as much as possible. You will need to use the given Artificial Intelligence algorithm to determine the playing of each computer opponent. For each computer opponent, your program will need to keep track of which player asked for cards of each rank last. We will only keep track of the most recent time a rank was requested. Since Go Fish! is mostly a memory style game, if we gave the computer opponent too much memory they would be very hard to beat. Whenever a rank is asked for, all computer players will update their memory to reflect this request. Since this information is the same for all players, your program only needs to have one set of memory that is shared by all players.
During a computer player's turn, it will first check its "memory" to see if some other player has requested a rank that it is holding. If so it will request that rank from the other player. If the player does not have any ranks that it is holding which have been requested by another player, it must then randomly choose a rank that it is holding and randomly select another player to make a request for that rank. Once a request is made, the player will either be given all cards of that rank from other player or told to "Go Fish!".
Your program is automate computer player's requests, the movement of all cards, the removal of a book of four cards from any player's hand and the drawing of a card from the fishing pool. The play of each turn is to be automated except for the user asking for a rank from another player. A descriptive message is to be output for each of these actions. The user's prompt must include showing the user his or her hand in some sorted order. Once the user loses his or her turn, there will be a number of messages output to the screen informing of the action of the subsquent turns. This will continue until the user gets another turn and is once again prompted to ask far a rank from another player. During the user's turn, they can enter any command they wish. If an invalid or unknown command is given, output an appropriate error message.
At the end of the game, list the number of books formed by each player and show the cards still in each players hand. Then prompt the user for the next command. If an invalid or unknown command is given, output an appropiate error message.
This program will require the use of multiple source code files, separate compilation and the use of a makefile. The division of the subroutines between the multiple source code files must be logical. One suggestion would be to have the game playing rountines in one source code file and the command interface commands in another source code file. This suggestion only specifies two source code files, you may wish to have more that two source code files for your program. Note: a "source code file" is not the same as a "header file". Source code files will have a file extension of .cpp (or .c, .C, .CC, etc.), while a header file will have a file extension of .h. Your program must separately compile the source code files and then link them together. Using a #include statement with a source code file will NOT satisfy this requirement.
This program will also require a 1-2 page write up of the data structures used in the program and the logical division of your program into multiple source code files (i.e. which routines are where). Remember that this write-up is to be written in ASCII format and is to be electronically turned in with your program. The name of this file should be "readme.txt". Also recall that your program will be given to another student to write a critique. Therefore, it is suggested that you do not include your Social Security Number in your program. Instead use your name and your EECS User ID to identify yourself.
Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.
The work you turn in must be 100% your own. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to another person nor may you look at any other person's written code.
You are to submit this project using the EECS Department's UNIX machine's turnin command. The project name for this assignment is mp2. Be sure to submit all source code, header files, make file as well as your program description. Failure to turnin all required pieces will result in a lower grade for the assignment.