Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 1: Match-making[50points] Basic Rules of the game Ochos Locos Setup: The game starts with a shuffled deck of 32 cards (given to you). Each

PROBLEM 1: Match-making[50points]

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 players 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). Example 1 (more cards of matching number): Suppose the upturned card in the discard pile is a Green-3 (G3) and that the players 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 R3. Example 2 (equal or more cards of matching colour): Suppose this time the upturned card in the discard pile is a Blue-8 (B8) and that the players hand is the same as before with the following cards in it: R3 R7 Y3 Y7 G8 B7 B8 The player will look at their hand and count the number of blue cards (3 blue cards: 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 7 and a blue 8. Since 7 comes before 8 in counting order, they will choose to play the 7. The player will choose to play the card B7. Example 3 (no match in hand): Suppose this time the upturned card in the discard pile is a Yellow-4 (Y4) and that the players 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.

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. Output the starting card on the discard pile. 2. Starting with player one, decide which card they will play (or pick up from the draw 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. Repeat this for each player until a player has no more cards in their hand. This player becomes the winner of the game. image text in transcribed 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).

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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). Sample output New hand after play Sample input Y3 Y7 Y8 B1 B7 R8 Y1 G4 G8 B8 R3 R4 R7 Y6 B5 B3 R2 G5 B6 Y5 G3 G2 ... Y4 R1 G1 Y2 G6 ... B4 R5 G7 R6 B2 B3 1: B1 2: BS 3: B5 1: B7 2: DRAW 3: R7 1: 77 2: 3: Y6 1: Y3 2: DRAW 3: R3 1: DRAW 2: R2 3: R4 (WINNER) 0: B6 1: Y3 Y7 Y8 B B7 2: R8 Y1 G4 G8 Be 3: R3 R4 R7 Y6 B5 1: Y3 Y7 Y8 B7 2: R2 R8 Y1 G4 G8 3: R3 R4 R7 Y6 1: Y3 I YS 2: R2 R8 41 G4 G8 3: R3 R4 16 1: 13 Y8 2: R2 R8 G4 G5 G8 3: R3 R4 2: R2 R8 G4 G5 G8 3: R+ R1 R4 G2 G8 B2 R2 R8 Y7 Y8 B3 R3 R6 Y3 G4 G5 B6 Y2 B7 Y1 G6 Y5 G7 ... R5 R7 G1 Y4 B5 G3 ... B1 B8 B4 Y6 1: R4 2: R8 3: DRAW 1: 68 2: Y8 3: Y2 1: G2 (WINNER) 1: R1 R4 G2 G8 B2 2: R2 R8 Y7 Y8 B3 3: A3 R6 Y3 G4 G5 1: R R4 G2 G8 2: R2 R8 Y7 78 3: R6 Y3 G4 G5 1: R+ G2 G8 2: RE 77 78 3: Y2 Y3 G4 G5 1: G2 68 2: Y7 Y8 3: *2 Y3 G4 G5 1: 62 PROBLEM 2: Take Two [20 points] Now that you've become proficient at playing the game, we will start adding in extra rules. For this one, if a player plays any "two" card (R2, Y2, G2 or B2), the next player's turn is skipped and they must take two cards. You will apply the Rule of Two below: Rule of Two If the card last laid in the discard pile was numbered 2, the next player must choose between the following options: If they have another "two" card (R2, Y2, G2 or B2) in their hand, they will choose to play the one. o If they have more than one colour, they will pick in rainbow order: red- yellow-green-blue. If they do not have a "two" card, on their turn they are skipped and must draw two cards from the top of the draw pile. Input Same as in Problem 1. Processing Same as in Problem 1 with the following exception: If a player lay's down a card numbered 2, the next player must apply the Rule of Two as described above. Output format Same as in Problem 1 with the following exception: If a player lay's down a card numbered 2 and the following player is unable to play another "two" card, output: {N}: TAKE TWO Where N = 1,2, or 3, the skipped player that had to draw two cards. HINT: Start from Problem 1 and modify... Sample input Sample output New hand after play R1 R4 Y6 G8 B2 R2 R8 Y7 Y8 B3 R3 R6 Y3 G4 G5 B6 0: B6 1: B2 2: R2 3: TAKE TWO 1: R1 2: R8 Y2 B7 Y1 G6 Y5 G7 R5 R7 G1 Y4 B5 ... G3 B1 B8 B4 G2 1: R1 R4 Y6 G8 B2 2: R2 R8 Y7 Y8 B3 3: R3 R6 Y2 Y3 G4 G5 B7 1: R3 R4 Y6 G8 2: RO Y7 Y8 B3 3: R R6 Y2 Y3 G4 G5 B7 1: R4 Y6 G8 2: Y1 Y7 Y8 B3 3: R6 Y2 Y3 G4 G5 B7 1: 16 GB 3: R3 1: R4 2: DRAW 3: R6 1: Y6 PROBLEM 3: Going Wild! [10 points] Now that we have that sorted, we will really go "wild" and add in the crazy eights rule. If the last player plays any Loco Card, an "eight card (R8, Y8, G8 or B8), they can choose the colour to be played next. The player that follows must then either play another Loco Card (R8, Y8, G8 or B8) of any colour, or a card of the new colour chosen. The Loco Rule If a player is allowed to play one of their Loco Cards (R8, Y8, G8 or B8), they will. If they have more than one Loco Card, they will choose to play the eight card that comes earlier in rainbow order (red-yellow-green- blue). When a Loco Card is played, they get to choose a colour to follow (i.e. it behaves as if they 8 was painted in the colour chosen). The chosen colour will always be the first colour in rainbow order that will remain in their hand (if any) on their next turn (if no cards remain, they win). Input Same as in Problem 2. Input Same as in Problem 2. Processing Same as in Problem 2 with the addition of Loco Rule: If a player has an "eight" card (R8, Y8, G8 or B8) in their hand, the Loco Rule (above) is applied. Output format Same as in Problem 2 with the following exception: If a player lay's down a card numbered 8, output the chosen colour as follows: {N}: {colour of Loco Card}8 {Colour chosen: R,Y,G, or B} HINT: Start from Problem 2 and modify... Sample input Sample output New hand after play R1 R4 Y6 G8 B2 R2 R3 R6 Y4 G5 R5 R8 Y7 Y8 G2 B6 Y3 B7 Y1 G6 Y5 G7 B3 R7 G1 G4 B5 G3 B1 B8 B4 Y2 0: B6 1: B2 2: R2 3: G2 1: TAKE TWO 2: 65 3: R5 1: R1 2: R3 3: R8 LOCO Y 1: G8 LOCO R. 2: R6 3: DRAW 1: R4 2: Y4 (WINNER) 1: R1 R4 Y6 G8 B2 2: R2 R3 R6 Y4 G5 3: R5 R8 Y7 Y8 62 1: R1 R4 Y3 Y6 G8 B7 2: R3 R6 Y4 65 3: R5 R8 Y7 Y8 1: R1 R4 Y3 Y6 G8 B7 2: R3 R6 Y4 3: R8 Y7 Y8 1: R4 Y3 Y6 GO B7 2: R6 Y4 3: Yl Y7 Y8 1: R4 Y3 Y6 B7 2: *4 PROBLEM 4: The More the Merrier [10 points] This game is just TOO much fun to keep it to ourselves! Let's let a few other people play. Input . Integer N representing the number of players. Remaining lines are the same as in Problem 3 with the exception that you should expect N lines of player hands Processing Same as in Problem 3 with the exception that you must consider play of N (as read in from input) players. Output format Same as in Problem 3. HINT: Start from Problem 3 and modify... Sample input Sample output New hand after play -- R2 Y8 G6 G7 G8 R7 Y3 Y6 B2 B4 R6 R8 Y1 B1 B5 R1 R3 R5 Y7 B6 B7 0: B7 1: G7 2: R7 3: R8 LOCO R 4: R1 1: R2 2: B2 3: TAKE TWO 4: B6 G1 G3 Y2 G2 B8 Y4 ... R4 G8 B3 G5 Y5 1: G6 (Note that if ALL of the draw cards have been used. At some point, DRAW and a TAKE TWO act more like skipped turn. Output remains the same.) 1: R2 Y8 G4 G6 67 2: R7 Y3 Y6 B2 B4 3: R6 R8 Y1 B1 B5 4: R1 R3 R5 Y7 B6 1: R2 Y8 G6 G8 2: Y3 Y6 B2 B4 3: R6 Y1 G1 G3 B1 B5 4: R3 R5 Y7 B6 1: Y8 64 66 2: Y3 16 B4 3: R6 #1 G1 G3 B1 B5 4: R3 R5 17 1: 48 G4 2: Y2 Y3 B4 3: R6 61 G3 B1 B5 4: R3 R5 G2 1: 64 2: Y6 3: Y1 4: 77 1: Y8 LOCO G 2: DRAW 3: G1 4: DRAW 1: G4 (WINNER) 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). Sample output New hand after play Sample input Y3 Y7 Y8 B1 B7 R8 Y1 G4 G8 B8 R3 R4 R7 Y6 B5 B3 R2 G5 B6 Y5 G3 G2 ... Y4 R1 G1 Y2 G6 ... B4 R5 G7 R6 B2 B3 1: B1 2: BS 3: B5 1: B7 2: DRAW 3: R7 1: 77 2: 3: Y6 1: Y3 2: DRAW 3: R3 1: DRAW 2: R2 3: R4 (WINNER) 0: B6 1: Y3 Y7 Y8 B B7 2: R8 Y1 G4 G8 Be 3: R3 R4 R7 Y6 B5 1: Y3 Y7 Y8 B7 2: R2 R8 Y1 G4 G8 3: R3 R4 R7 Y6 1: Y3 I YS 2: R2 R8 41 G4 G8 3: R3 R4 16 1: 13 Y8 2: R2 R8 G4 G5 G8 3: R3 R4 2: R2 R8 G4 G5 G8 3: R+ R1 R4 G2 G8 B2 R2 R8 Y7 Y8 B3 R3 R6 Y3 G4 G5 B6 Y2 B7 Y1 G6 Y5 G7 ... R5 R7 G1 Y4 B5 G3 ... B1 B8 B4 Y6 1: R4 2: R8 3: DRAW 1: 68 2: Y8 3: Y2 1: G2 (WINNER) 1: R1 R4 G2 G8 B2 2: R2 R8 Y7 Y8 B3 3: A3 R6 Y3 G4 G5 1: R R4 G2 G8 2: R2 R8 Y7 78 3: R6 Y3 G4 G5 1: R+ G2 G8 2: RE 77 78 3: Y2 Y3 G4 G5 1: G2 68 2: Y7 Y8 3: *2 Y3 G4 G5 1: 62 PROBLEM 2: Take Two [20 points] Now that you've become proficient at playing the game, we will start adding in extra rules. For this one, if a player plays any "two" card (R2, Y2, G2 or B2), the next player's turn is skipped and they must take two cards. You will apply the Rule of Two below: Rule of Two If the card last laid in the discard pile was numbered 2, the next player must choose between the following options: If they have another "two" card (R2, Y2, G2 or B2) in their hand, they will choose to play the one. o If they have more than one colour, they will pick in rainbow order: red- yellow-green-blue. If they do not have a "two" card, on their turn they are skipped and must draw two cards from the top of the draw pile. Input Same as in Problem 1. Processing Same as in Problem 1 with the following exception: If a player lay's down a card numbered 2, the next player must apply the Rule of Two as described above. Output format Same as in Problem 1 with the following exception: If a player lay's down a card numbered 2 and the following player is unable to play another "two" card, output: {N}: TAKE TWO Where N = 1,2, or 3, the skipped player that had to draw two cards. HINT: Start from Problem 1 and modify... Sample input Sample output New hand after play R1 R4 Y6 G8 B2 R2 R8 Y7 Y8 B3 R3 R6 Y3 G4 G5 B6 0: B6 1: B2 2: R2 3: TAKE TWO 1: R1 2: R8 Y2 B7 Y1 G6 Y5 G7 R5 R7 G1 Y4 B5 ... G3 B1 B8 B4 G2 1: R1 R4 Y6 G8 B2 2: R2 R8 Y7 Y8 B3 3: R3 R6 Y2 Y3 G4 G5 B7 1: R3 R4 Y6 G8 2: RO Y7 Y8 B3 3: R R6 Y2 Y3 G4 G5 B7 1: R4 Y6 G8 2: Y1 Y7 Y8 B3 3: R6 Y2 Y3 G4 G5 B7 1: 16 GB 3: R3 1: R4 2: DRAW 3: R6 1: Y6 PROBLEM 3: Going Wild! [10 points] Now that we have that sorted, we will really go "wild" and add in the crazy eights rule. If the last player plays any Loco Card, an "eight card (R8, Y8, G8 or B8), they can choose the colour to be played next. The player that follows must then either play another Loco Card (R8, Y8, G8 or B8) of any colour, or a card of the new colour chosen. The Loco Rule If a player is allowed to play one of their Loco Cards (R8, Y8, G8 or B8), they will. If they have more than one Loco Card, they will choose to play the eight card that comes earlier in rainbow order (red-yellow-green- blue). When a Loco Card is played, they get to choose a colour to follow (i.e. it behaves as if they 8 was painted in the colour chosen). The chosen colour will always be the first colour in rainbow order that will remain in their hand (if any) on their next turn (if no cards remain, they win). Input Same as in Problem 2. Input Same as in Problem 2. Processing Same as in Problem 2 with the addition of Loco Rule: If a player has an "eight" card (R8, Y8, G8 or B8) in their hand, the Loco Rule (above) is applied. Output format Same as in Problem 2 with the following exception: If a player lay's down a card numbered 8, output the chosen colour as follows: {N}: {colour of Loco Card}8 {Colour chosen: R,Y,G, or B} HINT: Start from Problem 2 and modify... Sample input Sample output New hand after play R1 R4 Y6 G8 B2 R2 R3 R6 Y4 G5 R5 R8 Y7 Y8 G2 B6 Y3 B7 Y1 G6 Y5 G7 B3 R7 G1 G4 B5 G3 B1 B8 B4 Y2 0: B6 1: B2 2: R2 3: G2 1: TAKE TWO 2: 65 3: R5 1: R1 2: R3 3: R8 LOCO Y 1: G8 LOCO R. 2: R6 3: DRAW 1: R4 2: Y4 (WINNER) 1: R1 R4 Y6 G8 B2 2: R2 R3 R6 Y4 G5 3: R5 R8 Y7 Y8 62 1: R1 R4 Y3 Y6 G8 B7 2: R3 R6 Y4 65 3: R5 R8 Y7 Y8 1: R1 R4 Y3 Y6 G8 B7 2: R3 R6 Y4 3: R8 Y7 Y8 1: R4 Y3 Y6 GO B7 2: R6 Y4 3: Yl Y7 Y8 1: R4 Y3 Y6 B7 2: *4 PROBLEM 4: The More the Merrier [10 points] This game is just TOO much fun to keep it to ourselves! Let's let a few other people play. Input . Integer N representing the number of players. Remaining lines are the same as in Problem 3 with the exception that you should expect N lines of player hands Processing Same as in Problem 3 with the exception that you must consider play of N (as read in from input) players. Output format Same as in Problem 3. HINT: Start from Problem 3 and modify... Sample input Sample output New hand after play -- R2 Y8 G6 G7 G8 R7 Y3 Y6 B2 B4 R6 R8 Y1 B1 B5 R1 R3 R5 Y7 B6 B7 0: B7 1: G7 2: R7 3: R8 LOCO R 4: R1 1: R2 2: B2 3: TAKE TWO 4: B6 G1 G3 Y2 G2 B8 Y4 ... R4 G8 B3 G5 Y5 1: G6 (Note that if ALL of the draw cards have been used. At some point, DRAW and a TAKE TWO act more like skipped turn. Output remains the same.) 1: R2 Y8 G4 G6 67 2: R7 Y3 Y6 B2 B4 3: R6 R8 Y1 B1 B5 4: R1 R3 R5 Y7 B6 1: R2 Y8 G6 G8 2: Y3 Y6 B2 B4 3: R6 Y1 G1 G3 B1 B5 4: R3 R5 Y7 B6 1: Y8 64 66 2: Y3 16 B4 3: R6 #1 G1 G3 B1 B5 4: R3 R5 17 1: 48 G4 2: Y2 Y3 B4 3: R6 61 G3 B1 B5 4: R3 R5 G2 1: 64 2: Y6 3: Y1 4: 77 1: Y8 LOCO G 2: DRAW 3: G1 4: DRAW 1: G4 (WINNER)

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

Step: 3

blur-text-image

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

What is the role of the Joint Commission in health care?

Answered: 1 week ago