diff --git a/process/compress.py b/process/compress.py index 539f1a032..2ad62d814 100755 --- a/process/compress.py +++ b/process/compress.py @@ -38,9 +38,11 @@ for line in infile.readlines(): if not options.has_key("reports"): continue reports = options["reports"].split(",") -# reports = reports + [ "iso.cr" ] prefix = "%(turn)s-%(faction)s." % options files=[] + times="../parteien" + if os.path.isfile(times): + files = files + [ times ] if options["compression"]=="zip": output = prefix+"zip" files = [output] diff --git a/scripts/newplayer.lua b/scripts/newplayer.lua new file mode 100644 index 000000000..fa8e9f18f --- /dev/null +++ b/scripts/newplayer.lua @@ -0,0 +1,88 @@ +function seed(r, email, race, lang) + local f = faction.create(email, race, lang) + local u = unit.create(f, r) + u:set_skill("perception", 30) + u:add_item("money", 10000) + items = { + log = 50, + stone = 50, + iron = 50, + laen = 10, + mallorn = 10, + skillpotion = 5 + } + for it, num in pairs(items) do + u:add_item(it, num) + end + skills ={ + "crossbow", + "mining", + "bow", + "building", + "trade", + "forestry", + "catapult", + "herbalism", + "training", + "riding", + "armorer", + "shipcraft", + "melee", + "sailing", + "polearm", + "espionage", + "quarrying", + "roadwork", + "tactics", + "stealth", + "entertainment", + "weaponsmithing", + "cartmaking", + "taxation", + "stamina" + } + for _, sk in ipairs(skills) do + u = unit.create(f, r, 5) + u:set_skill(sk, 15) + end + return f +end + +turn = 923 +dofile("config.lua") +p = require("populate") +eressea.read_game(("%d.dat"):format(turn)) +best = { score = 0, r = nil } +limit = 30000 +sel = p.select(regions(), limit) +for _, r in ipairs(sel) do + score = p.score(r) + if score > best.score then + best.r = r + best.score = score + end + print(score, r, r.terrain) +end +-- print(best.r, best.score) +math.randomseed(os.time()) + +print(#sel, limit) + +players = { +{ email = "Reinhardt.Karnapke@Freenet.de", race = "dwarf", lang = "de" } +} + +for _, p in ipairs(players) do + local index = math.random(#sel) + local start = nil + while not start or start.units() do + start = sel[index] + end + f = seed(start, p.email, p.race or "human", p.lang or "de") + print(f, start) + init_reports() + write_report(f) +end + +eressea.write_game(("%d.dat.new"):format(turn)) + diff --git a/scripts/populate.lua b/scripts/populate.lua new file mode 100644 index 000000000..dfd07b5dd --- /dev/null +++ b/scripts/populate.lua @@ -0,0 +1,32 @@ +local this = {} + +local function score(r, res) + assert(r) + res = res or "peasant" + local x, y, rn + local peas = r:get_resource(res) + for _, rn in pairs(r.adj) do + if rn then + peas = peas + rn:get_resource(res) + end + end + return peas +end + +local function select(regions, limit) + local sel = {} + for r in regions do + if r.terrain~="ocean" and r.units()==nil then + s = score(r) + if s >= limit then + table.insert(sel, r) + end + end + end + return sel +end + +return { + score = score, + select = select +}