From 20caa41d37c730e1147234ddd56c62672c27655f Mon Sep 17 00:00:00 2001 From: DualFroz Date: Sun, 23 Aug 2026 09:00:00 +0200 Subject: [PATCH] chore: add gitignore and build configuration --- .gitignore | 13 +++++++++++++ warren.lua | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .gitignore create mode 100644 warren.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c8f36a --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# compiled lua +*.luac + +# coverage +luacov.* + +# run / save output +*.out + +# os / logs / env +.DS_Store +*.log +.env diff --git a/warren.lua b/warren.lua new file mode 100644 index 0000000..c7f7ef8 --- /dev/null +++ b/warren.lua @@ -0,0 +1,38 @@ +-- Headless entry point. Examples: +-- lua warren.lua --seed 42 --auto 50 +-- lua warren.lua --seed 7 --auto 30 --save run.sav +-- lua warren.lua --load run.sav + +local scriptDir = arg[0]:match("^(.*)[/\\]") or "." +package.path = scriptDir .. "/src/?.lua;" .. scriptDir .. "/../src/?.lua;" .. package.path + +local Game = require("game") + +local function parseArgs(argv) + local opts = { seed = os.time() & 0xFFFF, auto = 0 } + local i = 1 + while i <= #argv do + local flag = argv[i] + if flag == "--seed" then opts.seed = math.tointeger(tonumber(argv[i + 1])); i = i + 2 + elseif flag == "--auto" then opts.auto = math.tointeger(tonumber(argv[i + 1])); i = i + 2 + elseif flag == "--save" then opts.save = argv[i + 1]; i = i + 2 + elseif flag == "--load" then opts.load = argv[i + 1]; i = i + 2 + else i = i + 1 end + end + return opts +end + +local opts = parseArgs(arg) +local game = opts.load and Game.load(opts.load) or Game.new(opts.seed) + +for _ = 1, opts.auto do + if not game.player:isAlive() then break end + game:autoStep() +end + +io.write(game:render(), "\n") + +if opts.save then + game:save(opts.save) + io.write("saved to " .. opts.save .. "\n") +end