wesnoth/data/ai/lua/ca_recruit_rushers.lua
mattsc 4999b20bd1 Experimental AI: adjustments to candidate action scores
The relative ranking of the CA scores is not changed, except for one case when two CAs had the same score.

Reasons:
- All scores should be lower than the scores of the default Goto CA (200,000) and the default scores of most Micro AIs (300,000).
- Break tie, resulting in uncertain order of execution, of place_healers and retreat_injured CA. Healers should be placed first, to allow retreating injured units to adjacent hexes.
- Set default for generic_recruit_engine to slightly above default AI recruiting score. That way it takes effect even if the default CA is not removed.
- Increase move_to_any_enemy CA score from 1 to 1,000. It is still the lowest score that way, but allows for setting up custom CAs with even lower scores (even if it is just for end-of-turn statistics or the like).

(cherry-picked from commit 35ba82050954c2cee86321e05d6706993c08e143)
2018-10-07 03:24:51 +00:00

45 lines
1.5 KiB
Lua

-- Make the generic_recruit_engine functions work as external CAs
local ca_castle_switch
for ai_tag in wml.child_range(wesnoth.sides[wesnoth.current.side].__cfg, 'ai') do
for stage in wml.child_range(ai_tag, 'stage') do
for ca in wml.child_range(stage, 'candidate_action') do
if ca.location and string.find(ca.location, 'ca_castle_switch') then
ca_castle_switch = wesnoth.require("ai/lua/ca_castle_switch.lua")
break
end
end
end
end
local dummy_engine = { data = {} }
local params = { score_function = (function() return 196000 end) }
if ca_castle_switch then
params.min_turn_1_recruit = (function() return ca_castle_switch:evaluation({}, dummy_engine.data) > 0 end)
params.leader_takes_village = (function()
if ca_castle_switch:evaluation({}, dummy_engine.data) > 0 then
local take_village = #(wesnoth.get_villages {
x = dummy_engine.data.leader_target[1],
y = dummy_engine.data.leader_target[2]
}) > 0
return take_village
end
return not ai.aspects.passive_leader
end
)
end
wesnoth.require("ai/lua/generic_recruit_engine.lua").init(dummy_engine, params)
local ca_recruit_rushers = {}
function ca_recruit_rushers:evaluation(cfg, data)
return dummy_engine:recruit_rushers_eval()
end
function ca_recruit_rushers:execution(cfg, data)
return dummy_engine:recruit_rushers_exec()
end
return ca_recruit_rushers