Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

=+Are there ways that all parties can have input into the process?

Answered: 1 week ago

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago

Question

=+C&B (especially taxation) laws, regulations, and practices?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago