Skip to content

Instantly share code, notes, and snippets.

@ceffiong
Created March 27, 2020 17:29
Show Gist options
  • Save ceffiong/eed18b8b86bf1f85981585ee8f0feb71 to your computer and use it in GitHub Desktop.
Save ceffiong/eed18b8b86bf1f85981585ee8f0feb71 to your computer and use it in GitHub Desktop.
Rock-paper-scissors game logic source codes
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