Fast Micro AI: better recovery from ambushes etc.

This is not necessary for most other Micro AIs, but this AI moves many
units per execution for speed reasons. If an ambush or failed teleport
or similar happens, it is better to reconsider rather than pull through
with the rest of the moves.
This commit is contained in:
mattsc 2016-10-21 20:56:53 -07:00
parent cc6679159b
commit 93f95f1d4c

View file

@ -269,7 +269,9 @@ function ca_fast_move:execution(cfg)
if best_hex then
local dx, dy = goal.x - best_hex[1], goal.y - best_hex[2]
AH.robust_move_and_attack(ai, unit, best_hex, nil, { dx = dx, dy = dy })
local move_result = AH.robust_move_and_attack(ai, unit, best_hex, nil, { dx = dx, dy = dy })
-- If something unexpected happened, return and reconsider
if (not move_result.ok) then return end
end
-- Also remove this unit from all the tables; using table.remove is fine here