require trees for new player regions

This commit is contained in:
Enno Rehling 2015-07-28 10:51:14 +02:00
parent d9e7ff69eb
commit 51fc6680dd
2 changed files with 5 additions and 5 deletions

View File

@ -42,12 +42,13 @@ local function dump_selection(sel)
end end
players = read_players() players = read_players()
local limit = 30000 local peasants = 20000
local trees = 1000
local turn = get_turn() local turn = get_turn()
local sel local sel
if #players > 0 then if #players > 0 then
eressea.read_game(("%d.dat"):format(turn)) eressea.read_game(("%d.dat"):format(turn))
sel = p.select(regions(), limit) sel = p.select(regions(), peasants, trees)
if #sel > 0 then if #sel > 0 then
local best = dump_selection(sel) local best = dump_selection(sel)
print("finest region, " .. best.score .. " points: " .. tostring(best.r)) print("finest region, " .. best.score .. " points: " .. tostring(best.r))

View File

@ -13,12 +13,11 @@ local function score(r, res)
return peas return peas
end end
local function select(regions, limit) local function select(regions, peasants, trees)
local sel = {} local sel = {}
for r in regions do for r in regions do
if not r.plane and r.terrain~="ocean" and not r.units() then if not r.plane and r.terrain~="ocean" and not r.units() then
s = score(r) if score(r, "peasant") >= peasants and score(r, "tree") >= trees then
if s >= limit then
table.insert(sel, r) table.insert(sel, r)
end end
end end