Advertisement
Jackibelle

max_ilvls.py

Jan 28th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. import time
  2. from itertools import permutations
  3. import numpy as np
  4. import random
  5.  
  6.  
  7. def bonus(a,b,c,x,y,z,f,g):
  8.     return (1+a/250) * (1+b/250)**2 * (1+c/250)**3 * (1+x/250)**4 * (1+y/250)**5 * (1+z/250)**6 * (1+f/250)**7 * (1+g/250)**8
  9.  
  10.  
  11. start = time.time()
  12. arg_list = [np.zeros(8)]
  13. bonus_list = [1]
  14. args = np.zeros(8)
  15. iterindices = list(permutations(range(8), 2))
  16. b_array = np.zeros(len(iterindices))
  17. step = 8
  18.  
  19. for levels in range(8, 8000, step):
  20.     running = True
  21.     new_levels = step
  22.     while new_levels > 0:
  23.         args[random.sample(range(8), 1)[0]] += 1
  24.         new_levels -= 1
  25.     a, b, c, x, y, z, f, g = args
  26.     bon = bonus(a, b, c, x, y, z, f, g)
  27.     max_bonus = bon
  28.  
  29.     while running:
  30.         args_copy = np.vstack([args for _ in range(len(iterindices))])
  31.         for n, (i, j) in enumerate(iterindices):
  32.             if args_copy[n, i] > 0:
  33.                 args_copy[n, i] -= 1
  34.                 args_copy[n, j] += 1
  35.             a, b, c, x, y, z, f, g = args_copy[n,:]
  36.             b_array[n] = bonus(a, b, c, x, y, z, f, g)
  37.         if b_array.max() > max_bonus:
  38.             max_bonus =b_array.max()
  39.             swap = iterindices[b_array.argmax()]
  40.             args[swap[0]] -= 1
  41.             args[swap[1]] += 1
  42.         else:
  43.             running = False
  44.     arg_list.append(args)
  45.     bonus_list.append(max_bonus)
  46. end = time.time()
  47. print(end-start)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement