Lua AIs: replace print() by std_print()

(cherry-picked from commit 3f54908b0b)
This commit is contained in:
mattsc 2018-08-27 07:30:24 -07:00
parent 98e5f0892e
commit fbbbcfc67e
4 changed files with 12 additions and 12 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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