Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Loops COMP 1 6 3 Write a program to play Ro - Sham - Bo . Two players make one of three hand signals at

Loops
COMP163
Write a program to play Ro-Sham-Bo. Two players make one of three hand signals at the same time. Hand signals represent a rock, a piece of paper, or a pair of scissors. Each combination results in a win for one of the players. Rock crushes scissors, paper covers rock, and scissors cut paper. A tie occurs if both players make the same signal. Use a random number generator of 0,1, or 2 to represent the three signals.
1 The Challenge
A seed is read from input to initialize the random number generator. This supports automated testing and creates predictable results that would otherwise be random.
Variables are defined for ROCK, PAPER, and SCISSORS
Read two player names
Read number of rounds
Continue reading number of rounds if value is below one and provide an error message
generate random values (0-2) for player 1 followed by player 2.
Continue to generate random values for both players until both values do not match.
Output "Tie" when the values match
2 Input
Seed
Player 1
Player 2
Number of rounds
3 Output
Player 1 vs Player 2 for # rounds
result of round
player 1 wins, player 2 wins
4 Example
Seed : 12
Player 1 Name : Bob
Player 2 Name : Sally
Rounds Played : 3
Bob vs Sally for 3 rounds Tie
Tie
Bob wins with scissors
sally wins with paper
Sally wins with paper
Bob wins 1 and Sally wins 2
Seed : 12
Player 1 Name : Bob
Player 2 Name : Salzy
Rounds Played : 0
Rounds must be >0
5 Hint
Use random.randint (0,2) to generate random values (0-2)
6 What to turn in
1
Loops.py
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions