tarinai/scripts/colony_crisis_regression_audit.js
2026-07-18 13:06:02 +09:00

44 lines
2.2 KiB
JavaScript

"use strict";
global.window = global;
global.CONFIG = { dayLength: 120 };
global.TarinaiAchievements = { evaluateWorld() {} };
require("../js/colony_situation_system.js");
function actor({ energy = 80, hunger = 20, health = 0 } = {}) {
return { dead: false, energy, hunger, stress: 10, needs: { health, safety: 0 }, state: "idle" };
}
function world(actors, deaths = 0, previousPopulation = null) {
return {
time: 100,
tarinai: actors,
recentDeathTimes: Array.from({ length: deaths }, (_, i) => 99 - i * 0.1),
lastColonyMoodPopulation: previousPopulation == null ? actors.length : previousPopulation,
colonyMoodDefinition(id) { return { id, label: id, effects: { personality: {} } }; },
config: { dayLength: 120 },
};
}
function evaluate(w) { return global.TarinaiColonySituationSystem.evaluate(w, true).id; }
function assert(ok, message) { if (!ok) throw new Error(message); }
// Ten recent deaths alone at 100 population must no longer trigger crisis without systemic weakness.
let w = world(Array.from({ length: 100 }, () => actor()), 10);
assert(evaluate(w) !== "crisis", "recent deaths alone still trigger crisis too easily");
// Systemic weakness alone below collapse severity must not trigger crisis.
w = world(Array.from({ length: 100 }, (_, i) => actor(i < 50 ? { energy: 24, hunger: 90, health: 70 } : {})), 0);
assert(evaluate(w) !== "crisis", "moderate systemic weakness alone still triggers crisis");
// Mortality plus systemic weakness should trigger crisis.
w = world(Array.from({ length: 100 }, (_, i) => actor(i < 50 ? { energy: 24, hunger: 90, health: 70 } : {})), 10);
assert(evaluate(w) === "crisis", "compound mortality/systemic stress does not trigger crisis");
// Extreme collapse can trigger even without recent deaths.
w = world(Array.from({ length: 100 }, (_, i) => actor(i < 70 ? { energy: 10, hunger: 98, health: 80 } : {})), 0);
assert(evaluate(w) === "crisis", "extreme colony collapse does not trigger crisis");
// Population growth still suppresses crisis.
w = world(Array.from({ length: 100 }, (_, i) => actor(i < 70 ? { energy: 10, hunger: 98, health: 80 } : {})), 20, 90);
assert(evaluate(w) !== "crisis", "crisis ignored population-growth exclusion");
console.log("[OK] stricter compound crisis classification passed");