Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved 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

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 users 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 users 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 users 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.

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

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions