|
|
@ -784,7 +784,8 @@ function Unit:PredictHealth(time) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
table.remove(self.regression_history, 1) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
table.insert(self.regression_history, { time = GetTime(), percent = self:GetHP() }) |
|
|
|
local currentTime = GetTime() |
|
|
|
|
|
|
|
table.insert(self.regression_history, { time = currentTime, percent = self:GetHP() }) |
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.regression_history do |
|
|
|
for i = 1, #self.regression_history do |
|
|
|
local entry = self.regression_history[i] |
|
|
|
local entry = self.regression_history[i] |
|
|
@ -793,9 +794,12 @@ function Unit:PredictHealth(time) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local slope, intercept = self:LinearRegression(x, y) |
|
|
|
local slope, intercept = self:LinearRegression(x, y) |
|
|
|
return slope * time + intercept |
|
|
|
|
|
|
|
|
|
|
|
return slope * (currentTime + time) + intercept |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Use linear regression to guess the time until a given health percent |
|
|
|
-- Use linear regression to guess the time until a given health percent |
|
|
|
---@param percent number |
|
|
|
---@param percent number |
|
|
|
---@return number |
|
|
|
---@return number |
|
|
|