程序代写代做 game PROBLEM 1: Match-making [50points]

PROBLEM 1: Match-making [50points]
For the first portion of this problem, you will implement a simple version of our game Ochos Locos. For this simplified version, there will be three players. The rules of the game are as follows:
Basic Rules of the game Ochos Locos
Setup:
¡ì The game starts with a shuffled deck of 32 cards (given to you).
¡ì Each player is dealt 5 cards and one card is upturned in the discard
pile.
¡ì The remaining cards from the deck are placed in a draw pile
Play:
¡ì On a player¡¯s turn, they must play a card (if one exists) that matches either the colour or number of the card played just before:
o If the player has more cards in their hand of the matching number than they do of the matching colour:
¡ì They will choose to play a card of matching number. (e.g. 4)
¡ì They will play the card of that number that they have which comes first
in rainbow order: red-yellow-green-blue. (i.e. R4-Y4-G4-B4)
o If the player equal or more cards in their hand of the matching colour than they do of the matching number:
¡ì They will choose to play a card of matching colour.
¡ì They will play the card of that colour that they have which comes first
counting order: 1-2-3-4-5-6-7-8.
¡ì If a player does not have a card that they are able to play, they pick up a new card from the top of the draw pile (if one exists, pass if not).
2

Example 1 (more cards of matching number):
Suppose the upturned card in the discard pile is a Green-3 (G3) and that the player¡¯s hand has the following cards in it:
R3 R7 Y3 Y7 G8 B3 B7 B8
The player will look at their hand and count the number of red cards (2 red cards: R3 & R7)
and the number of 3s (three: R3, Y3 & B3).
¡ì Since they have more threes than red cards, they will choose to play a three card, but which colour?
o They have a red, yellow and blue 3, so they choose to play the red because it comes first in rainbow order (red-yellow-green-blue) , choosing first red then yellow, then green and lastly blue.
The player will choose to play the card B3. Example 2 (more cards of matching colour):
Suppose this time the upturned card in the discard pile is a Blue-8 (B8) and that the player¡¯s hand is the same as before with the following cards in it:
R3 R7 Y3 Y7 G8 B3 B7 B8
The player will look at their hand and count the number of blue cards (3 blue cards: B3, B7 &
B8) and the number of 8s (two eights: G8 & B8).
¡ì Since they have at least as many blue cards as eights, they will choose to play a blue card, but which number?
o They have a blue 3, 7 and 8, so they will count the total number of threes, sevens and eights in their hand and choose to play the number which they have the most of.
In this example, they have 3 threes, 3 sevens and 2 eight cards, so they have a tie!
¡ì Since there is a tie between the number of threes and the number of sevens, they would pick between the those numbers in number order from low to high, choosing to play the three card.
The player will choose to play the card B3. Example 3 (no match in hand):
Suppose this time the upturned card in the discard pile is a Yellow-4 (Y4) and that the player¡¯s hand has the following cards in it:
R1 R2 G3 G5 B6 B7 B8
The player has no cards that match they Yellow-4 in either colour or number (i.e. they have
no cards they are either yellow or the number 4). They must DRAW a card from the draw pile.
3

Input
¡ì Hand of player one (initially 5 cards)
¡ì Hand of player two (initially 5 cards)
¡ì Hand of player three (initially 5 cards)
¡ì First card in the discard pile on which to you play on (1 card)
¡ì Remaining cards in the draw pile (top to bottom, all remaining cards)
Processing
1. Outputthestartingcardonthediscardpile.
2. Startingwithplayerone,decidewhichcardtheywillplay(orpickupfromthedraw
pile) and output their choice (or DRAW if they have no match and must try to pick up
a card from the draw pile).
3. Repeatthisforeachplayeruntilaplayerhasnomorecardsintheirhand.This
player becomes the winner of the game.
Output format
0: {First/starting card on the discard pile} 1: {Card played by player 1*}
2: {Card played by player 2*}
3: {Card played by player 3*}
1: {Card played by player 1*} 2: {Card played by player 2*}
3: {Card played by player 3*} :
:
:
{N}: {Last card played by player N} (WINNER)
Where N = 1,2, or 3, the player first able to play all of their cards and empty their hand
* If no card is able to be played by a player, output DRAW on their turn and pick up a card from the draw pile (if one exists).
4

Sample input
Sample output
New hand after play
Y3 Y7 Y8 B1 B7
R8 Y1 G4 G8 B8
R3 R4 R7 Y6 B5
B3
R2 G5 B6 Y5 G3 G2
… Y4R1G1Y2G6
… B4R5G7R6B2
0: B3
1: B1
2: B8
3: B5
1: B7
2: DRAW
3: R7
1: Y7
2: Y1
3: Y6
1: Y3
2: DRAW
3: R3
1: DRAW
2: R2
3: R4 (WINNER)

1: Y3 Y7 Y8 B1 B7 2: R8 Y1 G4 G8 B8 3: R3 R4 R7 Y6 B5 1: Y3 Y7 Y8 B7
2: R2 R8 Y1 G4 G8 3: R3 R4 R7 Y6
1: Y3 Y7 Y8
2: R2 R8 Y1 G4 G8 3: R3 R4 Y6
1: Y3 Y8
2: R2 R8 G4 G5 G8 3: R3 R4
1: Y8
2: R2 R8 G4 G5 G8 3: R4
R1 R4 G2 G8 B2
R2 R8 Y7 Y8 B3
R3 R6 Y3 G4 G5
B6
Y2 B7 Y1 G6 Y5 G7
… R5R7G1Y4B5G3
… B1B8B4Y6
0: B6
1: B2
2: B3
3: R3
1: R1
2: R2
3: R6
1: R4
2: R8
3: DRAW
1: G8
2: Y8
3: Y2
1: G2 (WINNER)

1: R1 R4 G2 G8 B2 2: R2 R8 Y7 Y8 B3 3: R3 R6 Y3 G4 G5 1: R1 R4 G2 G8
2: R2 R8 Y7 Y8
3: R6 Y3 G4 G5
1: R4 G2 G8
2: R8 Y7 Y8
3: Y2 Y3 G4 G5
1: G2 G8
2: Y7 Y8
3: Y2 Y3 G4 G5
1: G2
Note: In the ¡°New hand after play¡± column, cards are shown (for fun!) in their colour. An underlined card (e.g. B7) was just added to the player¡¯s hand and a card with a strikethrough (e.g R2) was just played from the player¡¯s hand. I have made bold (e.g Y2) any draw pile cards that were used.
5