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 15
Problem: Card game -Match exactly 15
This is a 4-player card game where each player will have 10cards in the form of 5cards in a stack and the next 5cards in a queue from a deck of 52cards. There will also be 4cards on the table face up.
In each players turn, the player will try to make a total point of exactly 15by 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 15,then the player can dequeue (players choice, if wants to swap)one 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 queue).After swapping (if performed by the player),if the top card still does not make a total point of exactly 15,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 15,the player will get 15points, and both the cards that add up to 15will 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 player(s)with the highest points will be the winner(s).
Initial Setup:
1)The game consists of a deck of 52cards with 4sets. Each set contains cards numbered 1to 13with a specific color. Our deck has RED(R),GREEN(G),ORANGE(O),and PURPLE(P)colors. Example cards: 1R,10G,3O,13P,etc.
2)An initial queue called deck of size 52.The cards will be stored in this queue.
3)Each player (Players 1to 4)has a dedicated stack and queue with a size of 5each. For player i,we called them stack_i and queue_i.These stacks and queues function like personal zones where players accumulate cards and play during the game.
4)Create classes for a bounded stack and a bounded queue called Stack and Queue, respectively. Then, create each instance of these classes as required.
5)A table with a list of 4cards face up on the table.
6)Implement your solution with modularization using functions.
Gameplay:
(A)In the first round, starting with the player_i,
1)Pop the top card from the stack_i.
2)The sum of the player's popped card and one of the table cards must equal to 15.
3)If this condition is met, 15points will be added to the player_is score. Then both the popped and the chosen cards on the table will be enqueued (in any order)back to the deck. (If multiple cards on the table match the condition, take the first card from the list.)
(i)The table will be refilled with a card from the deck.
4)If the condition is not met, ask the user if player_i wants to discard (D/d)the popped card or swap (S/s)it with the card in the queue_i.
(i)If the player wants to discard the popped card, then enqueue the card back to the deck.
(ii)If the player wants to swap, then dequeue a card from queue_i and enqueue the popped card into queue_i.Then perform step 3again with the dequeued card.
(iii)If the condition is not met, the dequeued card will be enqueued back to the deck.
(B)The same actions should be performed by the other players as well and their score will be updated accordingly for each round.
(C)According to the playersstack size, there are five rounds in total, and the game will continue until all cards are popped from the players' stacks.
(D)For each round and each player, the output format will be as follows:
Round: 1,Player 1is playing.
Player 1gets 15points by matching 2R from hand and 11G from the table.[if there is a match],or
No Matches for Player 1,would you like to Discard(D/d)the card or swap (S/s)?
Player 1discarded the card on hand! [if D/d is entered as input],or
Player 1swaps the card [3R]from the queue. [if S/s is entered as input]
Player 1gets 15points by matching 3R from hand and 12P from the table. or
No Matches for Player 1,discarded the card on hand!
(E)After each players turn, the updated table will be displayed.
Display the color of the cards in the player (F)stack and queue with the ANSI escape command. For this, you can think of lab 6to apply the colors. Use the following color codes:
color_code_dict ={'R': '\033[41m','G': '\033[42m','O': '\033[43m','P': '\033[105m'}
reset_code ='\033[0m'
(G)Here you can see sample_output. Please stick to the required output format. (Run your code in the terminal/command prompt to see the expected output.
Ex: [path to your file]python filename.py).
(H)The final scores of the players will also be stored in a "game_score.txt"file with below format:
Scores:
Player_1=0.0;
Player_2=30.0;
Player_3=0.0;
Player_4=15.0;
Player 2wins!
Card Game - Match exactly 1 5 Problem: Card game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!