Requirement
You are to develop an interactive game of Go Fish between two players. In Go Fish, each player takes turns asking for a card with a specific rank or face from another player. The goal is to form a book (a set of 4 cards with the same face or rank). The player with the most books at the end of the game is declared the winner. The gameplay for Go
Fish is described at https://en.wikipedia.org/wiki/Go_Fish. Your program should operate as follows.
Setup
Go Fish cards are represented as variables of the following type:
1 | typedef struct card_s { |
- You are allowed to add attributes to this definition, but not to remove any. You can represent colors by using card suits. Red: hearts; Yellow: diamonds; Green: clubs; Blue: spades. The action field is used to denote the function of action cards.
- The game is played with a standard 52-card deck.
- At the beginning, the user can choose to shuffle the deck or load a predefined sequence of cards from a file (for testing). The cards are stored in a file in a format of your choice. For instance, they could be stored in the form
- The deck is implemented by a dynamic list of cards. This can be a singly-linked or a doubly-linked list (recommended). The cards drawn from the deck are deleted from the list.
- Each player’s hand is implemented by a dynamic list of cards. The list is initially populated with the cards dealt to each player. The card drawn (played) by each player is added to (deleted from) the respective list.
- The pool of cards in the center is implemented as a dynamic list of cards that is shuffled at the beginning of your game. The cards drawn or discarded in the pile is added/deleted in a dynamic fashion.
Game Play
The gameplay is described at https://en.wikipedia.org/wiki/Go_Fish
Optional Features for Extra Credit
- Any number of players: Modify your code to work with more than two players. Look at the rule changes when more than 4 players participate (in terms of card dealing).
- Game variations: Implement at least four game variations, as they are described in the game description.
- Player automation: Automate one of the players to implement to play the game according to a winning strategy
- Graphics. Add graphics to your game. You can print cards using ascii art. For example.
Sample Execution
Note: You are encouraged to make your output look more appealing than what is given below. Your interface should display sufficient direction for a user to play the game. Get friends and family to play your game without much assistance.
It is very likely that you will not get the exact same code execution shown below. This is used to show you how the game should be played.