ExpAI: capture villages with injured units if no enemy can reach

This commit is contained in:
mattsc 2013-11-01 09:19:54 -07:00
parent 948147550a
commit d8c35a75c8

View File

@ -313,7 +313,7 @@ return {
local enemy_distance_from_village = AH.get_closest_enemy(v)
-- Now we go on to the unit-dependent rating
local best_unit_rating = 0
local best_unit_rating = -9e99
local reachable = false
for i,u in ipairs(units) do
-- Skip villages that have units other than 'u' itself on them
@ -334,8 +334,13 @@ return {
reachable = true
--print('Can reach:', u.id, v[1], v[2], cost)
local rating = 0
-- Finally, since these can be reached by the enemy, want the strongest unit to go first
rating = rating + u.hitpoints / 100.
-- Prefer strong units if enemies can reach the village, injured units otherwise
if enemy_attack_map:get(v[1], v[2]) then
rating = rating + u.hitpoints
else
rating = rating + u.max_hitpoints - u.hitpoints
end
-- Prefer not backtracking and moving more distant units to capture villages
local enemy_distance_from_unit = AH.get_closest_enemy({u.x, u.y})