ai_helper.next_hop: fix bug in fan-out code
This fixes the case when the unit cannot reach the previously found next_hop location from the ideal next_hop location in the part of the code that tries to keep units from moving in single file.
This commit is contained in:
parent
f620314800
commit
a666a34055
1 changed files with 3 additions and 1 deletions
|
@ -1531,7 +1531,9 @@ function ai_helper.next_hop(unit, x, y, cfg)
|
|||
local unit_map = LS.create()
|
||||
for _,u in ipairs(units) do unit_map:insert(u.x, u.y, u.id) end
|
||||
|
||||
local max_rating = inverse_reach_map:get(next_hop[1], next_hop[2]) -- do not move farther away
|
||||
-- Do not move farther away, but if next_hop is out of reach from next_hop_ideal,
|
||||
-- anything in reach is better -> set to -infinity in that case.
|
||||
local max_rating = inverse_reach_map:get(next_hop[1], next_hop[2]) or - math.huge
|
||||
for _,loc in ipairs(reach) do
|
||||
if (not unit_map:get(loc[1], loc[2]))
|
||||
and ((not cfg) or (not cfg.avoid_map) or (not cfg.avoid_map:get(loc[1], loc[2])))
|
||||
|
|
Loading…
Add table
Reference in a new issue