Question: This is supposed to be programmed in MATLAB. This is the criteria: You are each to write and submit an m-file which plays the game
This is supposed to be programmed in MATLAB. This is the criteria:
You are each to write and submit an m-file which plays the game Crazy 8s (one user versus the computer). The game is played as follows:
1) Each player is dealt 7 cards from a standard 52 card deck.
2) One card is turned up from the remaining non-dealt down-pile to create the first card in the up-pile, and either the computer or the person is randomly chosen to go first.
3) A player may play any of their cards if it matches either the number or suit of the top card on the up-pile. For example, if the top card is the seven of spades, one can play either a 7 (any suit), or a spade (any number).
4) At any time, a player may play an 8 of any suit and call the suit of their choice (independent of the suit of that 8). Thats why its called Crazy 8s. The next play must be another 8 or the suit that was chosen. Note that if an 8 is the first card to start the game, then that suit (or number) must be played.
5) If a player has a card they can play, they must play a card.
6) If a player cannot play a card, they draw a card from down pile. If they can play that card, they do. If not, it is the other players turn.
7) The game is won when one player plays their last remaining card.
Note that there are several tasks such as the initial deal, determining who goes first, how a player can indicate which card they will play, how the computer will check if the card is legal, how the computer with update the playing board, how the computer will decide which card to play, how the computer will reshuffle the up-pile when/if the down-pile runs out of cards, how the computer will tell the player they must play a card if they have a card they can play but try to draw a card, etc.
Will be very much appreciated if this can be done.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
