Skip to content

Commit

Permalink
noReverse config activated
Browse files Browse the repository at this point in the history
If noReverse is configured for an implement,
or the Giants function reports it should not
be reversed then don't move a turn back to
able to remain on the field as it always
introduces reverse sections.
  • Loading branch information
pvaiko committed Apr 2, 2022
1 parent f83799f commit f36e5b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions scripts/ai/AIUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -604,4 +604,17 @@ function AIUtil.getWidth(vehicle)
else
return vehicle.size.width
end
end

--- Can we reverse with whatever is attached to the vehicle?
function AIUtil.canReverse(vehicle)
if AIVehicleUtil.getAttachedImplementsBlockTurnBackward(vehicle) then
-- Giants says no reverse
return false
elseif g_vehicleConfigurations:getRecursively(vehicle, 'noReverse') then
-- our configuration disabled reverse
return false
else
return true
end
end
7 changes: 4 additions & 3 deletions scripts/ai/turns/TurnManeuver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,10 @@ function AnalyticTurnManeuver:init(vehicle, turnContext, vehicleDirectionNode, t
local dzMax = self:getDzMax(self.course)
local spaceNeededOnFieldForTurn = dzMax + workWidth / 2
distanceToFieldEdge = distanceToFieldEdge or 500 -- if not given, assume we have a lot of space
self:debug('dzMax=%.1f, workWidth=%.1f, spaceNeeded=%.1f, distanceToFieldEdge=%.1f, ixBeforeEndingTurnSection=%d',
dzMax, workWidth, spaceNeededOnFieldForTurn, distanceToFieldEdge, ixBeforeEndingTurnSection)
if distanceToFieldEdge < spaceNeededOnFieldForTurn then
local canReverse = AIUtil.canReverse(vehicle)
self:debug('dzMax=%.1f, workWidth=%.1f, spaceNeeded=%.1f, distanceToFieldEdge=%.1f, ixBeforeEndingTurnSection=%d, canReverse=%s',
dzMax, workWidth, spaceNeededOnFieldForTurn, distanceToFieldEdge, ixBeforeEndingTurnSection, canReverse)
if distanceToFieldEdge < spaceNeededOnFieldForTurn and canReverse then
self.course = self:moveCourseBack(self.course, spaceNeededOnFieldForTurn - distanceToFieldEdge,
ixBeforeEndingTurnSection, endingTurnLength)
end
Expand Down

0 comments on commit f36e5b1

Please sign in to comment.