Here are some steps to get you started in the Rock Paper Scissors project! As you work through the project, make sure to test your program by running it. 1. Download the starter code Clickhereto...


Here are some steps to get you started in the Rock Paper Scissors project! As you work through the project, make sure to test your program by running it.


1. Download the starter code


Clickhereto download the starter code.


The starter code gives you a place to begin, withPlayerandGameclasses that are mostly empty. Over the course of the project, you will be greatly expanding the classes and methods in this program.



Readthe starter code, andrunit on your computer to see what it does.


Try importing it into the Python interpreter and experimenting with thePlayerandGameobjects.


2. Create a player subclass that plays randomly


The starterPlayerclass always plays'rock'. That's not a very good strategy! Create a subclass calledRandomPlayerthat chooses its move at random. When you call themovemethod on aRandomPlayerobject, it should return one of'rock','paper', or'scissors'at random.


Change the code so it plays a game between twoRandomPlayerobjects.


3. Keep score


The starterGameclass does not keep score. It doesn't even notice which player won each round. Update theGameclass so that it displays the outcome of each round, and keeps score for both players. You can use the providedbeatsfunction, which tells whether one move beats another one.


Make sure to handle ties — when both players make the same move!


4. Create a subclass for a human player.


The game is a lot more interesting if you can actually play it, instead of just watching the computer play against itself. Create aHumanPlayersubclass, whosemovemethod asks the human user what move to make. (Take another look back at the project demo to see what this can look like!)


Set the program to play a game betweenHumanPlayerandRandomPlayer.


5. Create player classes that remember


At the end of each game round, theGameclass calls thelearnmethod on each player object, to tell that player what the other player's move was. This means you can have computer players that change their moves depending on what has happened earlier in the game. To do this, you will need to implementlearnmethods that save information into instance variables.


Create aReflectPlayerclass that remembers what move theopponentplayed last round, and plays that movethisround. (In other words, if you play'paper'on the first round, aReflectPlayerwill play'paper'on the second round.)


Create aCyclePlayerclass that remembers what moveitplayed last round, and cycles through the different moves. (If it played'rock'this round, it should play'paper'in the next round.)



(Something to think about: What should these classes do on the first move?)


Test each of these player classes versusHumanPlayer.


6. Validate user input


The human player might sometimes make typos. If they enterroxkinstead ofrock, theHumanPlayercode should let them try again. (See how this works in the demo if you type something in that isn't a valid move.)


7. Announce the winner


It's up to you how long the game should run. The starter code always plays three rounds, but that's not the only way it could work. You could choose to continue until the player typesquit, or you could have the game run until one player is ahead by three points, or any other rule that makes sense to you.


At the end of the game, have it print out which player won, and what the final scores are.


8. Check your code formatting


Use thepycodestyletool to check the formatting of your code. Make the edits that it recommends, then re-run it to see fewer and fewer warnings. By the time you're done, it should displayno warnings or errorsat all.

Sep 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here