{{{id=1| #These variables store the mineral, gas, and larva cost for each unit. The larva and mineral costs for the overlord supply are included drone = [62.5,0,1.125] overlord = [100,0,1] overseer = [150,100,1] zergling = [31.25,0,0.5625] queen = [175,0,.25] baneling = [56.25,25,0.5625] roach = [100,25,1.25] hydralisk = [112.5,50,1.25] mutalisk = [112.5,100,1.25] corrupter = [162.5,100,1.25] infestor = [112.5,150,1.25] ultralisk = [375,200,1.75] broodlord = [350,250,1.5] unitList = [drone, overlord, overseer, zergling, queen, baneling, roach, hydralisk, mutalisk, corrupter, infestor, ultralisk, broodlord] #Hatcheries correspond to larva output. Hatcheries with Queens achieve a different rate. hatchRate = 1/15 queenRate = 1/6 minRate = 7/10 dimMinRate = 3/10 #The rate of return for the third worker added to a mineral patch is lower than for the first two. There is no benefit from workers beyond the third. gasRate = 19/30 minPatch = 0 geysers = 0 compCost = [0,0,0] #The input here should be the relative numbers of each of the 13 units in the order listed above. Because of how larva cost is used the input can be fractions of the total army output or relative quantities. Overlords needed for supply should be ignored. The output is the total cost of the given unit mix. Queens, being the only unit not built from larva, are not calculable through the same methods. def prodCost(unitComp): compCost = [0,0,0] for n in [0..12]: for m in [0..2]: compCost[m] += unitList[n][m]*unitComp[n] return compCost #This calculates the worker saturation needed based on a given number of bases held, hatcheries built, and unit composition desired. It is assumed that each hatchery will have a Queen, considering that in most stages of the game that will be the case. By def setBase(x,y,z): minDrones = 0 gasDrones = 0 minPatch = 8*x geysers = 2*x larvaRate = y*queenRate compCost = prodCost(z) minCostSec = compCost[0]*(larvaRate/compCost[2]) #Calculates the costs per second of the given composition for easy calculation. gasCostSec = compCost[1]*(larvaRate/compCost[2]) #Calculates the required drones in the event that fewer than two workers per patch will be needed. if minCostSec/minRate < 2*minPatch: minDrones = minCostSec/minRate #Calculates the required drones in the event that more than two workers per patch will be needed. if minCostSec/minRate > 2*minPatch: minCostTemp = minCostSec - minPatch * minRate * 2 minDrones = minPatch*2 + minCostTemp/dimMinRate #Handles the case in which the number of bases is insufficient for constant production. if minDrones > 3*minPatch: minDrones = 3*minPatch print ("Production will be mineral limited.") #Similarly, calculates the number of drones needed as well as checking whether full saturation will fail to allow for full army production. gasDrones = gasCostSec/gasRate if gasDrones > geysers*3: print ("Production will be gas limited.") gasDrones = geysers*3 print("Drones on minerals:") print(minDrones) print("Drones on gas:") print(gasDrones) /// }}} {{{id=5| setBase(2,2,[0,0,0,8,0,1,2,0,0,0,0,0,0]) /// Drones on minerals: 31.8772136953955 Drones on gas: 5.21966072205307 }}}