Question: Card Game - Match exactly 1 5 Problem: Card game - Match exactly 1 5 This is a 4 - player card game where each
Card Game Match exactly
Problem: Card game Match exactly
This is a player card game where each player will have cards in the form of cards in a stack and the next cards in a queue from a deck of cards There will also be cards on the table face up
In each players turn, the player will try to make a total point of exactly by adding the number of the top card in the players stack and the number of one of four cards on the table. If none of the cards on the table adds up to exactly then the player can dequeue players choice, if wants to swapone card from the players queue and swap it with the top card of the players stack the top card from the stack must be enqueued to the players queueAfter swapping if performed by the playerif the top card still does not make a total point of exactly then the players card from the top of the stack will be popped and discarded, and enqueued back to the deck. Otherwise, for the match of point the player will get points and both the cards that add up to will be discarded from the stack and the table and enqueued back to the deck. The table will be refilled from the deck.
After five rounds of play the stacks of each player will be empty and the game ends. At this point, the playerswith the highest points will be the winners
Initial Setup:
The game consists of a deck of cards with sets Each set contains cards numbered to with a specific color. Our deck has REDRGREENGORANGEOand PURPLEPcolors Example cards: RGOPetc
An initial queue called deck of size The cards will be stored in this queue.
Each player Players to has a dedicated stack and queue with a size of each For player iwe called them stacki and queueiThese stacks and queues function like personal zones where players accumulate cards and play during the game.
Create classes for a bounded stack and a bounded queue called Stack and Queue, respectively. Then, create each instance of these classes as required.
A table with a list of cards face up on the table.
Implement your solution with modularization using functions.
Gameplay:
AIn the first round, starting with the playeri
Pop the top card from the stacki
The sum of the player's popped card and one of the table cards must equal to
If this condition is met, points will be added to the playeris score. Then both the popped and the chosen cards on the table will be enqueued in any orderback to the deck. If multiple cards on the table match the condition, take the first card from the list.
iThe table will be refilled with a card from the deck.
If the condition is not met, ask the user if playeri wants to discard Ddthe popped card or swap Ssit with the card in the queuei
iIf the player wants to discard the popped card, then enqueue the card back to the deck.
iiIf the player wants to swap, then dequeue a card from queuei and enqueue the popped card into queueiThen perform step again with the dequeued card.
iiiIf the condition is not met, the dequeued card will be enqueued back to the deck.
BThe same actions should be performed by the other players as well and their score will be updated accordingly for each round.
CAccording to the playersstack size, there are five rounds in total, and the game will continue until all cards are popped from the players' stacks.
DFor each round and each player, the output format will be as follows:
Round: Player is playing.
Player gets points by matching R from hand and G from the table.if there is a matchor
No Matches for Player would you like to DiscardDdthe card or swap Ss
Player discarded the card on hand! if Dd is entered as inputor
Player swaps the card Rfrom the queue. if Ss is entered as input
Player gets points by matching R from hand and P from the table. or
No Matches for Player discarded the card on hand!
EAfter each players turn, the updated table will be displayed.
Display the color of the cards in the player Fstack and queue with the ANSI escape command. For this, you can think of lab to apply the colors. Use the following color codes:
colorcodedict R: mG: mO: mP: m
resetcode m
GHere you can see sampleoutput. Please stick to the required output format. Run your code in the terminalcommand prompt to see the expected output.
Ex: path to your filepython filename.py
HThe final scores of the players will also be stored in a "gamescore.txtfile with below format:
Scores:
Player;
Player;
Player;
Player;
Player wins
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
