Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import random def main(): print(\'ROCK PAPER SCISSORS in Python\') print() print

ID: 3733623 • Letter: I

Question

import random

def main():

    print('ROCK PAPER SCISSORS in Python')

    print()

    print('Rules: 1) Rock wins over Scissors.')

    print(' 2) Scissors wins over Paper.')

    print(' 3) Paper wins over Rock.')

def rock_paper_scissors():

    guess = 'r','p','s'

    computer_score = 0

    person_score = 0

    rounds = 1

    total_rounds= int(input("How many points does it take to win? "))

    while(computer_score < total_rounds and person_score < total_rounds):

        while (computer_score < total_rounds and person_score < total_rounds):

            print("******************* ROUND #", rounds, "*******************")

            rock_paper_scissors = input("Pick your throw: [r]ock, [p]aper, or [s]cissors? ")

            computer = random.choice(guess)

            if rock_paper_scissors == computer:

                print('Tie!')  

                rounds +=1

            elif (rock_paper_scissors == 'p' and computer == 'r'):

                print('Computer threw rock, you win!')

                person_score=person_score+1

                rounds +=1

            elif (rock_paper_scissors == 'r' and computer == 's'):

                print('Computer threw scissors, you win!')

                person_score=person_score+1

                rounds +=1

            elif(rock_paper_scissors == 's' and computer == 'p'):

                print('Computer threw paper, you win!')

                person_score=person_score+1

                rounds +=1

            elif(rock_paper_scissors == 'r' and computer == 'p'):

                print('Computer threw paper, you lose!')

                computer_score=computer_score+1

                rounds +=1

            elif (rock_paper_scissors == 's' and computer == 'r'):

                print('Computer threw rock, you lose!')

               computer_score=computer_score+1

                rounds +=1

            else:

                (rock_paper_scissors == 'p' and computer == 's')

                print('Computer threw scissors, you lose!')

                computer_score=computer_score+1

                rounds +=1

                print ("Your score:" , person_score)

                print ("Computer's score:", computer_score)

    return

main()

rock_paper_scissors

The program above contains a python program for a rock paper scissor game where the user competes with the cpu. The program can calculate all the individual rounds and tally up a winner at the end based on how many points was initiated for the game to last thru. I would like to change and add these features to the program

1) Instead of asking the user to play an x amount of round change it that in every round it tallies up the amount of wins and losses and ask the user to either keep playing more rounds or quit

2) Also add a counting feature for the cpu where the it selects the weapon most likely to beat the user, based on the user’s previous choice of weapons. For instance, if the user has selected Paper 3 times but Rock and Scissors only 1 time each, the computer should choose Scissors as the weapon most likely to beat Paper, which is the user’s most frequent choice so far. To accomplish this, the program must keep track of how often the user chooses each weapon. The program should then use this playing history (to count of how often each weapon has been selected by the user) to determine if the user currently has a preferred weapon; if so, the computer should select the weapon most likely to beat the user’s preferred weapon. During rounds when the user does not have a single preferred weapon, the computer may select any weapon. For instance, if the user has selected Rock and Paper 3 times each and Scissors only 1 time, or if the user has selected each of the weapons an equal number of times, then there is no single weapon that has been used most frequently by the user; in this case the computer may select any of the weapons.

Explanation / Answer

import random

def main():

print('ROCK PAPER SCISSORS in Python')

print()

print('Rules: 1) Rock wins over Scissors.')

print(' 2) Scissors wins over Paper.')

print(' 3) Paper wins over Rock.')

def rock_paper_scissors():

guess = ['r','p','s']

computer_score = 0

person_score = 0

rounds = 1

total_rounds= 1

p=0

r=0

s=0

while(computer_score < total_rounds and person_score < total_rounds):

while (computer_score < total_rounds and person_score < total_rounds):

print("******************* ROUND #", rounds, "*******************")

rock_paper_scissors = input("Pick your throw: [r]ock, [p]aper, or [s]cissors? ")

if p==0 and r==0 and s==0 and p==s and r==s:

computer = random.choice(guess)

elif p>r and p>s:

computer = s

elif r>p and r>s:

computer = p

elif s>p and s>r:

computer = r

elif s==p and s>r:

computer=random.choice(s,p)

elif s==r and s>p:

computer=random.choice(s,r)

elif r==p and r>s:

computer=random.choice(r,p)

  

if rock_paper_scissors == computer:

print('Tie!')  

rounds +=1

if rock_paper_scissors==p:

p +=1

elif rock_paper_scissors==r:

r =r+1

elif rock_paper_scissors==s:

s +=1

elif (rock_paper_scissors == 'p' and computer == 'r'):

print('Computer threw rock, you win!')

person_score=person_score+1

p +=1

rounds +=1

elif (rock_paper_scissors == 'r' and computer == 's'):

print('Computer threw scissors, you win!')

person_score=person_score+1

r +=1

rounds +=1

elif(rock_paper_scissors == 's' and computer == 'p'):

print('Computer threw paper, you win!')

person_score=person_score+1

s +=1

rounds +=1

elif(rock_paper_scissors == 'r' and computer == 'p'):

print('Computer threw paper, you lose!')

computer_score=computer_score+1

r +=1

rounds +=1

elif (rock_paper_scissors == 's' and computer == 'r'):

print('Computer threw rock, you lose!')

computer_score=computer_score+1

s +=1

rounds +=1

elif(rock_paper_scissors == 'p' and computer == 's'):

print('Computer threw scissors, you lose!')

computer_score=computer_score+1

p +=1

rounds +=1

print ("Your score:", person_score)

print ("Computer's score:", computer_score)

print("keep playing more rounds Enter 1 or for quit Enter 0")

x= int(input())

if x==1:

if computer_score> person_score:

total_rounds = computer_score + 1

else:

total_rounds = person_score + 1

return

main()

rock_paper_scissors()