v0.1.20: 万世无谬(第二轮全量审计歼灭,1011 测试+双金钟罩)

【事件闸(机制重锤)】
- fire(w,id,priority):单闸+优先级——高优(raid/渡劫/大比)顶替被占者、被顶替入 eventQueue 下月兑现不丢失;普通被占返回 false 调用方冷却(raid 被吞也写 CD)
- pending 唯一写入入口:渡劫/破境丹改走 fire(防覆盖丢弃);名宿传薪年锚 flag(防同年重复 12 次)
- applyEventChoice 前置校验 pendingEvent===id(陈旧 Modal 二次结算防线)

【世界模型四修(真·活世界)】
- era 延续档:flow 权重和<1(留白=续任)——盛世能撑 30 年而非固定 25
- 潮汐供给符号修正:灵涨万物丰(原实现反了)+tide 双界 clamp
- driftMarket 弱锚定:rebalance 0.1→0.025——供需/era/灾年真实撬动价格(原五池被锚死±5%)
- 断供/池底单常量 poolFloorPct=0.35(消灭禁买暗雷带)

【知识防线(审计虫洞修复)】
- 指纹扩展:era/stance/prosperity/relationsWithOthers/calamityLeft/pendingEvent 全入 hash
- 第二金钟罩 GOLDEN_RESOLVED:自动 resolve 长跑锁“现实”世界(原指纹锁的只是“事件流冻结”世界)

【性能与存储】
- 存档节流(疾12/常6/缓4,手动即时)+ saveChronicle O(N)→O(1) 单查增量写(2160 月档告别每 tick 数千 OPFS)
- battles≤220/chronicle≤520 截断(stringify 线性膨胀止血);startNewGame/openState 停 timer 摘旧 bus

【杂项】actDirect 对齐 ACT_CATALOG 全 24 项;about 三版本统一 0.1.20;kernel.bus 死总线删;seed 改 RngHub.rollSeed;normalize 补 eraStartYear/overflux/distress;WorldPanel 买卖条件反转修复;音效与视效同闸

