Skip to content

Commit

Permalink
Experimental AI: adjustments to candidate action scores
Browse files Browse the repository at this point in the history
The relative ranking of the CA scores is not changed, except for one case when two CAs had the same score.

Reasons:
- All scores should be lower than the scores of the default Goto CA (200,000) and the default scores of most Micro AIs (300,000).
- Break tie, resulting in uncertain order of execution, of place_healers and retreat_injured CA. Healers should be placed first, to allow retreating injured units to adjacent hexes.
- Set default for generic_recruit_engine to slightly above default AI recruiting score. That way it takes effect even if the default CA is not removed.
- Increase move_to_any_enemy CA score from 1 to 1,000. It is still the lowest score that way, but allows for setting up custom CAs with even lower scores (even if it is just for end-of-turn statistics or the like).
  • Loading branch information
mattsc committed Sep 3, 2018
1 parent b92d8e8 commit 35ba820
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/ai/lua/ca_castle_switch.lua
Expand Up @@ -161,7 +161,7 @@ function ca_castle_switch:evaluation(cfg, data)
data.leader_target = next_hop

-- if we're on a keep, wait until there are no movable units on the castle before moving off
CS_leader_score = 290000
CS_leader_score = 195000
if wesnoth.get_terrain_info(wesnoth.get_terrain(leader.x, leader.y)).keep then
local castle = wesnoth.get_locations {
x = "1-"..width, y = "1-"..height,
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/ca_grab_villages.lua
Expand Up @@ -31,7 +31,7 @@ function ca_grab_villages:evaluation(cfg, data)
end

-- First check if attacks are possible for any unit
local return_value = 200000
local return_value = 191000
-- If one with > 50% chance of kill is possible, set return_value to lower than combat CA
local attacks = ai.get_attacks()
for i,a in ipairs(attacks) do
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/ca_move_to_any_enemy.lua
Expand Up @@ -51,7 +51,7 @@ function ca_move_to_any_enemy:evaluation(cfg, data)
MTAE_unit = unit

if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
return 1
return 1000
end

function ca_move_to_any_enemy:execution(cfg, data)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/ca_place_healers.lua
Expand Up @@ -11,7 +11,7 @@ function ca_place_healers:evaluation(cfg, data)

if HS:evaluation(cfg, data) > 0 then
if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
return 95000
return 96000
end
if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
return 0
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/ca_recruit_rushers.lua
Expand Up @@ -14,7 +14,7 @@ end

local dummy_engine = { data = {} }

local params = { score_function = (function() return 300000 end) }
local params = { score_function = (function() return 196000 end) }
if ca_castle_switch then
params.min_turn_1_recruit = (function() return ca_castle_switch:evaluation({}, dummy_engine.data) > 0 end)
params.leader_takes_village = (function()
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/ca_retreat_injured.lua
Expand Up @@ -30,7 +30,7 @@ function ca_retreat_injured:evaluation(cfg, data)
end
end
if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
return 205000
return 192000
end
if AH.print_eval() then AH.done_eval_messages(start_time, ca_name) end
return 0
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/generic_recruit_engine.lua
Expand Up @@ -371,7 +371,7 @@ return {
end
data.recruit.cheapest_unit_cost = cheapest_unit_cost

local score = 180000 -- default score if one not provided. Same as RCA AI
local score = 180010 -- default score if one not provided, just above RCA AI recruiting
if params.score_function then
score = params.score_function()
end
Expand Down

0 comments on commit 35ba820

Please sign in to comment.