Wolves Micro AI: better recovery from ambushes etc.
This is not necessary for most other Micro AIs, but this AI moves several units per execution. If an ambush or failed teleport or similar happens, it is better to reconsider rather than pull through with the previously planned moves.
This commit is contained in:
parent
348f64f4a0
commit
67fd4367fd
2 changed files with 9 additions and 3 deletions
|
@ -63,7 +63,9 @@ function ca_wolves_move:execution(cfg)
|
|||
return rating
|
||||
end)
|
||||
|
||||
AH.movefull_stopunit(ai, wolves[1], wolf1)
|
||||
local move_result = AH.movefull_stopunit(ai, wolves[1], wolf1)
|
||||
-- If the wolf was ambushed, return and reconsider; also if an event removed a wolf
|
||||
if (AH.is_incomplete_move(move_result)) then return end
|
||||
for _,check_wolf in ipairs(wolves) do
|
||||
if (not check_wolf) or (not check_wolf.valid) then return end
|
||||
end
|
||||
|
@ -90,7 +92,9 @@ function ca_wolves_move:execution(cfg)
|
|||
return rating
|
||||
end)
|
||||
|
||||
AH.movefull_stopunit(ai, wolves[i], move)
|
||||
local move_result = AH.movefull_stopunit(ai, wolves[i], move)
|
||||
-- If the wolf was ambushed, return and reconsider; also if an event removed a wolf
|
||||
if (AH.is_incomplete_move(move_result)) then return end
|
||||
for _,check_wolf in ipairs(wolves) do
|
||||
if (not check_wolf) or (not check_wolf.valid) then return end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,9 @@ function ca_wolves_wander:execution(cfg)
|
|||
return rating
|
||||
end)
|
||||
|
||||
AH.movefull_stopunit(ai, wolf, best_hex)
|
||||
local move_result = AH.movefull_stopunit(ai, wolf, best_hex)
|
||||
-- If the wolf was ambushed, return and reconsider; also if an event removed a wolf
|
||||
if (AH.is_incomplete_move(move_result)) then return end
|
||||
for _,check_wolf in ipairs(wolves) do
|
||||
if (not check_wolf) or (not check_wolf.valid) then return end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue