Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- N = 100000
- with open("data.csv", 'r') as f:
- M = np.array([np.array([float(n)/10 for n in row.split("\t")]) for row in f.read().split("\n")])
- with open("histdata.txt", "r") as f:
- step0 = np.array([int(d) for d in f.read().split("\n")])
- step0 = step0/sum(step0)
- step1 = step0
- for i in range(1): #set number of steps
- step1 = M.dot(step1)
- print(step1)
- step1 /= sum(step1)
- #Remove quotes to simulate playing only the best character
- """
- i = np.argmax(step1)
- print(i)
- step1 = np.zeros(len(step0))
- step1[i] = 1
- """
- for i in range(10):
- wins = 0
- Rs = np.random.rand(N, 3)
- def pickfrom(dist, r):
- for i in range(len(dist)):
- if dist[i] > r:
- return i
- else:
- r-=dist[i]
- for row in Rs:
- char1 = pickfrom(step0, row[1])
- char2 = pickfrom(step1, row[2])
- if M[char1, char2] > row[0]:
- wins+=1
- print(f"{wins/N*100}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement