From 3f54908b0ba69173442107105889caeb891b922d Mon Sep 17 00:00:00 2001 From: mattsc Date: Mon, 27 Aug 2018 07:30:24 -0700 Subject: [PATCH] Lua AIs: replace print() by std_print() --- data/ai/lua/ai_helper.lua | 4 ++-- data/ai/lua/battle_calcs.lua | 12 ++++++------ data/ai/lua/generic_recruit_engine.lua | 6 +++--- data/ai/lua/generic_rush_engine.lua | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data/ai/lua/ai_helper.lua b/data/ai/lua/ai_helper.lua index 624da59cf2b0..dd632cce3744 100644 --- a/data/ai/lua/ai_helper.lua +++ b/data/ai/lua/ai_helper.lua @@ -125,7 +125,7 @@ function ai_helper.print_ts(...) local arg = { ... } arg[#arg+1] = string.format('[ t = %.3f ]', ts) - print(table.unpack(arg)) + std_print(table.unpack(arg)) return ts end @@ -143,7 +143,7 @@ function ai_helper.print_ts_delta(start_time, ...) local arg = { ... } arg[#arg+1] = string.format('[ t = %.3f, dt = %.3f ]', ts, delta) - print(table.unpack(arg)) + std_print(table.unpack(arg)) return ts, delta end diff --git a/data/ai/lua/battle_calcs.lua b/data/ai/lua/battle_calcs.lua index c0dc636409de..612f6d01977d 100644 --- a/data/ai/lua/battle_calcs.lua +++ b/data/ai/lua/battle_calcs.lua @@ -532,10 +532,10 @@ function battle_calcs.print_coefficients() dummy, coeffs = battle_calcs.battle_outcome_coefficients(cfg) end - print() - print('Attacker: ' .. cfg.att.strikes .. ' strikes, can survive ' .. cfg.att.max_hits .. ' hits') - print('Defender: ' .. cfg.def.strikes .. ' strikes, can survive ' .. cfg.def.max_hits .. ' hits') - print('Chance of hits on defender: ') + std_print() + std_print('Attacker: ' .. cfg.att.strikes .. ' strikes, can survive ' .. cfg.att.max_hits .. ' hits') + std_print('Defender: ' .. cfg.def.strikes .. ' strikes, can survive ' .. cfg.def.max_hits .. ' hits') + std_print('Chance of hits on defender: ') -- The first indices of coeffs are the possible number of hits the attacker can land on the defender for hits = 0,#coeffs do @@ -570,8 +570,8 @@ function battle_calcs.print_coefficients() local skip_str = '' if combs.skip then skip_str = ' (skip)' end - print(hits .. skip_str .. ': ' .. str) - print(' = ' .. hit_prob) + std_print(hits .. skip_str .. ': ' .. str) + std_print(' = ' .. hit_prob) end end end diff --git a/data/ai/lua/generic_recruit_engine.lua b/data/ai/lua/generic_recruit_engine.lua index 2e15ad7232d0..209bef1253bd 100644 --- a/data/ai/lua/generic_recruit_engine.lua +++ b/data/ai/lua/generic_recruit_engine.lua @@ -650,9 +650,9 @@ return { if AH.print_eval() then if village[1] then - print("Recruit at: " .. best_hex[1] .. "," .. best_hex[2] .. " -> " .. village[1] .. "," .. village[2]) + std_print("Recruit at: " .. best_hex[1] .. "," .. best_hex[2] .. " -> " .. village[1] .. "," .. village[2]) else - print("Recruit at: " .. best_hex[1] .. "," .. best_hex[2]) + std_print("Recruit at: " .. best_hex[1] .. "," .. best_hex[2]) end end return best_hex, village @@ -815,7 +815,7 @@ return { local score = offense_score*offense_weight + defense_score*defense_weight + move_score*move_weight + bonus if AH.print_eval() then - print(recruit_id .. " score: " .. offense_score*offense_weight .. " + " .. defense_score*defense_weight .. " + " .. move_score*move_weight .. " + " .. bonus .. " = " .. score) + std_print(recruit_id .. " score: " .. offense_score*offense_weight .. " + " .. defense_score*defense_weight .. " + " .. move_score*move_weight .. " + " .. bonus .. " = " .. score) end if score > best_score and wesnoth.unit_types[recruit_id].cost <= gold_limit then best_score = score diff --git a/data/ai/lua/generic_rush_engine.lua b/data/ai/lua/generic_rush_engine.lua index d5117d4e0e21..bdc2322198c8 100644 --- a/data/ai/lua/generic_rush_engine.lua +++ b/data/ai/lua/generic_rush_engine.lua @@ -40,7 +40,7 @@ return { for i,u in ipairs(units) do total_hp = total_hp + u.hitpoints end local leader = wesnoth.get_units { side = s.side, canrecruit = 'yes' }[1] if leader then - print(' Player ' .. s.side .. ' (' .. leader.type .. '): ' .. #units .. ' Units with total HP: ' .. total_hp) + std_print(' Player ' .. s.side .. ' (' .. leader.type .. '): ' .. #units .. ' Units with total HP: ' .. total_hp) end end end