Advertisement
Guest User

Yomi strategy testing

a guest
Nov 7th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import numpy as np
  2.  
  3. N = 100000
  4.  
  5. with open("data.csv", 'r') as f:
  6.     M = np.array([np.array([float(n)/10 for n in row.split("\t")]) for row in f.read().split("\n")])
  7.    
  8. with open("histdata.txt", "r") as f:
  9.     step0 = np.array([int(d) for d in f.read().split("\n")])
  10.     step0 = step0/sum(step0)
  11.    
  12. step1 = step0
  13. for i in range(1): #set number of steps
  14.     step1 = M.dot(step1)
  15.     print(step1)
  16.     step1 /= sum(step1)
  17.    
  18. #Remove quotes to simulate playing only the best character
  19. """
  20. i = np.argmax(step1)
  21. print(i)
  22. step1 = np.zeros(len(step0))
  23. step1[i] = 1
  24. """
  25.  
  26. for i in range(10):
  27.     wins = 0
  28.     Rs = np.random.rand(N, 3)
  29.    
  30.     def pickfrom(dist, r):
  31.         for i in range(len(dist)):
  32.             if dist[i] > r:
  33.                 return i
  34.             else:
  35.                 r-=dist[i]
  36.    
  37.     for row in Rs:
  38.         char1 = pickfrom(step0, row[1])
  39.         char2 = pickfrom(step1, row[2])
  40.         if M[char1, char2] > row[0]:
  41.             wins+=1
  42.            
  43.     print(f"{wins/N*100}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement