import { describe, expect, it } from 'vitest' import { stateFingerprint, longRun } from './fingerprint.helper' import { World } from '../src/renderer/game/engine/runtime/World' /** * 金钟罩:固定种子长跑 560 月的状态指纹。 * 任何改动(重构日程/调平衡/加系统)若改变了确定性序列或结果,此测试立刻报红。 * 更新规则:仅当**有意**变更序列逻辑时,三枚 seed 指纹同版更新并注明原因。 */ // 0.1.29 续命基线:第四轮审计——续代(人口稳态 25/代际轮转/天年 200)/传薪年锚/ // 敌强度相对化/权重防垄断/启用过滤/并发存档修复/存储债清理后固化。 const GOLDEN: Record> = { 'bell-seed-1': { 560: '184a2203', 1200: 'af169007', 2160: 'c8fe205a' }, 'bell-seed-2': { 560: '8d0b60ef', 1200: '08e60d00', 2160: 'd13f1b64' }, 'bell-seed-3': { 560: 'a80ce621', 1200: '1baea655', 2160: '37794cb0' } } /** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件; * 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */ const GOLDEN_RESOLVED: Record> = { 'bell-seed-1': { 560: 'bad85950', 1200: 'd9344194', 2160: '8ed61f10' }, 'bell-seed-2': { 560: '3e9698e7', 1200: '68940d48', 2160: '1d56b086' }, 'bell-seed-3': { 560: 'f8d10c28', 1200: '54f9dd80', 2160: '9c931d77' } } const TIERS = [ [560, '47 年(4 个十年)'], [1200, '100 年'], [2160, '180 年'] ] as const describe('金钟罩 · 长跑确定性指纹(三档:47/100/180 年)', () => { for (const [seed, tiers] of Object.entries(GOLDEN)) { for (const [months, label] of TIERS) { it(`${seed} ${label}指纹 === ${tiers[months]}`, () => { const w = run(seed, months) expect(stateFingerprint(w.state)).toBe(tiers[months]) }) } } it('同 seed 两次长跑指纹一致(无状态污染)', () => { const a = stateFingerprint(longRun('bell-seed-1').state) const b = stateFingerprint(longRun('bell-seed-1').state) expect(a).toBe(b) }) }) function run(seed: string, months: number): ReturnType { const w = World.create({ seed, surname: '钟', familyName: '钟家', motto: 'm', difficulty: 'normal' }) for (let i = 0; i < months; i++) { if (w.state.gameOver) break w.advanceMonth() } return w }