Phase 4: close loot/refund leaks, landing-site garrisons, speed-scaled shipping, update/offsite tooling, broad e2e
Built: - Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds). - End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x). - Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in. - e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English. Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented). NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
9104480463
commit
3c23c51902
92 changed files with 4887 additions and 300 deletions
|
|
@ -93,7 +93,7 @@ class Bot {
|
|||
this.firstAllianceTry = 0;
|
||||
this.incCache = null;
|
||||
this.takeoverTargets = new Map();
|
||||
this.armyOverride = 0; this.egForce = null;
|
||||
this.armyOverride = 0; this.egForce = null; this.egDefTarget = 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ session schedule (human cadence)
|
||||
|
|
@ -164,7 +164,7 @@ class Bot {
|
|||
if (!sec && this.egForce) for (const type of Object.keys(this.egForce)) if (view.level(t, type) < this.egForce[type]) out.push({ key: type, type });
|
||||
// a store that keeps hitting its cap is the first thing a player fixes
|
||||
const cur = R.resourcesAt(t, now);
|
||||
if (RES.every((r) => cur.amounts[r] >= 0.8 * cur.caps.fiber) && !busy.has('rack_hall') && view.level(t, 'rack_hall') < Math.min(20, Math.max(2, F + 1))) out.push({ key: 'rack_hall', type: 'rack_hall' });
|
||||
if (RES.every((r) => cur.amounts[r] >= 0.8 * R.storageCap(t)) && !busy.has('rack_hall') && view.level(t, 'rack_hall') < Math.min(20, Math.max(2, F + 1))) out.push({ key: 'rack_hall', type: 'rack_hall' });
|
||||
const order = sec ? ['core_router', 'rack_hall', 'battery_bank'] : this.arch.order;
|
||||
for (const type of order) {
|
||||
const tgt = sec ? Math.min(this.target(type, F), 6) : this.target(type, F);
|
||||
|
|
@ -186,7 +186,7 @@ class Bot {
|
|||
// level the other fields are at; substations only when power is short (or units are wanted).
|
||||
pickFieldMarginal(t, fields, now) {
|
||||
const rates = R.ratesPerHour(t);
|
||||
const unitsWanted = this.arch.armyDays > 0 || this.arch.defDays > 0.5 || !!this.armyOverride;
|
||||
const unitsWanted = this.arch.armyDays > 0 || this.arch.defDays > 0.5 || !!this.armyOverride || !!this.egDefTarget;
|
||||
const lowest = (type) => fields.filter((f) => f.type === type && f.level < 20).sort((a, b) => a.level - b.level || (a.key < b.key ? -1 : 1))[0];
|
||||
if (rates.powerNet < 4 + 0.04 * rates.powerOut && (unitsWanted || rates.powerNet < 2)) {
|
||||
const s = lowest('substation');
|
||||
|
|
@ -209,7 +209,7 @@ class Bot {
|
|||
const w = this.arch.weights;
|
||||
const rates = R.ratesPerHour(t);
|
||||
const power = rates.powerNet;
|
||||
const unitsWanted = this.arch.armyDays > 0 || this.arch.defDays > 0.5 || !!this.armyOverride;
|
||||
const unitsWanted = this.arch.armyDays > 0 || this.arch.defDays > 0.5 || !!this.armyOverride || !!this.egDefTarget;
|
||||
const lag = fields.filter((f) => f.level === F);
|
||||
if (!lag.length) return null;
|
||||
// power first when it is short and units are on the way
|
||||
|
|
@ -248,7 +248,7 @@ class Bot {
|
|||
const pending = view.pendingBuilds(t.id);
|
||||
if (pending.length >= R.queueSlots(t)) break;
|
||||
const cur = R.resourcesAt(t, now);
|
||||
const cap = cur.caps.fiber;
|
||||
const cap = R.storageCap(t);
|
||||
const overflow = RES.some((r) => cur.amounts[r] >= 0.9 * cap);
|
||||
let acted = false;
|
||||
const list = this.wishes(t, now, new Set(pending.map((p) => p.key)));
|
||||
|
|
@ -615,7 +615,7 @@ class Bot {
|
|||
if (lvl < 1) continue;
|
||||
let t = t0;
|
||||
const cur = R.resourcesAt(t, now);
|
||||
const cap = cur.caps.fiber;
|
||||
const cap = R.storageCap(t);
|
||||
const fill = {}; for (const r of RES) fill[r] = cur.amounts[r] / cap;
|
||||
const sorted = RES.slice().sort((a, b) => fill[b] - fill[a]);
|
||||
const surplus = sorted[0], deficit = sorted[2];
|
||||
|
|
@ -638,9 +638,9 @@ class Bot {
|
|||
// post one of our own (one open offer per POP at a time)
|
||||
const open = db.get("SELECT COUNT(*) AS n FROM trade_offers WHERE town_id = ? AND status = 'open'", t.id).n;
|
||||
if (open >= 1) continue;
|
||||
const give = Math.min(D.TRANSPORT.capacityPerLink, Math.floor((cur.amounts[surplus] - 0.4 * cap) * 0.6));
|
||||
const give = Math.min(R.transportCapacity(this.sim.world.speed), Math.floor((cur.amounts[surplus] - 0.4 * cap) * 0.6));
|
||||
if (give < 100) continue;
|
||||
const want = Math.min(D.TRANSPORT.capacityPerLink, Math.max(50, Math.floor(give * (0.9 + this.rng() * 0.2))));
|
||||
const want = Math.min(R.transportCapacity(this.sim.world.speed), Math.max(50, Math.floor(give * (0.9 + this.rng() * 0.2))));
|
||||
const r = this.call('tradeOffer', { townId: t.id, giveRes: surplus, giveAmount: give, wantRes: deficit, wantAmount: want, maxDistance: Math.max(10, Math.min(reach, 40)) });
|
||||
if (r.ok) this.log.offers += 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue