# program to play rock, paper scissors # # Matt Bishop, MHI 289I, Fall 2024 # # first version # # list of objects things = ( "rock", "paper", "scissors" ) # list of legal commands cmdlist = ( "rock", "paper", "scissors", "quit" ) # list of winning pairs (first dominates second) winlist = ( ("rock", "scissors"), ("paper", "rock"), ("scissors", "paper") ) # scores score = { "user" : 0, "computer" : 0, "tie" : 0 } # STUB FOR TESTING -- TO BE REPLACED def getuser(): while True: n = input("Human: enter rock, paper, scissors, quit: ") if n not in cmdlist: print("Bad input; try again") else: break return n # STUB FOR TESTING -- TO BE REPLACED def getcomp(): while True: n = input("Computer: enter rock, paper, scissors, quit: ") if n not in cmdlist: print("Bad input; try again") else: break return n # STUB FOR TESTING -- TO BE REPLACED def whowins(user, comp): win = "tie" return win # pulling it all together # calls: getuser(), getcomp(), whowins() def main(): # now we play while True: # get the user's choice userchoice = getuser(); if (userchoice == "quit"): break # get the computer's choice compchoice = getcomp(); # figure out who won winner = whowins(userchoice, compchoice) # track the new score score[winner] += 1; # # announce the final score, with good grammar # print("You won", score["user"], "game(s), the computer won", end=" ") print(score["computer"], "game(s), and you two tied", score["tie"], "game(s)") main()