Answer:
In Python
print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")
p1 = int(input("Player 1: "))
p2 = int(input("Player 2: "))
if p1 == p2:
print("Tie")
else:
if p1 == 1: # Rock
if p2 == 2: #Paper
print("P2 wins! Paper covers Rock")
else: #Scissors
print("P1 wins! Rock smashes Scissors")
elif p1 == 2: #Paper
if p2 == 1: #Rock
print("P1 wins! Paper covers Rock")
else: #Scissors
print("P2 wins! Scissors cuts Paper")
elif p1 == 3: #Scissors
if p2 == 1: #Rock
print("P2 wins! Rock smashes Scissors")
else: #Paper
print("P1 wins! Scissors cuts Paper")
Explanation:
This prints the game instruction
print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")
The next two lines get input from the user
<em>p1 = int(input("Player 1: "))</em>
<em>p2 = int(input("Player 2: "))</em>
If both input are the same, then there is a tie
<em>if p1 == p2:</em>
<em> print("Tie")</em>
If otherwise
else:
The following is executed if P1 selects rock
if p1 == 1: # Rock
If P2 selects paper, then P2 wins
<em> if p2 == 2: #Paper</em>
<em> print("P2 wins! Paper covers Rock")</em>
If P2 selects scissors, then P1 wins
else: #Scissors
print("P1 wins! Rock smashes Scissors")
The following is executed if P1 selects paper
elif p1 == 2: #Paper
If P2 selects rock, then P1 wins
<em> if p2 == 1: #Rock</em>
<em> print("P1 wins! Paper covers Rock")</em>
If P2 selects scissors, then P2 wins
<em> else: #Scissors</em>
<em> print("P2 wins! Scissors cuts Paper")</em>
The following is executed if P1 selects scissors
elif p1 == 3: #Scissors
If P2 selects rock, then P2 wins
<em> if p2 == 1: #Rock</em>
<em> print("P2 wins! Rock smashes Scissors")</em>
If P2 selects paper, then P1 wins
<em> else: #Paper</em>
<em> print("P1 wins! Scissors cuts Paper")</em>