Files
ChronicleOfTheImmortalClan/tests/clock.test.ts
T
thzxx 3fb64f6e78 v0.1.34a(修正): 新秘境改种子派生伪随机——零 rng 消耗(修复跨世界/跨跑分叉)
B0 原用 World.rng.chance/pick/int——序列漂移疑虑(实际为模块级全局 EXTRA_MISSIONS 残留污染);
现改为 seed 哈希派生(year/npcSuccessions 异或哈希——纯确定性零 rng),金钟罩序列零伤;
SecretQi/mission def 全走世界状态 s.wonders(每档独立),确定性复跑矩阵恢复绿;
金钟罩 0.1.34 基线固化(功法流派/时节共鸣/warFatigue/换代/断供受控变更——值变序列受控重算 62 例绿)
2026-08-23 22:05:53 +08:00

57 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.34 万象归元基线:功法流派效果(crit/guard/trib/secret/元素时节共鸣/
// warFatigue/换代恩义清/断供/新秘境(零 rng 派生)后固化(受控变更重算)。
const GOLDEN: Record<string, Record<number, string>> = {
'bell-seed-1': { 560: '70f0223f', 1200: 'da91696b', 2160: '952c55c5' },
'bell-seed-2': { 560: '700fd9dd', 1200: 'd04b0989', 2160: 'c8aae012' },
'bell-seed-3': { 560: '1788581c', 1200: 'cc2ed227', 2160: '991d2684' }
}
/** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件;
* 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */
const GOLDEN_RESOLVED: Record<string, Record<number, string>> = {
'bell-seed-1': { 560: 'd03824ce', 1200: '237e93f3', 2160: 'cee2dc9c' },
'bell-seed-2': { 560: 'db32bc97', 1200: '7b8177d8', 2160: '8257b4e1' },
'bell-seed-3': { 560: '4c8b66c5', 1200: '39fc71ea', 2160: '384b1586' }
}
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<typeof longRun> {
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
}