Loading

Paste #ponrjzleh

  1. #!/usr/bin/env python3
  2. import numpy as np
  3.  
  4. # Storage needed without normal storage and 1st level 20 great storage:
  5. needed_storage = 600000
  6. # Build slots dedicated to great storages beyond the 1st level 20 great storage:
  7. n_storages     = 12
  8.  
  9. # initialize with worst case values
  10. best_build_time = 1000000000
  11. best_building_levels = [20] * n_storages
  12.  
  13. # Data for the great storage levels (w/o plus account)
  14. # level, time*4 [minutes], storage capacity
  15. build_times = np.array(
  16.      [
  17.      [0, 0, 0, 0],
  18.      [1, 11, 3600, 11],
  19.      [2, 16, 5100, 27],
  20.      [3, 23, 6900, 50],
  21.      [4, 34, 9300, 84],
  22.      [5, 66, 12000, 150],
  23.      [6, 140, 15000, 290],
  24.      [7, 205, 18900, 495],
  25.      [8, 275, 23100, 770],
  26.      [9, 330, 28800, 1100],
  27.      [10, 380, 36000, 1480],
  28.      [11, 460, 43200, 1940],
  29.      [12, 540, 54000, 2480],
  30.      [13, 640, 66000, 3120],
  31.      [14, 720, 78000, 3840],
  32.      [15, 830, 96000, 4670],
  33.      [16, 930, 114000, 5600],
  34.      [17, 1110, 135000, 6710],
  35.      [18, 1265, 165000, 7975],
  36.      [19, 1460, 198000, 9435],
  37.      [20, 1650, 240000, 11085]
  38.      ]
  39.      )
  40.  
  41. # capacity of the great storages with plus account (this is used)
  42. plus_capacity = build_times[:,2] * 1.25
  43.      
  44. def get_cumulative_build_time(level=0):
  45.     " Return the cumulative build time for a given level"
  46.     return build_times[level,3]/4
  47.  
  48. def get_build_time(level=0):
  49.     " Return the build time for a given level"
  50.     return build_times[level,1]/4
  51.  
  52. def get_capacity(level=0):
  53.     " Return the capacity for a certain level"
  54.     return plus_capacity[level]
  55.  
  56. def add_storage(remaining_storages, building_levels, build_time, capacity):
  57.     global best_build_time
  58.     global best_building_levels
  59.     global n_storages
  60.     "Add the build time and capacity for an additional storage"
  61.     if (capacity > needed_storage) and (build_time < best_build_time):
  62.        best_build_time = build_time
  63.        best_building_levels = building_levels
  64.        print("Time: ", best_build_time, "; Storages: ", building_levels)
  65.        # print("Storages: ", building_levels)
  66.        return
  67.    if remaining_storages == 0:
  68.        return
  69.    
  70.    for level in range(0,21):
  71.        if remaining_storages < n_storages:
  72.            if building_levels[remaining_storages] < level:
  73.                break
  74.        building_levels[remaining_storages-1] = level
  75.        add_storage(remaining_storages-1, building_levels, build_time+get_cumulative_build_time(level), capacity+get_capacity(level))
  76.  
  77. building_levels = [0] * n_storages
  78. add_storage(n_storages, building_levels, 0, 0)

Comments