Question: 1 0 . 1 1 PROJ - 3 : Racko ( Checkpoint A ) In this project, you will implement the game of 'Rack -
PROJ: Racko Checkpoint A
In this project, you will implement the game of 'RackO a game that involves rearranging your hand of cards in order to have an increasing sequence. Each card just has a number. While Racko is typically played with to players, we will keep this simple and just use two players. One player's moves will be decided by the user via input. We will also build a computer player whose moves are decided by you, the programmer. This game will be built in stages: Checkpoint A and Checkpoint B and an extra credit Checkpoint C to participate in a Racko class competition!
This Ideaconcept application of this project was obtained from Dr Bhusnurmath at the University of Pennsylvania.
Overview
A Racko deck is composed of cards, numbered to A hand is kept in a special place, called a rack. The objective is to be the first player to arrange all of the cards in your rack from lowest to highest.
To setup the game, we shuffle the deck and each player gets dealt cards one at a time. As a player receives a card, it is placed in their rack ie without rearranging any of them, in the order they were dealt The goal of each player is to create a rack where the sequence of card numbers is in ascending order, starting at slot Players will try to accomplish this by selectively discarding from their hand and replacing with new cards.
To start the game, the top card of the deck is turned over to create a discard pile.
Each player then takes turns by:
Taking the top card from either the discard pile or the deck
Optionally discarding one card from their rack, and inserting the new card into the vacant slot
If a player draws a card from the deck, they may immediately discard it rather than discard one from their rack
If a player draws the top card from the discard, they must keep it and discard one from their rack
The first player to get cards in ascending order calls RackO and wins the game.
The following video explains the rules and gameplay of Racko:
Implementation Notes
You will notice that, in a sense, the objective of RackO is to get a sorted rack, but it is not how we would traditionally consider "sorting" none of our other sorting algorithms let us discard and select new elements!
Our project will make heavy use of lists. We will represent a player's rack, the deck and the discard pile as lists. Note that in both the deck and the discard pile, you only ever will access to the top card.
To add a card to a pile of cards, you just call the append method.
To take a card from the top of a pile of cards, you just call the pop method.
A player's rack can also be represented by a list. If their rack was:
rack
This rack is not yet "RackO since it is not in ascending order.
Checkpoint A
In Checkpoint A the game will not yet be playable as a twoplayer game. It will be playable by you in a type of "solitaire mode."
Implement these functions from the template following the description specification in their docstring:
showtopcard
gettopcard
addcardtodiscard
checkracko
findandreplace
playhand
The main function to drive the game has been provided.
Missing inputoutput statements are part of playhand and left for you to implement, guided by the sample inputoutput
None of the other functions left to implement use input or print.
The case capitalization of user input should be ignored.
On any invalid user input, the program should exit with a nonzero exit code.
Hint: Use Python Tutor. as much as possible when testing gameplay. Zybooks requires you specify all your inputs in advance and it is less enjoyable to play that way.
Sample inputoutput
When the inputs are:
no
yes
yes
yes
The expected behavior is inputs are shown inline
Deck:
Discard pile:
Your current rack is:
The top discard card is
Do you want ityes or no: no
The card from the deck is
Do you want ityes or no: yes
Enter the number of the card you want to kick out:
Your new rack is:
Deck:
Discard pile:
Your current rack is:
The top discard card is
Do you want ityes or no: yes
Enter the number of the card you want to kick out:
Your new rack is:
Deck:
Discard pile:
Your current rack is:
The top discard card is
Do you want ityes or no: yes
Enter the number of the card you want to discard:
Your new rack is:
Computer rack is:
Deck:
Discard pile:
Your current rack is:
Computer rack is:
The top discard card is
Do you want ityes or no: no
The card from the deck is
Do you want ityes or no: yes
Enter the number of the
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
