Find Jobs
Hire Freelancers

Rock Paper Scissors Python Code

$10-30 USD

Completed
Posted over 5 years ago

$10-30 USD

Paid on delivery
1. Download the starter code The starter code gives you a place to begin, with Player and Game classes that are mostly empty. Over the course of the project, you will be greatly expanding the classes and methods in this program. Read the starter code, and run it on your computer to see what it does. Try importing it into the Python interpreter and experimenting with the Player and Game objects. 2. Create a player subclass that plays randomly The starter Player class always plays 'rock'. That's not a very good strategy! Create a subclass called RandomPlayer that chooses its move at random. When you call the move method on a RandomPlayer object, it should return one of 'rock', 'paper', or 'scissors' at random. Change the code so it plays a game between two RandomPlayer objects. 3. Keep score The starter Game class does not keep score. It doesn't even notice which player won each round. Update the Game class so that it displays the outcome of each round, and keeps score for both players. You can use the provided beats function, 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 a HumanPlayer subclass, whose move method 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 between HumanPlayer and RandomPlayer. 5. Create player classes that remember At the end of each game round, the Game class calls the learn method 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 implement learn methods that save information into instance variables. Create a ReflectPlayer class that remembers what move the opponent played last round, and plays that move this round. (In other words, if you play 'paper' on the first round, a ReflectPlayer will play 'paper' on the second round.) Create a CyclePlayer class that remembers what move it played 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 versus HumanPlayer. 6. Validate user input The human player might sometimes make typos. If they enter roxk instead of rock, the HumanPlayer code 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 types quit, 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 the pycodestyle tool 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 display no warnings or errors at all.
Project ID: 18507067

About the project

3 proposals
Remote project
Active 5 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
I am a university student who has worked on similar projects before. This project appears to be quite easy to implement, and I should be able to complete it soon. I hope you can accept my bid.
$30 USD in 1 day
5.0 (1 review)
1.0
1.0
3 freelancers are bidding on average $30 USD for this job
User Avatar
I have 5+ years of experience with Python. I have also developed games on Python. I have rad the description. I can start immediately and complete this task quickly. Hope to work with you.
$30 USD in 1 day
5.0 (1 review)
1.2
1.2
User Avatar
Hey! I hope you are fine, I can do this work with great efficiency as I've a lot of experience in this field. I would like you to give this opportunity to me I assure you I'll not disappoint you. Thanks in advance dear customer. Yet, I'm a beginner at this freelancing site but not in this field chain :). Your support will matters a lot.
$30 USD in 1 day
5.0 (1 review)
1.1
1.1

About the client

Flag of SAUDI ARABIA
Riyadh, Saudi Arabia
0.0
0
Member since Jan 11, 2019

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.