Created
March 27, 2020 17:29
-
-
Save ceffiong/eed18b8b86bf1f85981585ee8f0feb71 to your computer and use it in GitHub Desktop.
Rock-paper-scissors game logic source codes
This file contains 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
def game_logic(you, opponent): | |
winner = "" | |
rock = "rock" | |
paper = "paper" | |
scissors = "scissors" | |
player0 = "you" | |
player1 = "opponent" | |
if you == opponent: | |
winner = "draw" | |
elif you == rock: | |
if opponent == paper: | |
winner = player1 | |
else: | |
winner = player0 | |
elif you == scissors: | |
if opponent == rock: | |
winner = player1 | |
else: | |
winner = player0 | |
elif you == paper: | |
if opponent == scissors: | |
winner = player1 | |
else: | |
winner = player0 | |
return winner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment