Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
small mode 10 changes
Browse files Browse the repository at this point in the history
Driver always starts in the middle and drives from there to the right or the left alternating. #7422
  • Loading branch information
schwiti6190 committed Aug 12, 2021
1 parent 24b3dcb commit 7ccfe38
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
27 changes: 22 additions & 5 deletions BunkerSiloAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,30 @@ function BunkerSiloAIDriver:beforeDriveIntoSilo()
end

--- Gets the best target for driving into the silo.
--- Allways starts at the right side and then drives to the left/right side.
function BunkerSiloAIDriver:getBestTarget()
if not self.lastDrivenColumn then
self:siloDebug("Starting a new approach at column 1.")
return {line=1,column=1},1
local column = math.floor(self.bunkerSiloManager:getNumberOfColumns()/2)
self:siloDebug("Starting a new approach in the middle at column %d",column)
self.lastDrivenColumnRight = true
return {line=1,column=column},1
else
local numColumns = self.bunkerSiloManager:getNumberOfColumns()
local nextColumn = self.lastDrivenColumn+1
if nextColumn > numColumns then nextColumn = 1 end
local nextColumn
if self.lastDrivenColumnRight then
nextColumn = self.lastDrivenColumn+1
if nextColumn > numColumns then
nextColumn = math.floor(self.bunkerSiloManager:getNumberOfColumns()/2)
self.lastDrivenColumnRight = false
end
else
nextColumn = self.lastDrivenColumn-1
if nextColumn <= 0 then
nextColumn = math.floor(self.bunkerSiloManager:getNumberOfColumns()/2)
self.lastDrivenColumnRight = true
end
end

self:siloDebug("Starting at column: %d, last column: %d",nextColumn,self.lastDrivenColumn)
return {line=1,column=nextColumn},1
end
Expand All @@ -294,13 +310,14 @@ end
--- Delete the best target, so after the unloader has unloaded,
--- a new approach for the silo is created.
function BunkerSiloAIDriver:beforeMainCourse()
self:deleteLastBestTarget()
self:deleteBestTarget()
end

--- Deletes the best target and forces a new approach.
function BunkerSiloAIDriver:deleteBestTarget()
self.lastDrivenColumn = nil
self.bestTarget = nil
self.lastDrivenColumnRight = not self.lastDrivenColumnRight
end

--- Deletes the best target, but saves the last driven column.
Expand Down
4 changes: 4 additions & 0 deletions BunkerSiloLoaderAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ end

function BunkerSiloLoaderAIDriver:getBunkerSiloSpeed()
return 2
end

function BunkerSiloLoaderAIDriver:getBestTarget()
return 1
end

0 comments on commit 7ccfe38

Please sign in to comment.