Skip to content

Commit

Permalink
Lua AIs: replace print() by std_print()
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsc committed Aug 27, 2018
1 parent 83c4ef2 commit 3f54908
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions data/ai/lua/ai_helper.lua
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions data/ai/lua/battle_calcs.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions data/ai/lua/generic_recruit_engine.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/ai/lua/generic_rush_engine.lua
Expand Up @@ -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
Expand Down

0 comments on commit 3f54908

Please sign in to comment.