Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program is written in python. Please include a screenshot of the code and the result as I cannot see indentation with plain text on

This program is written in python. Please include a screenshot of the code and the result as I cannot see indentation with plain text on Chegg. Thank you

image text in transcribed

here is the provided file:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

To clarify Part 2 specifications, I have provided sample tests for each required function inside of its docstrings in a3_game_xxxxxx.py. Furthermore, you can find example run of the whole game below and its associated video at the link below. The behaviour implied by the sample tests/runs and the video should be considered as required spec- ifications in addition to what is explained in this document. Finally, you can also find one extra example run of the beginninng of the game that the end of the assgnment Here is the link to the video https:/lyoutu.be/Zw12qTyPnHo Description: A card in a standard deck has a suit (in particular, one of four suits:4) and a rank (one of 1 3 ranks: A, 2.3. , 10, J, Q, K). Taking every pair of a suit and a rank gives rise to a standard deck of (413c) 52 cards. Imagine you have access to only an old fashion terminal that cannot display fancy characters like: * but yet you would like to make a card game. You would first need to decide how to represent a card. One way to do that would be to represent a card by a 3 digit integer where the first digit (1 to 4) represents a suit and the two last digits (1 to 13) represent ranks. Let's call such a deck, a strange deck. For part 2 of the assignment, you will need to make a (heavily) modified version of Rummy card game with this strange deck. More specifically the deck will have 4 suits (indicated with first digit 1, 2, 3 or 4) and num ranks where nunm is given by the user and can be between 3 and 99, inclusively. In Rummy, the main goal is to build melds which consists of sets, two, three or four of a kind of the same rank; or progression, three or more cards in a sequence of consecutive ranks, of the same suit. So the set 0.10.* 10 forms three of a kind. And the set/sequence 7+. 8+. 9., 10+. 1 1 forms a progression. In our strange deck, 210, 110, 310 would form three of a kind (since the first digit is a suit, so the ranks are 10, 10, 10) and the set 309, 307, 311, 308, 310 is a progression (since they all have a suit 3 and 07, 08, 09, 10,11 is sequence of consecutive integers). Note that 201, 302, 303 is not a progression. Although 01, 02, 03 is a sequence of consecutive integers, the three cards do not have the same suit (some have suit 2 and some 3) so this is not a progression. So the game that you will develop needs to go as follows: (The goal of the player is to get rid of all of her cards in as few rounds of the game as possible) Step 0: The strange deck is created and shuffled. (In order to test your game more quickly you can reduce the numer of ranks to less than 13 and more than 3). In your implementation the created deck needs to be a list of integers representing a strange deck. Top of the deck is considered the last card in te ist Step : The player is dealt 7 cards rom the top of the strange deck Step 2: The ollowing steps are repeated until the player runs out of the cardse. until player's hand is empty: Step 3: The player rolls a dice I the player gets a 1 The player can discard any one card she ikes. After that, the current round is over and the game goes back to Step 2 If instead the player gets num-2,3,4,5 or 6: The player if first delt, Erom the top of the deck num or len(deck) cards, whichever is smaller The player then keeps on discarding melds from her hand until she has no more melds. You program has to check that the set of cards that the player chooses indeed forms a valid meld before discarding them from the player's hand Once she decides she is out of melds, the round is over and the game goes back to Step 2 (Note that if the deck is empty and the player has no more melds, no melds can ever be created again. Thus the player has to wait for 1 on the dice. In order to avoid that unpleasantry your game should roll 1 i.e. set num to 1, in each round that starts with empty deck.) Finally, once the player is out of cards (i.e. once the player's hand is empty),the total number of rounds is reported and the game is over As usual, whenever you ask the player for some input you should make sure they give you the required kind of input. You may assume that the player will follow instructions and give you a correct type of date but not the correct values. For example, if you are asking for an integer between 3 and 99, you may assume that the player will give you an integer but not that she will give you an integer in the correct range. Thus you should keep on repeating the question until you get a valid answer. Similarly if you ask the player for a meld, you may assume that the player will give you a set of 3 digit integers, but you will need to test if these cards are indeed in the players hand and that they form a meld. As in the previous assignment, I provided you with the starter code in the file called, a3_game xxxxxx.py. Start by replacing xxxxxx in the file name with your student number. Then open the file. Your solution (code) for this part must go into that file in the clearly indicated spaces only. You are not allowed to delete or comment-out or change any parts of the provided code except for the keywords pass. In a3_game xxxxxx.py, there are many functions with code missing. You must complete and use all of those func tions. Your function should behave as explained in the function description and the example runs. All rea given in the docstrings. You also need to complete the main. To clarify Part 2 specifications, I have provided sample tests for each required function inside of its docstrings in a3_game_xxxxxx.py. Furthermore, you can find example run of the whole game below and its associated video at the link below. The behaviour implied by the sample tests/runs and the video should be considered as required spec- ifications in addition to what is explained in this document. Finally, you can also find one extra example run of the beginninng of the game that the end of the assgnment Here is the link to the video https:/lyoutu.be/Zw12qTyPnHo Description: A card in a standard deck has a suit (in particular, one of four suits:4) and a rank (one of 1 3 ranks: A, 2.3. , 10, J, Q, K). Taking every pair of a suit and a rank gives rise to a standard deck of (413c) 52 cards. Imagine you have access to only an old fashion terminal that cannot display fancy characters like: * but yet you would like to make a card game. You would first need to decide how to represent a card. One way to do that would be to represent a card by a 3 digit integer where the first digit (1 to 4) represents a suit and the two last digits (1 to 13) represent ranks. Let's call such a deck, a strange deck. For part 2 of the assignment, you will need to make a (heavily) modified version of Rummy card game with this strange deck. More specifically the deck will have 4 suits (indicated with first digit 1, 2, 3 or 4) and num ranks where nunm is given by the user and can be between 3 and 99, inclusively. In Rummy, the main goal is to build melds which consists of sets, two, three or four of a kind of the same rank; or progression, three or more cards in a sequence of consecutive ranks, of the same suit. So the set 0.10.* 10 forms three of a kind. And the set/sequence 7+. 8+. 9., 10+. 1 1 forms a progression. In our strange deck, 210, 110, 310 would form three of a kind (since the first digit is a suit, so the ranks are 10, 10, 10) and the set 309, 307, 311, 308, 310 is a progression (since they all have a suit 3 and 07, 08, 09, 10,11 is sequence of consecutive integers). Note that 201, 302, 303 is not a progression. Although 01, 02, 03 is a sequence of consecutive integers, the three cards do not have the same suit (some have suit 2 and some 3) so this is not a progression. So the game that you will develop needs to go as follows: (The goal of the player is to get rid of all of her cards in as few rounds of the game as possible) Step 0: The strange deck is created and shuffled. (In order to test your game more quickly you can reduce the numer of ranks to less than 13 and more than 3). In your implementation the created deck needs to be a list of integers representing a strange deck. Top of the deck is considered the last card in te ist Step : The player is dealt 7 cards rom the top of the strange deck Step 2: The ollowing steps are repeated until the player runs out of the cardse. until player's hand is empty: Step 3: The player rolls a dice I the player gets a 1 The player can discard any one card she ikes. After that, the current round is over and the game goes back to Step 2 If instead the player gets num-2,3,4,5 or 6: The player if first delt, Erom the top of the deck num or len(deck) cards, whichever is smaller The player then keeps on discarding melds from her hand until she has no more melds. You program has to check that the set of cards that the player chooses indeed forms a valid meld before discarding them from the player's hand Once she decides she is out of melds, the round is over and the game goes back to Step 2 (Note that if the deck is empty and the player has no more melds, no melds can ever be created again. Thus the player has to wait for 1 on the dice. In order to avoid that unpleasantry your game should roll 1 i.e. set num to 1, in each round that starts with empty deck.) Finally, once the player is out of cards (i.e. once the player's hand is empty),the total number of rounds is reported and the game is over As usual, whenever you ask the player for some input you should make sure they give you the required kind of input. You may assume that the player will follow instructions and give you a correct type of date but not the correct values. For example, if you are asking for an integer between 3 and 99, you may assume that the player will give you an integer but not that she will give you an integer in the correct range. Thus you should keep on repeating the question until you get a valid answer. Similarly if you ask the player for a meld, you may assume that the player will give you a set of 3 digit integers, but you will need to test if these cards are indeed in the players hand and that they form a meld. As in the previous assignment, I provided you with the starter code in the file called, a3_game xxxxxx.py. Start by replacing xxxxxx in the file name with your student number. Then open the file. Your solution (code) for this part must go into that file in the clearly indicated spaces only. You are not allowed to delete or comment-out or change any parts of the provided code except for the keywords pass. In a3_game xxxxxx.py, there are many functions with code missing. You must complete and use all of those func tions. Your function should behave as explained in the function description and the example runs. All rea given in the docstrings. You also need to complete the main

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

Students also viewed these Databases questions

Question

2. What efforts are countries making to reverse the brain drain?

Answered: 1 week ago