【测试】1011 全绿(42 套件):audit-0.1.20 9 例(事件闸/传薪/二次结算/era延续/潮汐符号/断供一致/弱锚定/指纹敏感)
This commit is contained in:
2026-08-23 15:14:28 +08:00
parent e853fbdb71
commit be6f2f5fe7
22 changed files with 286 additions and 97 deletions
+21 -6
View File
@@ -13,7 +13,7 @@ export class WorldSim {
private s(): WorldSimState {
const w = this.w
if (!w.state.worldSim) w.state.worldSim = initSim(w) as never
if (!w.state.worldSim) w.state.worldSim = initSim(w)
const ws = w.state.worldSim as WorldSimState
if (!ws.secretQi || Object.keys(ws.secretQi).length === 0) {
const defs = pack().missions
@@ -30,7 +30,11 @@ export class WorldSim {
s.tideTicks++
const phase = (s.tideTicks % WORLDSIM.tideCycle) / WORLDSIM.tideCycle
const sine = 0.5 + 0.5 * Math.sin(phase * Math.PI * 2)
s.tide = Math.min(WORLDSIM.tideMax, WORLDSIM.tideMin + sine * (WORLDSIM.tideMax - WORLDSIM.tideMin) + ERA_CONF[s.era ?? 'pingshi'].tideBias)
s.tide = clamp(
WORLDSIM.tideMin + sine * (WORLDSIM.tideMax - WORLDSIM.tideMin) + ERA_CONF[s.era ?? 'pingshi'].tideBias,
WORLDSIM.tideMin - 0.05,
WORLDSIM.tideMax + 0.05
)
// 秘境灵气(自动恢复 + 探索消耗由 missions 在探索时扣;灾年灵脉闭锁 0.5 恢复)
const qiRecover = s.calamity ? WORLDSIM.secretRecover * 0.5 : s.tide > 0.85 ? WORLDSIM.secretRecoverHi : WORLDSIM.secretRecover
@@ -47,6 +51,7 @@ export class WorldSim {
const flow = ERA_CONF[curEra].flow
const roll = rng.next()
let acc = 0
let moved = false
for (const [next, wgt] of flow) {
acc += wgt
if (roll < acc) {
@@ -58,9 +63,12 @@ export class WorldSim {
year: this.w.state.year, month: 1, src: '天道',
text: `世道更替:${conf.name}来临。${conf.desc}`, kind: 'calamity'
})
moved = true
break
}
}
void moved
// roll 落在 flow 权重之外 → 延续本届(era 有厚度)
}
}
@@ -112,6 +120,12 @@ export class WorldSim {
// ---- B. NPC 演化(换代 + 关系网 + 互攻;B7) ----
evolveNpc(this.w, s, rng.next())
// ---- D1.5 盟友求援时效(18 月自清) ----
if (s.distress) {
const distAge = (this.w.state.year - s.distress.year) * 12 + (this.w.state.month - s.distress.month)
if (distAge > 18 && !this.w.state.npcFamilies[s.distress.id]?.allied) s.distress = undefined
}
// ---- D2. 天下十年一鉴(史官综述) ----
if (this.w.state.month === 1 && this.w.state.year % 10 === 0) {
s.newsFeed.push({ year: this.w.state.year, month: 1, src: '史官', text: decadeChronicle(s, this.w.state.year), kind: 'annal' })
@@ -218,7 +232,8 @@ function empty(): WorldSimState {
function worldBreath(w: World, s: WorldSimState): void {
const tide = s.tide
const era = ERA_CONF[s.era ?? 'pingshi']
const span = 1 - (tide - 1) * WORLDSIM.tideSupplySpan
// 潮汐供给:灵涨万物丰(tide>1 供给×1.3、灵衰×0.7)——0.1.19 符号反转修复
const span = 1 + (tide - 1) * WORLDSIM.tideSupplySpan
const supplySpan = Math.max(0.75, Math.min(1.35, span))
const eraSupply = era.supplyMult
const eraDemand = era.demandMult
@@ -293,11 +308,11 @@ function driftMarket(s: WorldSimState, noise: number): void {
const per = n; n += 0.13
const base = poolBase(id)
const cur = s.marketPool[id] ?? base
// 向基准再平衡 + 噪声漂移(价格弹性)
// 向基准再平衡(弱化锚定:让供需流与 era 真正撬动价格)+ 噪声漂移(价格弹性)
const rebalance = (base - cur) * WORLDSIM.marketRebalance
const drift = ((per % 1) - 0.5) * WORLDSIM.marketDriftRate * base
s.marketPool[id] = Math.max(base * 0.3, cur + rebalance + drift)
s.marketPool[id] = Math.max(base * WORLDSIM.poolFloorPct, cur + rebalance + drift)
}
}
@@ -494,7 +509,7 @@ function decadeChronicle(s: WorldSimState, year: number): string {
const from = year - 9
const rows = s.newsFeed.filter((r) => r.year >= from && r.year < year)
const calamities = rows.filter((r) => r.kind === 'calamity' && r.text.includes('灾')).length
const successions = rows.filter((r) => r.kind === 'npc').length
const successions = rows.filter((r) => r.kind === 'npc' && !r.text.includes('态度')).length
const quotes = rows.filter((r) => r.kind === 'quote').length
const era = ERA_CONF[s.era ?? 'pingshi'].name
const tideAvg = s.tide
@@ -89,10 +89,10 @@ export const ERA_CONF: Record<'shengshi' | 'pingshi' | 'luanshi' | 'mofa', {
/** 转移概势表:[下一态, 权重] */
flow: Array<['shengshi' | 'pingshi' | 'luanshi' | 'mofa', number]>
}> = {
shengshi: { name: '盛世', desc: '灵气鼎盛,百业兴旺,天下升平。', calamityMult: 0.5, supplyMult: 1.25, demandMult: 1.15, auctionMult: 1.3, tideBias: 0.08, flow: [['pingshi', 0.7], ['luanshi', 0.3]] },
pingshi: { name: '平世', desc: '四海无波,仙凡相安。', calamityMult: 1.0, supplyMult: 1.0, demandMult: 1.0, auctionMult: 1.0, tideBias: 0, flow: [['shengshi', 0.35], ['luanshi', 0.45], ['mofa', 0.2]] },
luanshi: { name: '乱世', desc: '群雄相逐,烽烟四起,灾祸连年。', calamityMult: 1.6, supplyMult: 0.85, demandMult: 1.05, auctionMult: 0.75, tideBias: -0.04, flow: [['pingshi', 0.4], ['mofa', 0.6]] },
mofa: { name: '末法', desc: '灵机衰微,大能隐迹,仙路将绝。', calamityMult: 1.2, supplyMult: 0.7, demandMult: 0.85, auctionMult: 0.6, tideBias: -0.09, flow: [['pingshi', 0.6], ['shengshi', 0.4]] }
shengshi: { name: '盛世', desc: '灵气鼎盛,百业兴旺,天下升平。', calamityMult: 0.5, supplyMult: 1.25, demandMult: 1.15, auctionMult: 1.3, tideBias: 0.08, flow: [['pingshi', 0.45], ['luanshi', 0.15]] },
pingshi: { name: '平世', desc: '四海无波,仙凡相安。', calamityMult: 1.0, supplyMult: 1.0, demandMult: 1.0, auctionMult: 1.0, tideBias: 0, flow: [['shengshi', 0.22], ['luanshi', 0.28], ['mofa', 0.1]] },
luanshi: { name: '乱世', desc: '群雄相逐,烽烟四起,灾祸连年。', calamityMult: 1.6, supplyMult: 0.85, demandMult: 1.05, auctionMult: 0.75, tideBias: -0.04, flow: [['pingshi', 0.25], ['mofa', 0.35]] },
mofa: { name: '末法', desc: '灵机衰微,大能隐迹,仙路将绝。', calamityMult: 1.2, supplyMult: 0.7, demandMult: 0.85, auctionMult: 0.6, tideBias: -0.09, flow: [['pingshi', 0.4], ['shengshi', 0.2]] }
}
/** era 持续年数区间(转移时机) */
@@ -106,14 +106,15 @@ export const ERA_DURA: Record<'shengshi' | 'pingshi' | 'luanshi' | 'mofa', [numb
/** 世界演化参数表(全部可调) */
export const WORLDSIM = {
marketDriftRate: 0.03,
marketRebalance: 0.1,
marketRebalance: 0.025, // 0.1.20 弱锚定:让供需/era/灾年真实驱动价格(0.1.19 为 0.1 硬锚死)
priceFloor: 0.55,
priceCeil: 2.3,
// —— 0.1.17 真库存循环 ——
worldSupplyRate: 0.02, // 世界侧月供给(base 比例;潮涨时 ×1.3)
worldDemandRate: 0.015, // 世界侧月需求(坊市/宗门常驻消耗)
npcTradeRate: 0.008, // 每 NPC 月贸易量(base 比例;上桌食量)
tradeFloorPct: 0.35, // 池低于此比例时玩家买入拒单(断供告急)
tradeFloorPct: 0.35, // 池低于此比例时玩家买入拒单(断供告急)——与 drift 池底一致
poolFloorPct: 0.35, // driftMarket 下限(拒绝“断供后还能买到”悖论带)
tradeCeilPct: 2.4, // 池上限(玩家大量卖出后价格封顶)
tideSupplySpan: 0.3, // 潮汐对供给的浮动幅度(tide±0.35 时 ×(1∓0.3)
// —— 灾年持续 ——
@@ -125,6 +126,8 @@ export const WORLDSIM = {
secretRecover: 2, // 灵气月恢复(潮高 ×2.5 → 用 secretRecoverHi
secretRecoverHi: 5,
secretConsume: 6, // 每次探索消耗(missions 默认)
// —— 盟约连坐(加性) ——
allianceGriefRaid: 0.012, // кажд 世仇盟连加性 raid 概率
// —— 天下事件 ——
calamityChance: 0.18,
calamities: ['旱灾', '涝灾', '蝗灾', '疫病', '兽潮', '寒潮'] as const,