Question
2 Part 2: Single Player Rummy Game with Dice and strange deck (80 points) To clarify Part 2 specifications, I have provided sample tests for
2 Part 2: Single Player Rummy Game with Dice and strange deck (80 points) 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://youtu.be/Zwl2qTyPnHo Description: A card in a standard deck has a suit (in particular, one of four suits: , , , ) and a rank (one of 13 ranks: A, 2, 3, ..., 10, J, Q, K). Taking every pair of a suit and a rank gives rise to a standard deck of (4x13=) 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. Lets 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. 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 10, 10, 10 forms three of a kind. And the set/sequence 7, 8, 9, 10, 11 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. 3 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 the list. Step 1: The player is dealt 7 cards from the top of the strange deck. Step 2: The following steps are repeated until the player runs out of the cards: Step 3: The player rolls a dice If the player gets a 1: The player can discard any one card she likes. 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, from 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 once 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, the total number of rounds is reported. 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started