Question: In this problem, you'll extend the problem we showed in class-rock paper scissors to improve with play. We do this with Machine Learning-our program leams
In this problem, you'll extend the problem we showed in class-rock paper scissors to improve with play. We do this with Machine Learning-our program leams from its play and changes its strategy based on the history of its play. 1 import randon as rn 3 #def get-best-move( rules, history) #TODO: Implement this function 4 7 def RPS(n): #INITIALIZATION 10 wins o tieso losseso moves. ["r", cnt0 12 15 16 17 18 19 20 "s". "p"] # Keep track of human's play # history. {"r":0, "p":0, "s":0} while cnt n: xinput(" play: mmoves[rn.randint (0,2)1 ^^-get-best-move(rules, history) 26 ties print("tie") elif [x,m) in rules print("human wins (0) beats (1)*.format(x,m)) wins += 1 30 31 else: losses +# 1 print("robot wins (O) beats (1)".format(m,x)) 34 35 36 cnt +# 1 print("human wins : {".forma t (wins)) print("robot wins:10".format(losses)) print("ties: t0)".format(ties)) Assignment Ne7 Programming Page 6 40#GAME 41 tint(input("How many ganes: 42 RPS(t)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
