Fred ExpAI recruiting: set initial conditions for first recruit

Without this, the AI always starts with whatever it considers the best unit without taking the level bonus into account. This mostly only matters when one sets high_level_fraction to a very large value (1 or larger) in order to force only high-level recruits. In other cases it makes no, or no significant, difference.
This commit is contained in:
mattsc 2019-10-08 13:24:13 -07:00
parent a51dee6761
commit cbf99a6f00

View file

@ -804,7 +804,15 @@ return {
if (min_recruit_level < 1) then min_recruit_level = 1 end
local unit_deficit = {}
for i=min_recruit_level+1,max_recruit_level do
unit_deficit[i] = high_level_fraction ^ (i - min_recruit_level) * #all_units - (level_count[i] or 0)
-- If no non-leader units are on the map yet, we set up the situation as if there were
-- one of each level. This is in order to get the situation for the first recruit right.
local n_units = #all_units
local n_units_this_level = level_count[i] or 0
if (n_units == 0) then
n_units = max_recruit_level - min_recruit_level
n_units_this_level = 1
end
unit_deficit[i] = high_level_fraction ^ (i - min_recruit_level) * n_units - n_units_this_level
end
for i, recruit_id in ipairs(wesnoth.sides[wesnoth.current.side].recruit) do