mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 12:19:09 +00:00
Protect Unit MAI: slight adjustment of evaluation scores
and add comment about them being hardcoded.
This commit is contained in:
parent
338d2f1f22
commit
7242ed59bf
@ -155,7 +155,7 @@ return {
|
|||||||
end
|
end
|
||||||
|
|
||||||
function engine:mai_protect_unit_move_eval(cfg)
|
function engine:mai_protect_unit_move_eval(cfg)
|
||||||
-- Always 94000 if one of the units can still move
|
-- Always 94999 if one of the units can still move
|
||||||
local units = {}
|
local units = {}
|
||||||
for i,id in ipairs(cfg.id) do
|
for i,id in ipairs(cfg.id) do
|
||||||
table.insert(units, wesnoth.get_units{ id = id, formula = '$this_unit.moves > 0' }[1])
|
table.insert(units, wesnoth.get_units{ id = id, formula = '$this_unit.moves > 0' }[1])
|
||||||
@ -174,12 +174,9 @@ return {
|
|||||||
-- W.message { speaker = "narrator", image = "wesnoth-icon.png", caption = "Parameters set to:", message = "Enemy unit weight = " .. self.data.enemy_weight .. "\nMy unit weight = " .. self.data.my_unit_weight .. "\nGoal distance weight = " .. self.data.distance_weight .. "\nTerrain defense weight = " .. self.data.terrain_weight .. "\nBearing: " .. tmp }
|
-- W.message { speaker = "narrator", image = "wesnoth-icon.png", caption = "Parameters set to:", message = "Enemy unit weight = " .. self.data.enemy_weight .. "\nMy unit weight = " .. self.data.my_unit_weight .. "\nGoal distance weight = " .. self.data.distance_weight .. "\nTerrain defense weight = " .. self.data.terrain_weight .. "\nBearing: " .. tmp }
|
||||||
--end
|
--end
|
||||||
|
|
||||||
if units[1] then
|
if units[1] then return 94999 end
|
||||||
return 94000
|
|
||||||
else
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function engine:mai_protect_unit_move_exec(cfg)
|
function engine:mai_protect_unit_move_exec(cfg)
|
||||||
-- Find and execute best (safest) move toward goal
|
-- Find and execute best (safest) move toward goal
|
||||||
@ -414,9 +411,8 @@ return {
|
|||||||
if (max_rating > -9e99) then
|
if (max_rating > -9e99) then
|
||||||
self.data.best_attack = best_attack
|
self.data.best_attack = best_attack
|
||||||
return 95000
|
return 95000
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function engine:mai_protect_unit_attack_exec()
|
function engine:mai_protect_unit_attack_exec()
|
||||||
|
@ -192,10 +192,11 @@ function wesnoth.wml_actions.micro_ai(cfg)
|
|||||||
--------- Protect Unit Micro AI - side-wide AI ------------------------------------
|
--------- Protect Unit Micro AI - side-wide AI ------------------------------------
|
||||||
elseif (cfg.ai_type == 'protect_unit') then
|
elseif (cfg.ai_type == 'protect_unit') then
|
||||||
required_keys = { "id", "goal_x", "goal_y" }
|
required_keys = { "id", "goal_x", "goal_y" }
|
||||||
|
-- Scores for this AI need to be hard-coded, it does not work otherwise
|
||||||
CA_parms = {
|
CA_parms = {
|
||||||
{ ca_id = 'mai_protect_unit_finish', score = 300000 },
|
{ ca_id = 'mai_protect_unit_finish', score = 300000 },
|
||||||
{ ca_id = 'mai_protect_unit_attack', score = 95000 },
|
{ ca_id = 'mai_protect_unit_attack', score = 95000 },
|
||||||
{ ca_id = 'mai_protect_unit_move', score = 94000 }
|
{ ca_id = 'mai_protect_unit_move', score = 94999 }
|
||||||
}
|
}
|
||||||
|
|
||||||
-- [unit] tags need to be dealt with separately
|
-- [unit] tags need to be dealt with separately
|
||||||
|
Loading…
x
Reference in New Issue
Block a user