.
This commit is contained in:
parent
59cfe70407
commit
294d3988a2
@ -343,19 +343,28 @@ local function calculateFieldInput()
|
||||
-- Total input needed
|
||||
local totalInput = baseInput + correction
|
||||
|
||||
-- SAFETY: Never return less than the drain rate (would cause field to drop)
|
||||
-- Add 10% safety margin, but ensure minimum of 1M RF/t during warmup when drain is 0
|
||||
local minimumInput = math.max(drainRate * 1.1, 1000000)
|
||||
-- If field is above target, allow input to go very low (just above drain rate)
|
||||
-- If field is below target, ensure minimum input to build field
|
||||
local minimumInput
|
||||
if currentStrength > targetStrength then
|
||||
-- Above target - only maintain drain rate, let field drop
|
||||
minimumInput = drainRate * 1.1
|
||||
else
|
||||
-- Below target - ensure some input even if drain is 0
|
||||
minimumInput = math.max(drainRate * 1.1, 1000000)
|
||||
end
|
||||
|
||||
local result = math.max(minimumInput, math.floor(totalInput))
|
||||
local result = math.max(0, math.floor(math.max(minimumInput, totalInput)))
|
||||
|
||||
-- Verbose output
|
||||
local fieldPct = string.format("%.1f%%", currentStrength * 100)
|
||||
local targetPct = string.format("%.1f%%", targetStrength * 100)
|
||||
if currentStrength < targetStrength - 0.01 then
|
||||
print("[FIELD] " .. fieldPct .. " < " .. targetPct .. " target -> increasing input to " .. formatNumber(result) .. " RF/t")
|
||||
print("[FIELD] " .. fieldPct .. " < " .. targetPct .. " target -> increasing input to " .. formatNumber(result) .. " RF/t (drain=" .. formatNumber(drainRate) .. ")")
|
||||
elseif currentStrength > targetStrength + 0.01 then
|
||||
print("[FIELD] " .. fieldPct .. " > " .. targetPct .. " target -> reducing input to " .. formatNumber(result) .. " RF/t")
|
||||
print("[FIELD] " .. fieldPct .. " > " .. targetPct .. " target -> reducing input to " .. formatNumber(result) .. " RF/t (drain=" .. formatNumber(drainRate) .. ")")
|
||||
else
|
||||
print("[FIELD] " .. fieldPct .. " at target -> maintaining " .. formatNumber(result) .. " RF/t")
|
||||
end
|
||||
|
||||
return result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user