Scissors Paper Rock
A simple game, that involves two players who individually pick between 3 options, Scissors, Paper and Rock. If both players pick the same item, it's a tie, and every other combination follows three rules:
1. Scissors beats paper
2. Paper beats rock
3. Rock beats scissors.
All that needs to happen is to let the player choose between the three choices, let the computer pick between the three choices, and compare to get the outcome. There is one complication, which is that the computer doesn't know how to pick between three things. However, we can make the computer pick between 3 numbers, with a random number generator, which effectively makes the computer pick between three different choices.
player = 2
while player != "S" and player != "s" and player != "P" and player != "p" and player != "R" and player != "r":
player = input("[S]cissors, [P]aper, [R]ock: ")
player.lower()
computer = random.randint(1, 3)
if computer == 1:
print("Computer picked Scissors")
if player == "s":
print("Tie")
elif player == "p":
print("Computer wins")
else:
print("Player wins")
elif computer == 2:
print("Computer picked Paper")
if player == "s":
print("Player wins")
elif player == "p":
print("Tie")
else:
print("Computer wins")
else:
print("Computer picked Rock")
if player == "s":
print("Compter wins")
elif player == "p":
print("Player wins")
else:
print("Tie")
Comments
Post a Comment