Merge AI-demo and mainline experimental recruit logic

Slight speed improvement when close to unowned vilages. Correct score
for time of day damage estimates for encountering the enemy near end of
game.
This commit is contained in:
Alarantalara 2013-06-14 18:03:39 -04:00
parent 6e8f764162
commit 62c2bbcb20

View file

@ -287,7 +287,7 @@ return {
function sum_gold_for_sides(side_filter)
-- sum positive amounts of gold for a set of sides
-- positive only because it is used to estimate the number of enemy units that could appear
-- and negative numbers should't subtract from the number of units on the map
-- and negative numbers shouldn't subtract from the number of units on the map
local gold = 0
local sides = wesnoth.get_sides(side_filter)
for i,s in ipairs(sides) do
@ -570,11 +570,6 @@ return {
-- Find the best recruit hex
-- First choice: a hex that can reach an unowned village
-- Second choice: a hex close to the enemy
local enemy_leaders = AH.get_live_units { canrecruit = 'yes',
{ "filter_side", { { "enemy_of", {side = wesnoth.current.side} } } }
}
local closest_enemy_distance, closest_enemy_location = AH.get_closest_enemy()
get_current_castle(leader, data)
local best_hex, village = get_village_target(leader, data)
@ -583,7 +578,14 @@ return {
table.insert(data.castle.assigned_villages_y, village[2])
else
-- no available village, look for hex closest to enemy leader
-- and also the closest enemy
local max_rating = -1
local enemy_leaders = AH.get_live_units { canrecruit = 'yes',
{ "filter_side", { { "enemy_of", {side = wesnoth.current.side} } } }
}
local closest_enemy_distance, closest_enemy_location = AH.get_closest_enemy()
for i,c in ipairs(data.castle.locs) do
local rating = 0
local unit = wesnoth.get_unit(c[1], c[2])
@ -677,7 +679,7 @@ return {
end
-- divide the lawful bonus by eta before running it through the function because the function converts from 0 centered to 1 centered
local lawful_bonus = 1
local lawful_bonus = 0
local eta_turn = wesnoth.current.turn + eta
if eta_turn <= wesnoth.game_config.last_turn then
lawful_bonus = wesnoth.get_time_of_day(wesnoth.current.turn + eta).lawful_bonus / eta^2