logancberrypie

hoi4 minmax

Nov 7th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1.  
  2.  
  3. def CalculateCivBuildTime(civs,mills,bonus,consumerGoods, infastructure):
  4. civsAvailable = CalculateCivsAvailable(civs , mills , consumerGoods)
  5. constructionSpeed = CalculateConstructionSpeed(civsAvailable , bonus , infastructure)
  6. return civCost / constructionSpeed
  7.  
  8. def CalculateCivsAvailable(civs, mills , consumerGoods):
  9. return civs - (civs+mills)*(consumerGoods/100)
  10.  
  11. def CalculateConstructionSpeed(civsAvailable , bonus , infastructure):
  12. return 5*(1+bonus/100) * (1+infastructure / 10) * civsAvailable
  13.  
  14. def AddCivs(number):
  15. global civs
  16. civs += number
  17.  
  18. def AddMills(number):
  19. global mills
  20. mills += number
  21.  
  22. def AddBonus(number):
  23. global bonus
  24. bonus += number
  25.  
  26. def AddCivBonus(number):
  27. global civBonus
  28. civBonus += number
  29.  
  30. def AddMillBonus(number):
  31. global millBonus
  32. millBonus += number
  33.  
  34. def SetGoods(number):
  35. global goods
  36. goods = number
  37.  
  38. def BuildCivs(maxTime):
  39. global civs , mills , goods , bonus , infastructure, civBonus
  40. time = 0
  41. civCost = 10800
  42. costRemaining = civCost
  43. while(time < maxTime):
  44. for key in focusBased:
  45. if key <= time:
  46. focusBased[key]()
  47. del focusBased[key]
  48. break
  49. if (costRemaining <= 0):
  50. costRemaining = civCost
  51. civs += 1
  52. else:
  53. civsAvailable = CalculateCivsAvailable(civs, mills , goods)
  54. costRemaining -= CalculateConstructionSpeed(civsAvailable , bonus , infastructure) * (1+civBonus/100)
  55. time +=1
  56.  
  57. def BuildMills(maxTime):
  58. global civs , mills , goods , bonus , infastructure, millBonus
  59. time = 0
  60. milCost = 7200
  61. costRemaining = milCost
  62. while(time < maxTime):
  63. for key in focusBased:
  64. if key <= time:
  65. focusBased[key]()
  66. del focusBased[key]
  67. break
  68. if (costRemaining <= 0):
  69. costRemaining = milCost
  70. mills += 1
  71. else:
  72. civsAvailable = CalculateCivsAvailable(civs, mills , goods)
  73. costRemaining -= CalculateConstructionSpeed(civsAvailable , bonus , infastructure) * (1+millBonus/100)
  74. time +=1
  75.  
  76. ##maxTime = 365 * 3 + 121
  77. ##
  78. ##civTime = 100
  79. ##BuildCivs(civTime)
  80. ##millTime = maxTime -civTime
  81. ##BuildMills(millTime)
  82. ##
  83. ##
  84. ##
  85. ##
  86. ##print("Civilian Factories :",civs)
  87. ##print("Military Factories :",mills)
  88.  
  89. civs = 43
  90. mills = 9
  91. # %
  92. bonus = 10
  93. civBonus = -30
  94. millBonus = -30
  95. goods = 35
  96. #Value 0,1,2....,10
  97. infastructure = 8
  98.  
  99. #Time , command to be ran
  100. focusBased = {
  101. 210 : lambda : AddCivs(5),
  102. 280 : lambda : AddMills(5),
  103. 490 : lambda : SetGoods(30),
  104. 491 : lambda : AddCivBonus(20),
  105. 492 : lambda : AddMillBonus(20),
  106. 770 : lambda : SetGoods(25),
  107. 771 : lambda : AddCivBonus(10),
  108. 772 : lambda : AddMillBonus(20)
  109. }
  110.  
  111. def setVariables():
  112. global civs , mills , bonus, civBonus , millBonus , goods, infastructure , focusBased
  113. civs = 43
  114. mills = 9
  115. # %
  116. bonus = 10
  117. civBonus = -30
  118. millBonus = -30
  119. goods = 35
  120. #Value 0,1,2....,10
  121. infastructure = 8
  122.  
  123. #Time , command to be ran
  124. focusBased = {
  125. 210 : lambda : AddCivs(5),
  126. 280 : lambda : AddMills(5),
  127. 490 : lambda : SetGoods(30),
  128. 491 : lambda : AddCivBonus(20),
  129. 492 : lambda : AddMillBonus(20),
  130. 770 : lambda : SetGoods(25),
  131. 771 : lambda : AddCivBonus(10),
  132. 772 : lambda : AddMillBonus(20)
  133. }
  134.  
  135. maxMills = 0
  136. bestTime = 0
  137.  
  138. maxTime = 1600
  139. for i in range(0,maxTime):
  140. setVariables()
  141. civTime = i
  142. BuildCivs(civTime)
  143. millTime = maxTime -civTime
  144. BuildMills(millTime)
  145. if (mills > maxMills):
  146. maxMills = mills
  147. print(maxMills)
  148. bestTime = i
  149. i
  150.  
  151. print("max mills ",maxMills)
  152. print("best Time " ,bestTime)
Advertisement
Add Comment
Please, Sign In to add comment