Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. import sys
  2.  
  3. #colony mines [met, cris, deut, fusionreactor, max_temp, name]
  4. colonies = [
  5. #[25, 23, 20, 11, 3, 'The Rice Fields'],
  6. # [0, 0, 0, 0, 74, 'New rice fields'],
  7. [28, 26, 22, 11, 78, 'Realm iii'],
  8. [26, 24, 20, 10, 59, 'Realm 900'],
  9. [26, 23, 20, 11, 73, 'Realm 305'],
  10. [26, 23, 20, 11, 48, 'Realm 3009'],
  11. [26, 23, 20, 11, 74, 'Realm 42'],
  12. [26, 23, 20, 11, 35, 'Realm 6'],
  13. [26, 23, 20, 10, 31, 'Realm 69']
  14. ]
  15. #Level of plasma-research
  16. plasma = 7
  17.  
  18. #uni-speed
  19. unispeed = 5
  20.  
  21. #base income of [met, cris, deut]
  22. base = [30, 15, 0]
  23.  
  24. #buffer for total production
  25. production = [0, 0, 0]
  26.  
  27. #mse to determine value
  28. mse = [2, 1, 1]
  29. #mse = [3, 2, 1]
  30.  
  31. def upgradecosts(colo):
  32. return [[int(40*1.5**(colo[0]+1)), int(10*1.5**(colo[0]+1)), 0],
  33. [int(30*1.6**(colo[1]+1)), int(15*1.6**(colo[1]+1)), 0],
  34. [int(150*1.5**(colo[2]+1)), int(50*1.5**(colo[2]+1)), 0]]
  35.  
  36. def upgradevalue(colo):
  37. return [[int(30*(colo[0]+1)*1.1**(colo[0]+1)*unispeed*(1+(plasma*0.01))) - int(30*colo[0]*1.1**colo[0]*unispeed*(1+(plasma*0.01))), 0, 0],
  38. [0, int(20*(colo[1]+1)*1.1**(colo[1]+1)*unispeed*(1+(plasma*0.01*2/3)))-int(20*colo[1]*1.1**colo[1]*unispeed*(1+(plasma*0.01*2/3))), 0],
  39. [0, 0, int(10*(colo[2]+1)*1.1**(colo[2]+1)*(1.44 - 0.004*colo[4])*unispeed*(1+(plasma*0.01*1/3)))-int(10*colo[2]*1.1**colo[2]*(1.44 - 0.004*colo[4])*unispeed*(1+(plasma*0.01*1/3)))]]
  40. def getproduction(colos):
  41. p = [0, 0, 0]
  42. for colo in colos:
  43. p[0] += int(30*colo[0]*1.1**colo[0]*unispeed*(1+(plasma*0.01)))
  44. p[1] += int(20*colo[1]*1.1**colo[1]*unispeed*(1+(plasma*0.01*2/3)))
  45. p[2] += int(10*colo[2]*1.1**colo[2]*(1.44 - 0.004*colo[4])*unispeed*(1+(plasma*0.01*1/3)))
  46. p[2] -= int(10*colo[3]*1.1**colo[3]*unispeed)
  47. p[0] += base[0]*unispeed
  48. p[1] += base[1]*unispeed
  49. p[2] += base[2]*unispeed
  50. return p
  51. def bestnext(colos, turns=10):
  52. colos = [colo[:] for colo in colos]
  53. nextturns = []
  54. for k in range(turns):
  55. best = None
  56. bestcosts = None
  57. for i in range(len(colos)):
  58. colo = colos[i]
  59. msecosts = [0, 0, 0]
  60. msevalues = [0, 0, 0]
  61. values = upgradevalue(colo)
  62. costs = upgradecosts(colo)
  63. for i in range(3):
  64. msecosts[i] = sum([int(costs[i][0]/mse[0]), int(costs[i][1]/mse[1]), int(costs[i][2]/mse[2])])
  65. msevalues[i] = sum([int(values[i][0]/mse[0]), int(values[i][1]/mse[1]), int(values[i][2]/mse[2])])
  66. if msecosts[0]/msevalues[0] < msecosts[1]/msevalues[1]:
  67. if msecosts[0]/msevalues[0] < msecosts[2]/msevalues[2]:
  68. bestchoice = [0 ,msecosts[0]/msevalues[0]]
  69. else:
  70. bestchoice = [2 ,msecosts[2]/msevalues[2]]
  71. elif msecosts[1]/msevalues[1] < msecosts[2]/msevalues[2]:
  72. bestchoice = [1 ,msecosts[1]/msevalues[1]]
  73. else:
  74. bestchoice = [2 ,msecosts[2]/msevalues[2]]
  75. if not best or best[1] > bestchoice[1]:
  76. best = bestchoice
  77. bestcosts = costs
  78. best.append(colo)
  79. mine = 'Met' if best[0] == 0 else 'Cris' if best[0] == 1 else 'Deut'
  80. production = getproduction(colos)
  81. time = max([bestcosts[best[0]][i] / production[i] for i in range(3)])
  82. print('{:<3}: Upgrade {:4} on {:15} from {} to {} ({}h {:2}min global production)'.format(k+1, mine, best[2][5], best[2][best[0]], best[2][best[0]]+1, int(time), int((time*60)%60)))
  83. print(*(costs[best[0]][i] for i in range(3)))
  84. best[2][best[0]] += 1
  85.  
  86. if len(sys.argv) > 1:
  87. turns = int(sys.argv[1])
  88. else:
  89. turns = 20
  90. bestnext(colonies, turns)
  91. production = getproduction(colonies)
  92. print("\n\nTotal Production:\n{}k Met/h\n{}k Cris/h\n{}k Deut/h".format(production[0]//1000, production[1]//1000, production[2]//1000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement