MarLind

Forutsigbarhet, 2015-02-26

Mar 26th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.37 KB | None | 0 0
  1. __author__ = 'marius'
  2.  
  3. Prob = [[[[[0]]]], [[[[0]]], [[[0]], [[0], [0, 1, 2], [0, 1, 2]], [[0], [0, 1, 2], [0, 1, 2]]],
  4.                     [[[0]], [[0], [0, 1, 2], [0, 1, 2]], [[0], [0, 1, 2], [0, 1, 2]]]],
  5.         [[[[0]]], [[[0]], [[0], [0, 1, 2], [0, 1, 2]], [[0], [0, 1, 2], [0, 1, 2]]],
  6.          [[[0]], [[0], [0, 1, 2], [0, 1, 2]], [[0], [0, 1, 2], [0, 1, 2]]]]]
  7.  
  8. "Lea: Prob = [[[[[[2, 0.5]]]]], [[[[[1, 0.0]]]], [[[[1, 0.0]]], [[[1, 1.0]], [0, 1, 2], [0, [2, 1.0], [1, 1.0]]], [[0], [0, 1, [2, 0.0]], [0, [1, 1.0], [1, 0.0]]]], [[[[1, 1.0]]], [[0], [0, [2, 1.0], 2], [0, [3, 0.3333], [1, 1.0]]], [[0], [0, [1, 0.0], 2], [0, [1, 1.0], [2, 0.5]]]]], [[[[[1, 0.0]]]], [[[0]], [[0], [[1, 1.0], 1, [3, 0.3333]], [0, 1, [1, 1.0]]], [[[1, 1.0]], [0, [2, 0.5], [2, 0.0]], [0, 1, [1, 0.0]]]], [[[0]], [[0], [0, [2, 0.5], [1, 1.0]], [[1, 1.0], [1, 1.0], 2]], [[0], [0, [1, 1.0], [2, 0.5]], [0, [2, 0.5], [2, 0.5]]]]]]"
  9.  
  10. "Vilde: Prob = [[[[[[8, 0.25]]]]], [[[[[6, 0.6667]]]], [[[[2, 0.5]]], [[[1, 1.0]], [0, [2, 1.0], [4, 0.5]], [0, [8, 0.75], [5, 0.6]]], [[0], [0, [5, 0.2], [7, 0.2857]], [0, [4, 0.0], [4, 0.75]]]], [[[[2, 1.0]]], [[[3, 1.0]], [[1, 1.0], [7, 0.8571], [5, 0.2]], [0, [2, 0.5], [9, 0.3333]]], [[0], [[1, 0.0], [5, 1.0], [8, 0.625]], [0, [7, 0.4286], [3, 0.3333]]]]], [[[[[2, 0.0]]]], [[[[4, 0.25]]], [[[1, 0.0]], [[1, 0.0], [4, 0.25], [8, 0.625]], [0, [3, 0.3333], [3, 0.0]]], [[[2, 1.0]], [[3, 1.0], [7, 0.8571], [4, 0.75]], [0, [10, 0.4], [4, 0.0]]]], [[[0]], [[[1, 0.0]], [0, [5, 0.0], [1, 1.0]], [[2, 1.0], [12, 0.5], [4, 0.5]]], [[0], [0, [1, 1.0], [9, 0.2222]], [0, [3, 0.0], 2]]]]]"
  11.  
  12. "Marius: Prob = [[[[[[10, 0.6]]]]], [[[[[4, 0.25]]]], [[[[3, 0.6667]]], [[[1, 1.0]], [0, [1, 1.0], [4, 0.75]], [0, [8, 0.875], [7, 0.5714]]], [[[1, 1.0]], [[1, 1.0], [8, 0.625], [10, 0.5]], [0, [9, 0.4444], [8, 0.625]]]], [[[[4, 0.75]]], [[[1, 0.0]], [0, [9, 0.5556], [10, 0.3999]], [[3, 0.0], [2, 0.5], [11, 0.3636]]], [[[1, 1.0]], [0, [10, 0.7], [11, 0.3636]], [[1, 0.0], [9, 0.3332], [5, 0.8]]]]], [[[[[6, 0.3333]]]], [[[[1, 0.0]]], [[[2, 1.0]], [[1, 0.0], [4, 0.0], [11, 0.4545]], [[1, 1.0], [11, 0.6364], [9, 0.2222]]], [[[3, 0.0]], [0, [8, 0.875], [5, 0.8]], [[1, 0.0], [11, 0.5455], [7, 0.2857]]]], [[[[2, 0.5]]], [[0], [[2, 0.0], [5, 0.4], [9, 0.4444]], [0, [11, 0.2727], [8, 0.625]]], [[[1, 0.0]], [0, [6, 0.5], [8, 0.25]], [0, [5, 0.2], [2, 0.5]]]]]]"
  13.  
  14. """b = None
  15. while b != "y" and b != "yes" and b != "n" and b != "no":
  16.   b = input("Input probabilities? (y/n) ")
  17.   if b == "y" or b == "yes":
  18.       Prob = input("Enter prob:\n")
  19.       print(str(Prob))"""
  20.  
  21. Human = [0] * 5
  22.  
  23. Predictability = [0, 0]
  24.  
  25.  
  26. def find(a):  # H is the last a inputs in new-old order
  27.     L = Prob
  28.     global H
  29.     H = Human[-5:]
  30.     H.reverse()
  31.  
  32.     for n in H[:a]:
  33.         L = L[n]
  34.     for n in range(5 - a):
  35.         L = L[0]
  36.  
  37.  
  38.     if a == 0:
  39.         if type(L) == int:  ###
  40.             print("!!!" + "X" * 32)  ###
  41.  
  42.     elif type(L) is int:  # Will nest to find non-0
  43.         Prob[H[0]][H[1]][H[2]][H[3]][H[4]] = [0, 0]
  44.         return find(a - 1)
  45.     elif len(L) == 1 or L == [0, 0]:
  46.         return find(a - 1)
  47.  
  48.     print(" " * 18 + str(L))
  49.     if a == 5:
  50.         L.append(L)
  51.         print(L)
  52.         return L
  53.     else:
  54.         return [0, 0, L]
  55.  
  56.  
  57. while True:
  58.     Chance = find(5)
  59.  
  60.     I = input(
  61.         "..." + str(Human[-5]) + ", " + str(Human[-4]) + ", " + str(Human[-3]) + ", " + str(Human[-2]) + ", " + str(
  62.             Human[-1]) + ", ")
  63.     # Can be shortened
  64.  
  65.     if not (I == "1" or I == "2"):
  66.         J = input("Terminate? ")
  67.         J.lower()
  68.         if J == "y" or J == "yes":
  69.             print(("_" * 64 + "\n") * 3)
  70.             break
  71.         print("Resuming..")
  72.         continue
  73.     I = int(I)
  74.  
  75.     Predictability[0] += 1
  76.     if I == 1:
  77.         Predictability[1] += 1 - Chance[2][1]
  78.     if I == 2:
  79.         Predictability[1] += Chance[2][1]
  80.  
  81.     Chance[1] = float(Chance[1]) * int(Chance[0]) + I - 1
  82.     Chance[0] += 1
  83.     Chance[1] = round((Chance[1] / Chance[0]), 4)
  84.  
  85.     Prob[Human[-1]][Human[-2]][Human[-3]][Human[-4]][Human[-5]] = Chance[:2]
  86.     print("-" * 32 + "\n" + "-" * 32)
  87.  
  88.     print(Predictability)
  89.  
  90.     Human.append(I)
  91.  
  92. J = input("Print Prob? ")
  93. J.lower()
  94. if J == "y" or J == "yes":
  95.     print("\n" + str(Prob), end="\n")
  96.  
  97. print(str(Predictability[0]) + " inputs\n" + str(round(Predictability[1] / Predictability[0] * 1000)) + " ‰ predictable")
Advertisement
Add Comment
Please, Sign In to add comment