Experimental AI: fix guardians being used for village actions
This commit is contained in:
parent
ac2e90faca
commit
da080dd94c
3 changed files with 12 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
|||
## Version 1.14.8+dev
|
||||
### AI:
|
||||
* Fixed a rare crash in attack prediction (issue #4068)
|
||||
* Experimental AI: fixed guardians being used for village actions
|
||||
### Campaigns
|
||||
* A Tale of Two Brothers:
|
||||
* S3: modify castle illumination tip on easy mode
|
||||
|
|
|
@ -899,11 +899,16 @@ function ai_helper.get_live_units(filter)
|
|||
return wesnoth.get_units { { "not", { status = "petrified" } }, { "and", filter } }
|
||||
end
|
||||
|
||||
function ai_helper.get_units_with_moves(filter)
|
||||
function ai_helper.get_units_with_moves(filter, exclude_guardians)
|
||||
-- Optional input: @exclude_guardians: set to 'true' to exclude units with ai_special=guardian
|
||||
-- Note: the order of the filters and the [and] tags are important for speed reasons
|
||||
local exclude_status = 'petrified'
|
||||
if exclude_guardians then
|
||||
exclude_status = exclude_status .. ',guardian'
|
||||
end
|
||||
return wesnoth.get_units {
|
||||
{ "and", { formula = "moves > 0" } },
|
||||
{ "not", { status = "petrified" } },
|
||||
{ "not", { status = exclude_status } },
|
||||
{ "and", filter }
|
||||
}
|
||||
end
|
||||
|
|
|
@ -267,9 +267,7 @@ return {
|
|||
if AH.print_eval() then print_time(' - Evaluating grab_villages CA:') end
|
||||
|
||||
-- Check if there are units with moves left
|
||||
local units = wesnoth.get_units { side = wesnoth.current.side, canrecruit = 'no',
|
||||
formula = 'movement_left > 0'
|
||||
}
|
||||
local units = AH.get_units_with_moves({ side = wesnoth.current.side, canrecruit = 'no' }, true)
|
||||
if (not units[1]) then
|
||||
if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
|
||||
return 0
|
||||
|
@ -513,10 +511,7 @@ return {
|
|||
------- Retreat CA --------------
|
||||
|
||||
function generic_rush:retreat_injured_units_eval()
|
||||
local units = wesnoth.get_units {
|
||||
side = wesnoth.current.side,
|
||||
formula = 'movement_left > 0'
|
||||
}
|
||||
local units = AH.get_units_with_moves({ side = wesnoth.current.side }, true)
|
||||
local unit, loc = R.retreat_injured_units(units)
|
||||
if unit then
|
||||
self.data.retreat_unit = unit
|
||||
|
@ -563,11 +558,7 @@ return {
|
|||
return 0
|
||||
end
|
||||
|
||||
local units = wesnoth.get_units {
|
||||
side = wesnoth.current.side,
|
||||
canrecruit = false,
|
||||
formula = 'movement_left > 0'
|
||||
}
|
||||
local units = AH.get_units_with_moves({ side = wesnoth.current.side, canrecruit = 'no' }, true)
|
||||
|
||||
if not units[1] then
|
||||
return 0
|
||||
|
@ -577,11 +568,7 @@ return {
|
|||
end
|
||||
|
||||
function generic_rush:village_hunt_exec()
|
||||
local unit = wesnoth.get_units({
|
||||
side = wesnoth.current.side,
|
||||
canrecruit = false,
|
||||
formula = 'movement_left > 0'
|
||||
})[1]
|
||||
local unit = AH.get_units_with_moves({ side = wesnoth.current.side, canrecruit = 'no' }, true)[1]
|
||||
|
||||
local villages = wesnoth.get_villages()
|
||||
local target, best_cost = nil, AH.no_path
|
||||
|
|
Loading…
Add table
Reference in a new issue