Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- patterns = {}
- human = 5
- lasthuman = 6
- a = [1,2,3,4,5,6,7,8,9,10]
- print 'Think of a number between 1 and 10'
- while human < 11:
- human = int(raw_input('Your choice > '))
- if lasthuman in patterns:
- robo = choice(patterns[lasthuman])
- else:
- robo = choice(a)
- print "I guess",robo
- print "----------------------------------"
- a.append(human)
- if a[-2] not in patterns:
- patterns[a[-2]] = [a[-1]]
- else:
- patterns[a[-2]].append(a[-1])
- lasthuman = human
- """
- patterns is a dictionary containing numbers and the numbers normally chosen after them
- a is a list of all numbers with chosen numbers appended to it
- the computer uses choice to make an informed guess (based on probability)
- the computer starts out with only the basic rules
- it records the human behaviour
- if you type in a repeating pattern of numbers eventually the machine will learn it
- """
Advertisement
Add Comment
Please, Sign In to add comment