Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function Name: ?incredibleUno Inputs: 1.(?char) The name of the current player 2. (?char) A letter representing the color of the card on the top of

Function Name: ?incredibleUno

Inputs: 1.(?char) The name of the current player

2. (?char) A letter representing the color of the card on the top of the discard pile

3. (?double) A number representing the value of the card on the top of the discard pile

4. (?char) A 1xM character vector representing the colors of the cards in the players hand

5. (?double) A 1xM vector representing the values of the cards in the players hand

Outputs: 1. (char) A description of what was played

Background: The Incredibles are playing Uno for their family game night. In Uno, the point of the game is to be the first person that runs out of cards, and luckily for these heros, one of MATLABs superpowers is the ability to find the best moves to make in one play.

Function Description: Given the color and number of the card on top of the discard, write a function that finds the best way to get rid of the most cards in your players hand and outputs the move.

Here are the rules of this Uno game: ? The next played card must match the top card's color or number. ? Multiple cards can be played if and only if they have the same number as the top card. ? Draw from the pile if nothing can be played. When ?'?Frozone' can't play, he will forfeit the game and get up to leave, saying ?'Wheres my super suit?!'

Based on the rules and your inputs, you will output one of the following strings: Scenario Output Played number card(s) ' played <# of cards played> # card(s).' Played color card ' played 1 card.' Had to Draw a Card ' had to draw a card...' Frozone Exception 'Where's my super suit?!'

Continued...

Homework 06 - Conditionals

Example: [out1] = incredibleUno('Mr. Incredible', 'r', 8, 'rbgyb', [7 8 6 8 3]) >> out1 = 'Mr. Incredible played 2 #8 cards.'

Notes: ? The possible card colors are as follows: ? red --- ?'r' ? blue --- ?'b' ? yellow --- ?'y' ? green --- ?'g'

? Since the goal is to play as many cards as possible, prioritize having the same number as the top card before having a card with the same color.

? If a player plays one card, the last word of the output string should be?'card'?, but if the player plays more than one card, the last word should be ?'cards'?.

Hints: ? The second output for the ?max()? function might be helpful.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions

Question

In your opinion, are any additional laws needed in these areas?

Answered: 1 week ago