Micro AIs: make recruit_rushers work with new external CA method
The previous code did not allow to get the ai table to the execution function.
This commit is contained in:
parent
48917eeb2b
commit
b826e5ead5
3 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
return {
|
||||
-- init parameters:
|
||||
-- ai: a reference to the ai engine so recruit has access to ai functions
|
||||
-- It is also possible to pass an ai table directly to the execution function, which will then override the value passed here
|
||||
-- ai_cas: an object reference to store the CAs and associated data
|
||||
-- the CA will use the function names ai_cas:recruit_rushers_eval/exec, so should be referenced by the object name used by the calling AI
|
||||
-- ai_cas also has the functions find_best_recruit, find_best_recruit_hex and analyze_enemy_unit added to it
|
||||
|
@ -422,7 +423,9 @@ return {
|
|||
return score
|
||||
end
|
||||
|
||||
function ai_cas:recruit_rushers_exec()
|
||||
function ai_cas:recruit_rushers_exec(ai_local)
|
||||
if ai_local then ai = ai_local end
|
||||
|
||||
if AH.print_exec() then print(' ' .. os.clock() .. ' Executing recruit_rushers CA') end
|
||||
if AH.show_messages() then W.message { speaker = 'narrator', message = 'Recruiting' } end
|
||||
|
||||
|
|
|
@ -417,8 +417,6 @@ function wesnoth.wml_actions.micro_ai(cfg)
|
|||
if (cfg.ai_type == 'recruit_rushers') then
|
||||
optional_keys = { "randomness" }
|
||||
CA_parms = { { ca_id = "mai_rusher_recruit", location = 'ai/micro_ais/cas/ca_recruit_rushers.lua', score = cfg.ca_score or 180000 } }
|
||||
wesnoth.message('The recruit_rushers Micro AI is currently diabled while we reorganize some things. Please check back later.')
|
||||
return
|
||||
|
||||
else
|
||||
optional_keys = { "skip_low_gold_recruiting", "type", "prob" }
|
||||
|
|
|
@ -7,7 +7,7 @@ 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
|
||||
|
||||
-- TODO: this does not currently work, as 'ai' is not defined in this context
|
||||
-- 'ai' is nil here (not defined), so we pass it directly in the execution function below
|
||||
wesnoth.require("ai/lua/generic_recruit_engine.lua").init(ai, internal_recruit_cas, internal_params)
|
||||
|
||||
function ca_recruit_rushers:evaluation(ai, cfg)
|
||||
|
@ -16,8 +16,7 @@ function ca_recruit_rushers:evaluation(ai, cfg)
|
|||
end
|
||||
|
||||
function ca_recruit_rushers:execution(ai)
|
||||
print('recruiting')
|
||||
return internal_recruit_cas:recruit_rushers_exec()
|
||||
return internal_recruit_cas:recruit_rushers_exec(ai)
|
||||
end
|
||||
|
||||
return ca_recruit_rushers
|
||||
|
|
Loading…
Add table
Reference in a new issue