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
players = read_players()
local limit = 30000
local peasants = 20000
local trees = 1000
local turn = get_turn()
local sel
if #players > 0 then
eressea.read_game(("%d.dat"):format(turn))
sel = p.select(regions(), limit)
sel = p.select(regions(), peasants, trees)
if #sel > 0 then
local best = dump_selection(sel)
print("finest region, " .. best.score .. " points: " .. tostring(best.r))

View File

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