Last active
August 12, 2022 10:33
-
-
Save InquisitiveDev2016/037cc2c0651efefef3ba81996ac40af1 to your computer and use it in GitHub Desktop.
Make a two-player Rock-Paper-Scissors game.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 1.) Understand the problem | |
Make a two-player Rock-Paper-Scissors game. | |
2.) Plan a solution | |
Algorithm: | |
- Ask player 1 for input either rock paper or scissors | |
- tell the player what he chose | |
- Ask player 2 the same thing and tell them what they chose | |
- while True: | |
- variable users input = user input | |
- if varaible users == quit then break | |
- if player 1 is rock and player 2 is scissors | |
- print player 1 wins | |
- else if player 1 is scissors and player is paper 2 | |
- print player wins | |
- else if player 1 is paper and player 2 is rock | |
- print p1 wins | |
- if player 2 is rock and player 1 is scissors | |
- player 2 wins | |
- if player 2 is scissors and player 1 is paper | |
- player 2 wins | |
- if player 2 is paper and player 1 is rock | |
- palyer 2 wins | |
while True: | |
if player 1 choses rock and player 2 = rock | |
- print play again | |
if palyer 1 choses scissors and player 2 = scissors | |
- play again | |
if player 1 choses paper and palyer 2 = paper | |
- play again | |
else: | |
break | |
3.) Carry out the plan: | |
""" | |
while True: | |
player1 = input(" Player 1, please pick Rock, Paper, or Scissors. ") | |
if player1 == "Rock" or player1 == "Scissors": | |
print("You chose ", player1) | |
elif player1 == "Paper": | |
print("You chose ", player1) | |
else: | |
print("That is not a valid input! Or if you did chose an appropraite item please put it in lower case letters!") | |
player2 = input("Player 2, please pick Rock, Paper, or Scissors. ") | |
if player2 == "Rock" or player2 == "Scissors": | |
print("You chose ", player2) | |
elif player2 == "Paper": | |
print("You chose ", player2) | |
else: | |
print("That is not a valid input! Or if you did chose an appropraite item please put it in lower case letters!") | |
break | |
while True: | |
if player1 == "Rock" and player2 == "Scissors": | |
print("Player 1 wins!") | |
break | |
elif player1 == "Scissors" and player2 == "Paper": | |
print("Player 1 wins!") | |
break | |
elif player1 == "Paper" and player2 == "Rock": | |
print("Player 1 wins!") | |
break | |
if player2 == "Rock" and player1 == "Scissors": | |
print("Player 2 wins!") | |
break | |
elif player2 == "Scissors" and player1 == "Paper": | |
print("Player 2 wins!") | |
break | |
elif player2 == "Paper" and player1 == "Rock": | |
print("Player 2 wins!") | |
break | |
else: | |
print("It's a Tie, or one of the players have not selected a proper item!") | |
break | |
# 4.) Examine your results for accuracy | |
""" Input: | |
player1 = "Rock" | |
player2 = "Scissors" | |
Output: | |
Player 1 wins! | |
Input: | |
player1 = "Scissors" | |
player2 = "Rock" | |
Output: | |
Player 2 wins! | |
Input: | |
player1 = "Rock" | |
player2 = "Rock" | |
Output: | |
It's a Tie, or one of the players have not selected a proper item! | |
Input: | |
player1 = "not valid input" | |
player2 = "Rock" | |
Output: | |
That is not a valid input! Or if you did chose an appropraite item please put it in lower case letters! | |
It's a Tie, or one of the players have not selected a proper item! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are using a lot of if else statements , and I see a lot of repetitive code. Remember the one golden rule of programming: "Be Lazy", if you are writing repetitive code, you are doing things the computer should be doing. Maybe try something with an array?