Experimental AI: do not use village hunt CA
The algorithm used in this CA is too simple to work reliably in a general setting, it tends to send whole groups of units toward small numbers of villages, or even individual ones. In its current version, it should not be used at all, not even in the Experimental AI. The recommended way to emphasize village hunting is to set the village_value aspect to a larger-than-default value and let the move-to-targets CA take care of it. An updated version of this CA's code is, however, left in place for potential future work as an external CA in Wesnoth 1.15.
This commit is contained in:
parent
8fc6cabf7d
commit
450e3d1a48
2 changed files with 0 additions and 61 deletions
|
@ -529,59 +529,6 @@ return {
|
|||
self.data.retreat_loc = nil
|
||||
end
|
||||
|
||||
------- Village Hunt CA --------------
|
||||
-- Give extra priority to seeking villages if we have less than our share
|
||||
-- our share is defined as being slightly more than the total/the number of sides
|
||||
|
||||
function generic_rush:village_hunt_eval()
|
||||
local villages = wesnoth.get_villages()
|
||||
|
||||
if not villages[1] then
|
||||
return 0
|
||||
end
|
||||
|
||||
local my_villages = wesnoth.get_villages { owner_side = wesnoth.current.side }
|
||||
|
||||
if #my_villages > #villages / #wesnoth.sides then
|
||||
return 0
|
||||
end
|
||||
|
||||
local allied_villages = wesnoth.get_villages { {"filter_owner", { {"ally_of", { side = wesnoth.current.side }} }} }
|
||||
if #allied_villages == #villages then
|
||||
return 0
|
||||
end
|
||||
|
||||
local units = AH.get_units_with_moves({ side = wesnoth.current.side, canrecruit = 'no' }, true)
|
||||
|
||||
if not units[1] then
|
||||
return 0
|
||||
end
|
||||
|
||||
return 30000
|
||||
end
|
||||
|
||||
function generic_rush:village_hunt_exec()
|
||||
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
|
||||
for i,v in ipairs(villages) do
|
||||
if not wesnoth.match_location(v[1], v[2], { {"filter_owner", { {"ally_of", { side = wesnoth.current.side }} }} }) then
|
||||
local path, cost = wesnoth.find_path(unit, v[1], v[2], { ignore_units = true, max_cost = best_cost })
|
||||
if cost < best_cost then
|
||||
target = v
|
||||
best_cost = cost
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if target then
|
||||
local x, y = wesnoth.find_vacant_tile(target[1], target[2], unit)
|
||||
local dest = AH.next_hop(unit, x, y)
|
||||
if dest then AH.checked_move(ai, unit, dest[1], dest[2]) end
|
||||
end
|
||||
end
|
||||
|
||||
return generic_rush
|
||||
end
|
||||
}
|
||||
|
|
|
@ -608,14 +608,6 @@
|
|||
evaluation="return (...):place_healers_eval()"
|
||||
execution="(...):place_healers_exec()"
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=lua
|
||||
id=village_hunt
|
||||
name=village_hunt
|
||||
max_score=30000
|
||||
evaluation="return (...):village_hunt_eval()"
|
||||
execution="(...):village_hunt_exec()"
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=lua
|
||||
id=move_to_enemy
|
||||
|
|
Loading…
Add table
Reference in a new issue