don't overbuild bots

This commit is contained in:
Luke Hubmayer-Werner 2022-12-20 00:03:57 +10:30
parent db2a2f451e
commit d2cfb99823
1 changed files with 20 additions and 17 deletions

View File

@ -18,6 +18,7 @@ def blueprintQuality(line: String, tMax: Int=24): (Int, Int, Int) =
val cost_geodebot_ore = nums(5) val cost_geodebot_ore = nums(5)
val cost_geodebot_obs = nums(6) val cost_geodebot_obs = nums(6)
val max_cost_ore = cost_orebot_ore max cost_claybot_ore max cost_obsbot_ore max cost_geodebot_ore
val maxPossibleInXMinutes = (0 to 32).toArray val maxPossibleInXMinutes = (0 to 32).toArray
for i <- 1 to 32 do for i <- 1 to 32 do
@ -40,7 +41,7 @@ def blueprintQuality(line: String, tMax: Int=24): (Int, Int, Int) =
nextRes(2) -= cost_geodebot_obs nextRes(2) -= cost_geodebot_obs
mostGeodes = mostGeodes max simStep(tn, numRobots, nextRes, totalGeodes + (tMax-tn), mostGeodes) mostGeodes = mostGeodes max simStep(tn, numRobots, nextRes, totalGeodes + (tMax-tn), mostGeodes)
// Try to make an Obs robot // Try to make an Obs robot
if numRobots(1) > 0 then if numRobots(1) > 0 && numRobots(2) < cost_geodebot_obs then
dt = 1 max (((cost_obsbot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build dt = 1 max (((cost_obsbot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build
dt = dt max (((cost_obsbot_clay - numRes(1)) ceilDiv numRobots(1)) + 1) // Must always spend at least 1 minute to build dt = dt max (((cost_obsbot_clay - numRes(1)) ceilDiv numRobots(1)) + 1) // Must always spend at least 1 minute to build
tn = t + dt tn = t + dt
@ -52,6 +53,7 @@ def blueprintQuality(line: String, tMax: Int=24): (Int, Int, Int) =
nextRes(1) -= cost_obsbot_clay nextRes(1) -= cost_obsbot_clay
mostGeodes = mostGeodes max simStep(tn, nextRobots, nextRes, totalGeodes, mostGeodes) mostGeodes = mostGeodes max simStep(tn, nextRobots, nextRes, totalGeodes, mostGeodes)
// Try to make an Ore robot // Try to make an Ore robot
if numRobots(0) < max_cost_ore then
dt = 1 max (((cost_orebot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build dt = 1 max (((cost_orebot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build
tn = t + dt tn = t + dt
if tn < (tMax-1) then // any ore past that point is worthless if tn < (tMax-1) then // any ore past that point is worthless
@ -61,6 +63,7 @@ def blueprintQuality(line: String, tMax: Int=24): (Int, Int, Int) =
nextRes(0) -= cost_orebot_ore nextRes(0) -= cost_orebot_ore
mostGeodes = mostGeodes max simStep(tn, nextRobots, nextRes, totalGeodes, mostGeodes) mostGeodes = mostGeodes max simStep(tn, nextRobots, nextRes, totalGeodes, mostGeodes)
// Try to make a Clay robot // Try to make a Clay robot
if numRobots(1) < cost_obsbot_clay then
dt = 1 max (((cost_claybot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build dt = 1 max (((cost_claybot_ore - numRes(0)) ceilDiv numRobots(0)) + 1) // Must always spend at least 1 minute to build
tn = t + dt tn = t + dt
if tn < (tMax-2) then // any clay past that point is worthless, needs to turn to obs if tn < (tMax-2) then // any clay past that point is worthless, needs to turn to obs