Fast MAI: don't target unowned villages if AI side has no leader

Only enemy-owned villages should be targets for leaderless AI sides.
This commit is contained in:
mattsc 2014-05-05 07:22:25 -07:00
parent 7ba550a63e
commit 053a9350a1

View file

@ -30,11 +30,16 @@ function ca_fast_move:execution(ai, cfg, self)
local villages = wesnoth.get_villages()
-- Eliminate villages owned by a side that is not an enemy
-- Also remove unowned villages if the AI has no leader
for i = #villages,1,-1 do
local owner = wesnoth.get_village_owner(villages[i][1], villages[i][2])
if owner and (not wesnoth.is_enemy(owner, wesnoth.current.side)) then
table.remove(villages, i)
end
if (not leader) and (not owner) then
table.remove(villages, i)
end
end
-- Add rating that is sum of inverse distances from all other villages