【世界种子生成器(NPC 数量不再定死)】 - sim/worldgen.ts:generateWorld(seed) 确定性塑造天下——NPC 4~8 家随机 (老牌世家模板 + 词库组合新贵,名字去重)、初始关系网(1-2世仇+1盟友)、 开局 era 三态、区域风味、市场偏移 ±15% - 独立派生 rng(seed::worldgen)——World.rng 主序列零消耗:同 seed 世界可重放、 玩法随机序列不受生成器移动(金钟罩玩法序保护) - state.worldGen 落档(normalize 旧档按 seed 重放=同世界,存档兼容) - creation 初始化 npcFamilies/initSim 关系网/era/池偏置全走 worldgen——开局即恩怨 - 局内补位目标 = 开局家数(4~8),生灭闭环持续 【插件深化(0.1.24 第二组钩子)】 - PluginContext.beforePhase/afterPhase(时轮锚点:phase 前后挂勾,卸载全摘) - PluginContext.addNpcTemplate(世界模板注入——词库插件化) - plugin-public 文档同步;示例 Plugin 契约升级 【测试适配(世界名单随机化)】 - 静态 npc id 假设全面改动态取家(anyNpc helper 共享); - 难度梯度用例改「同 seed 不同难度」比较;worldgen 确定性/范围/去重/关系对称 7 例 【测试】1034 全绿(45 套件);金钟罩 0.1.24 基线固化(worldgen 随机世界)+ worldAnnals 等; build 通过
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
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.24 寰宇初构基线(指纹含全世界轴+worldgen 随机世界):
|
|
// 世界种子生成器(4~8 家/开局恩怨/era/市场偏移独立量)+时轮锚点后固化。
|
|
const GOLDEN: Record<string, Record<number, string>> = {
|
|
'bell-seed-1': { 560: 'd446167b', 1200: '549b868e', 2160: '6daf0d73' },
|
|
'bell-seed-2': { 560: '306c458c', 1200: '625f5d8e', 2160: '00b2ea0c' },
|
|
'bell-seed-3': { 560: '8db4594e', 1200: 'c3e1c746', 2160: 'e4f1029a' }
|
|
}
|
|
|
|
/** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件;
|
|
* 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */
|
|
const GOLDEN_RESOLVED: Record<string, Record<number, string>> = {
|
|
'bell-seed-1': { 560: '9571c9c4', 1200: 'a5a616e1', 2160: '6278847d' },
|
|
'bell-seed-2': { 560: '5dd40c96', 1200: '7b7c61a3', 2160: '8f49d288' },
|
|
'bell-seed-3': { 560: 'a1f441ce', 1200: 'ffb579d0', 2160: 'b5fc8019' }
|
|
}
|
|
|
|
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
|
|
}
|