Question: Function Name: goFish Inputs: 1. ( double ) A 1xN vector of the cards in player ones hand 2. ( double ) A 1xN vector

Function Name: goFish Inputs: 1. ( double ) A 1xN vector of the cards in player ones hand 2. ( double ) A 1xN vector of the cards in player twos hand 3. ( double ) A 1xM vector of the cards in the deck Outputs: 1. (char ) A string stating which player won 2. (double) A 1x2 vector of the final score Function Description: You and your friend are super bored playing Go Fish at a normal speed so you decide to spice your game life up with some Go Fish, MATLAB style! You will be given a vector of the cards in each players hand -dont worry, jacks will be given to you as an 11, queens a 12 , and kings a 13- . As in normal Go Fish, the game will end once one player runs out of cards. Player one will always go first. Each player will ask the other for the first card in their hand, the first element in the hand vector. If the other player has one of the same type of card in their hand, remove the number from both hands and add a point to the proper players score. If the other player doesnt have the same type of card, first take the first card from the deck and append it to the end of the hand, then take the card at the front of that players hand and move it to the end of the hand (this makes sure they dont ask for the same card twice in a row). Repeat this process until one player doesnt have any cards left. Before you play the game, ensure that the players' hands have no repeat cards. If they do have repeats, remove each pair of cards (if you have three of the same card in one hand, remove the first two instances of the card). Make sure that every time you draw from the deck, you check to see if it pairs with any other card in the hand. Anytime a player makes a pair, add a point to their score. The winner is the player with the most points at the end of the game, not the one who clears their hand first. If player one wins, output the string: 'Player 1 won!' If player two wins, output the string: 'Player 2 won!' If it is a tie, output the string: 'It's a tie!' Example: >> [winner,score] = goFish([1,2],[2,3],[1,4,4,3]) score = [1,1] winner = 'It's a tie!' %Player one asks player two for a 1. Player one draws a card from the deck %and gains a point because it matched a card in player ones hand. player two %asks player one for a 2 and gains a point. The game then ends

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!