tarinai/scripts/reproduction_regression_audit.js
2026-07-18 22:15:26 +09:00

27 lines
2.1 KiB
JavaScript

"use strict";
const fs = require("fs");
const path = require("path");
const root = path.resolve(__dirname, "..");
const read = p => fs.readFileSync(path.join(root, p), "utf8");
const creature = read("js/simulation_creature_system.js");
const frame = read("js/tarinai_update_step_frame.js");
const social = read("js/tarinai_social_move_life.js");
const achievements = read("js/achievements.js");
const needs = read("js/tarinai_needs_items.js");
const socialRuntime = read("js/tarinai_social_action_runtime.js");
const actionDefs = read("js/tarinai_action_definitions.js");
const family = read("js/world_family_social.js");
function ok(cond, msg) { if (!cond) throw new Error(msg); console.log(`[OK] ${msg}`); }
ok(/t\.reproductionTimer\s*=\s*\(Number\(t\.reproductionTimer/.test(creature), "reproduction cooldown advances in the outer per-frame creature pass");
ok(!/reproductionTimer\s*-=\s*dt/.test(frame), "full AI cadence no longer double-advances reproduction cooldown");
ok(/const candidateBudget = Math\.max\(20, scanLimit \+ 8\)/.test(social) && /if \(inspected >= candidateBudget\) break;/.test(social), "dense contact scans are bounded instead of walking the full local population");
ok(/const currentMateTarget =/.test(social) && /detailed\.push\(\{ o: currentMateTarget/.test(social), "the selected mate target is injected into bounded contact checks");
ok(/id: "population",\s*\n\s*title: "\\u4eba\\u53e3"/.test(achievements), "achievement population category is titled 人口");
ok(/socialParts\.mate \+= 28/.test(needs), "ready unpaired adults receive a mating sub-need above the start threshold");
ok(/if \(subNeed === "mate"\) \{[\s\S]*subValue >= threshold/.test(needs), "mating sub-need can start independently of aggregate loneliness");
ok(/!tarinai\.juvenile/.test(needs) && /!t\.juvenile/.test(actionDefs), "juveniles do not proactively start mating actions");
ok(/!t\.juvenile && !other\.juvenile/.test(socialRuntime), "contact mating excludes juveniles");
ok(/if \(a\.juvenile \|\| b\.juvenile\) return false;/.test(family), "birth ritual rejects juvenile participants centrally");
console.log("Reproduction regression audit passed.");