High XP attacks: adapt other AIs to existence of new CA

This means:
1. Adding the new CA to AI configs
2. Removing it whenever the combat CA is removed
3. Preventing conflicts for AIs that previously used overlapping scores
This commit is contained in:
mattsc 2016-09-03 20:00:12 -07:00
parent 8e50c4ee06
commit d781e6263a
11 changed files with 17 additions and 4 deletions

View file

@ -16,6 +16,7 @@
{AI_CA_RECRUITMENT}
{AI_CA_MOVE_LEADER_TO_GOALS}
{AI_CA_MOVE_LEADER_TO_KEEP}
{AI_CA_HIGH_XP_ATTACK}
{AI_CA_COMBAT}
{AI_CA_HEALING}
{AI_CA_VILLAGES}

View file

@ -22,6 +22,7 @@
#{AI_CA_RECRUITMENT}
{AI_CA_MOVE_LEADER_TO_GOALS}
{AI_CA_MOVE_LEADER_TO_KEEP}
{AI_CA_HIGH_XP_ATTACK}
{AI_CA_COMBAT}
{AI_CA_HEALING}
{AI_CA_VILLAGES}

View file

@ -14,6 +14,7 @@
{AI_CA_RECRUITMENT}
{AI_CA_MOVE_LEADER_TO_GOALS}
{AI_CA_MOVE_LEADER_TO_KEEP}
{AI_CA_HIGH_XP_ATTACK}
{AI_CA_COMBAT}
{AI_CA_HEALING}
{AI_CA_VILLAGES}

View file

@ -7,7 +7,7 @@ function ca_healer_may_attack:evaluation()
-- After attacks by all other units are done, reset things so that healers can attack, if desired
-- This will be blacklisted after first execution each turn
local score = 99990
local score = 99900
return score
end

View file

@ -17,7 +17,7 @@ function ca_return_guardian:evaluation(cfg)
local guardian = get_guardian(cfg)
if guardian then
if (guardian.x == cfg.return_x) and (guardian.y == cfg.return_y) then
return cfg.ca_score - 20
return cfg.ca_score - 200
else
return cfg.ca_score
end

View file

@ -71,6 +71,11 @@ function wesnoth.micro_ais.fast_ai(cfg)
}
else
if (not cfg.skip_combat_ca) then
W.modify_ai {
side = cfg.side,
action = "try_delete",
path = "stage[main_loop].candidate_action[high_xp_attack]"
}
W.modify_ai {
side = cfg.side,
action = "try_delete",

View file

@ -34,7 +34,7 @@ function wesnoth.micro_ais.return_guardian(cfg)
local optional_keys = { "id", "[filter]" }
local CA_parms = {
ai_id = 'mai_return_guardian',
{ ca_id = 'move', location = 'ca_return_guardian.lua', score = cfg.ca_score or 100010 }
{ ca_id = 'move', location = 'ca_return_guardian.lua', score = cfg.ca_score or 100100 }
}
return required_keys, optional_keys, CA_parms
end

View file

@ -11,7 +11,7 @@ function wesnoth.micro_ais.healer_support(cfg)
-- The healers_can_attack CA is only added to the table if aggression ~= 0
-- But: make sure we always try removal
if (cfg.action == 'delete') or (tonumber(cfg.aggression) ~= 0) then
table.insert(CA_parms, { ca_id = 'may_attack', location = 'ca_healer_may_attack.lua', score = 99990 })
table.insert(CA_parms, { ca_id = 'may_attack', location = 'ca_healer_may_attack.lua', score = 99900 })
end
return {}, optional_keys, CA_parms
end

View file

@ -71,6 +71,7 @@ Gs^Fp , Gs^Fp , Wwf , Wwf , Mm , Rd
{AI_CA_GOTO}
{AI_CA_MOVE_LEADER_TO_GOALS}
{AI_CA_MOVE_LEADER_TO_KEEP}
{AI_CA_HIGH_XP_ATTACK}
{AI_CA_COMBAT}
{AI_CA_HEALING}
{AI_CA_VILLAGES}

View file

@ -72,6 +72,7 @@
location="campaigns/The_Rise_Of_Wesnoth/ai/ca_aggressive_attack_no_suicide.lua"
[/candidate_action]
)}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 2 main_loop high_xp_attack}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 2 main_loop combat}
[/ai]
{FLAG_VARIANT wood-elvish}
@ -115,6 +116,7 @@
location="campaigns/The_Rise_Of_Wesnoth/ai/ca_aggressive_attack_no_suicide.lua"
[/candidate_action]
)}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 3 main_loop high_xp_attack}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 2 main_loop combat}
[/ai]
{FLAG_VARIANT knalgan}
@ -157,6 +159,7 @@
location="campaigns/The_Rise_Of_Wesnoth/ai/ca_aggressive_attack_no_suicide.lua"
[/candidate_action]
)}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 4 main_loop high_xp_attack}
{MODIFY_AI_DELETE_CANDIDATE_ACTION 2 main_loop combat}
[/ai]
{FLAG_VARIANT long}

View file

@ -553,6 +553,7 @@
#{AI_CA_RECRUITMENT}
{AI_CA_MOVE_LEADER_TO_GOALS}
{AI_CA_MOVE_LEADER_TO_KEEP}
{AI_CA_HIGH_XP_ATTACK}
{AI_CA_COMBAT}
{AI_CA_HEALING}
{AI_CA_VILLAGES}