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.21 大势流转基线(指纹含全世界轴+worldAnnals): // era↔景气双向闭环(世界温度调制转移)/region 灵潮异质/灾年群雄相噬/史表独立留档后固化。 const GOLDEN: Record> = { 'bell-seed-1': { 560: '879a909d', 1200: 'fa07c9e7', 2160: '5a64b3e9' }, 'bell-seed-2': { 560: '33d511bc', 1200: '71930809', 2160: '4e67314c' }, 'bell-seed-3': { 560: 'e6936427', 1200: '56961a5e', 2160: 'bb972ccd' } } /** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件; * 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */ const GOLDEN_RESOLVED: Record> = { 'bell-seed-1': { 560: 'cbc13720', 1200: '0b4c6d57', 2160: 'c9de8ab5' }, 'bell-seed-2': { 560: 'e0706d1e', 1200: 'd3899339', 2160: '9c7ef509' }, 'bell-seed-3': { 560: 'fe429293', 1200: '79cbbca9', 2160: 'ada0a493' } } 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 }