ExpAI: do not use generic_recruit_engine

This removes the need for the Generic Recruit Engine and makes Recruit Rushers a "clean" candidate action.  In the process, it fixes a bug of data leakage between the Experimental AIs of different sides.
This commit is contained in:
mattsc 2022-06-20 18:28:09 -07:00
parent e64ddeb040
commit 6aaface658
4 changed files with 1064 additions and 54 deletions

View file

@ -59,7 +59,7 @@ end
local ca_castle_switch = {}
function ca_castle_switch:evaluation(cfg, data, filter_own, recruiting_leader)
-- @recruiting_leader is passed from the recuit_rushers CA for the leader_takes_village()
-- @recruiting_leader is passed from the recuit_rushers CA for the leader_takes_villages evaluation
-- evaluation. If it is set, we do the castle switch evaluation only for that leader
local start_time, ca_name = wesnoth.ms_since_init() / 1000., 'castle_switch'

File diff suppressed because it is too large Load diff

View file

@ -1,22 +0,0 @@
local internal_recruit_cas = {}
local internal_params = {}
-- The following external engine creates the CA functions recruit_rushers_eval and recruit_rushers_exec
-- It also exposes find_best_recruit and find_best_recruit_hex for use by other recruit engines
wesnoth.require("ai/lua/generic_recruit_engine.lua").init(internal_recruit_cas, internal_params)
local ca_recruit_rushers = {}
function ca_recruit_rushers:evaluation(cfg)
internal_params.high_level_fraction = cfg.high_level_fraction
internal_params.randomness = cfg.randomness
internal_params.score_function = function() return cfg.ca_score end
return internal_recruit_cas:recruit_rushers_eval()
end
function ca_recruit_rushers:execution()
return internal_recruit_cas:recruit_rushers_exec()
end
return ca_recruit_rushers

View file

@ -21,7 +21,7 @@ function wesnoth.micro_ais.recruit_rushers(cfg)
local optional_keys = { "high_level_fraction", "randomness" }
local CA_parms = {
ai_id = 'mai_rusher_recruit',
{ ca_id = "move", location = 'ca_recruit_rushers.lua', score = cfg.ca_score or 180000 }
{ ca_id = "move", location = '../../lua/ca_recruit_rushers.lua', score = cfg.ca_score or 180000 }
}
handle_default_recruitment(cfg)