lolamontes69

Python/ Think of a number between 1 and 10

May 16th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from random import choice
  2.  
  3. patterns = {}
  4. human = 5
  5. lasthuman = 6
  6. a = [1,2,3,4,5,6,7,8,9,10]
  7.  
  8. print 'Think of a number between 1 and 10'
  9. while human < 11:
  10.     human = int(raw_input('Your choice > '))
  11.     if lasthuman in patterns:
  12.         robo = choice(patterns[lasthuman])
  13.     else:
  14.         robo = choice(a)
  15.     print "I guess",robo
  16.     print "----------------------------------"
  17.     a.append(human)
  18.     if a[-2] not in patterns:
  19.         patterns[a[-2]] = [a[-1]]
  20.     else:
  21.         patterns[a[-2]].append(a[-1])
  22.     lasthuman = human
  23.  
  24.  
  25. """
  26. patterns is a dictionary containing numbers and the numbers normally chosen after them
  27. a is a list of all numbers with chosen numbers appended to it
  28.  
  29. the computer uses choice to make an informed guess (based on probability)
  30. the computer starts out with only the basic rules
  31. it records the human behaviour
  32.  
  33. if you type in a repeating pattern of numbers eventually the machine will learn it
  34.  
  35. """
Advertisement
Add Comment
Please, Sign In to add comment