ExpAI: ignore unreachable enemy leaders when selecting keep

This commit is contained in:
mattsc 2013-11-01 09:24:05 -07:00
parent d8c35a75c8
commit 241fd529e0

View file

@ -66,6 +66,20 @@ return {
wesnoth.require("ai/lua/generic_recruit_engine.lua").init(ai, generic_rush, params)
-------- Castle Switch CA --------------
local function get_reachable_enemy_leaders(unit)
local potential_enemy_leaders = AH.get_live_units { canrecruit = 'yes',
{ "filter_side", { { "enemy_of", {side = wesnoth.current.side} } } }
}
local enemy_leaders = {}
for j,e in ipairs(potential_enemy_leaders) do
local path, cost = wesnoth.find_path(unit, e.x, e.y, { ignore_units = true, viewing_side = 0 })
if cost < AH.no_path then
table.insert(enemy_leaders, e)
end
end
return enemy_leaders
end
function generic_rush:castle_switch_eval()
local start_time, ca_name = wesnoth.get_time_stamp() / 1000., 'castle_switch'
@ -122,9 +136,7 @@ return {
return 0
end
local enemy_leaders = AH.get_live_units { canrecruit = 'yes',
{ "filter_side", { { "enemy_of", {side = wesnoth.current.side} } } }
}
local enemy_leaders = get_reachable_enemy_leaders(leader)
-- Look for the best keep
local best_score, best_loc, best_turns = 0, {}, 3