Uno Lab #
In this lab, you are going to go behind the scenes of the classic card game, Uno.
 
 
[0] Let’s Play Uno #
๐ Let’s start by playing the classic card game, Uno. As you’re playing, consider the different components and mechanics of the game.
[0] Setup #
๐ Github Repo: github.com/Making-with-Code/lab_uno
๐ป Enter the Poetry shell and install the requirements:poetry shell
poetry install
This is the largest software package you have encountered and includes the following files:
- card.py
- deck.py
- player.py
- uno.py
- game.py
- view.py
- uno_cards.csv
- test_lab.py
[2] Play Test #
๐ป Play through Uno in your Terminal.
python game.py
If you’re interested, you can find the full rules of Uno here. Our implementation varies slightly. Can you identify the differences?
๐ค Was the gameplay different than you expected?
โ CHECKPOINT:
๐ป
Open up the code:
code .โ๏ธ In your group, complete the worksheet.
[3] StrategicComputerPlayer #
As you’ve experienced, you are playing against a computer. The ComputerPlayer has 3 main methods.
- get_playable_cards()
- play_card()
- choose_color()
However, the current computer is not very intelligent.
Let’s make a slightly more competitive computer by considering the best strategy for uno.
It’s up to you to extend the ComputerPlayer class and complete the StrategicComputerPlayer class:
You will NEED to override the following methods of StrategicComputerPlayer to successfully write a better computer strategy:
- get_playable_cards()
- choose_color()
a more advanced strategy will also override
play_card()
๐ค Your goal: write a strategic computer that consistently wins more than 35-40% of games against 2 other computer players who are using the basic strategy. Consider the rules and mechanics of Uno. Given a hand of cards, what would make playing one card better than playing another card?
๐ป 
 Finish StrategicComputerPlayer to implement a strategic strategy.
You may want to read more about inheritance.
๐ป Test your strategy by running:
python test_lab.py -k strategy
if you receive a
raise NotImplementedError, it is because you have not overriddenget_playable_cards()ANDchoose_color()
[5] Deliverables #
โกโจ
Once you’ve successfully completed the game be sure to fill out this Google form.
๐ป Push your work to Github:
- git status
- git add -A
- git status
- git commit -m “describe your drawing and your process here”
be sure to customize this message, do not copy and paste this line
- git push
[6] Extension: #
Now that you’ve got a fully functional Uno game, let’s expand its functionality.
It’s up to you which extension to work on. If you have your own idea for extending Uno, feel free to work on that!
[More Advanced Strategy] #
Can you make your StrategicComputerPlayer even more advanced?  You’ll need to override the play_card() method.
๐ป Make an even more strategic player! How high can you make the win percentage? It may be helpful to think through hou make the decision of which card to play at which time in the game.
๐ป Test your strategy by running:
python test_lab.py -k strategy
[Saying Uno] #
Currently, there is no way to system in place for saying ‘Uno’. It’s up to you to add in that feature!
๐ป Add a ‘saying Uno’ feature into the game. Be sure to consider:
- how will you allow the player to say ‘Uno’?
- how will you keep track if the player said ‘Uno’ at the correct time?
- how will you allow the player to say ‘Uno’ and play a card?
- how will you penalize the player if they forget to say ‘Uno?
๐พ Play test your feature to ensure it works as intended!
๐ค How would you add in this feature to the
ComputerPlayer?
[Advanced Deck Building] #
Cards are read into the deck as entries in a csv file. Look at the deck.py module and you’ll note that we’re using pandas to read the cards, looks like those data science skills will come in handy after all!
๐
 Take a look at the current cards in uno_cards.csv. As you can see, each card is on a new line and commas separate their properties.
๐ป Create your own deck and add a new special card by writing new a csv file. Just create a new csv file with the name of your special card in the special column.
๐ป 
 Implement your special card in the UnoGame class.
๐พ Play test your new deck to ensure it works as intended!
