feat(0.1.14-P3): 世界自进化 WorldSim(五大闭环)+ 引擎时钟合一

- WorldSim(engine/sim/WorldSim.ts + worldsim-data.ts):
  A 资源循环市场(库存池/再平衡/价格弹性——Market 行情联动 sim.mult)
  B NPC 聚合演化(宗主换代/境界成长/势力=境界+财力+兵员;换代计数)
  C 秘境灵气(探索消耗/恢复)+ 灵气潮汐(6年周期×修炼倍率)
  D 灾年签(旱涝蝗疫兽寒,联动市场池)
  E 天下快讯(节流 24 月滚动 120 条,世界动态 feed)
- 相位:新增 worldsim(diplomacy 后 epilogue 前);capabilities 加「天下演序」卡可停用
- 时钟合一:World.clock = Kernel.clock(单一时钟驱动,消除双时钟漂移)
- 发现并修复:worldsim 注册被文件搬迁覆盖丢失(修改纪律验证中招——已补回);
  WorldSim 内 Math.random 根除(改 w.rng)
- fingerprint 纳入 worldSim 概要(市场/灵脉/潮汐/换代/快讯数)
- 金钟罩三档重固化(0.1.14 正式基线,受控变更)
- 验证:35 套件/967 测试全绿;typecheck 0 error
This commit is contained in:
2026-08-23 13:31:34 +08:00
parent 8dfdaf843a
commit 5dd5d6b558
16 changed files with 370 additions and 45 deletions
+13 -1
View File
@@ -2,6 +2,8 @@ import type { World } from '../runtime/World'
import { pack } from '../../data/registry'
import { traitBonuses } from '../runtime/pcgen'
import { WorldSim } from './WorldSim'
export function marketPrice(w: World, itemId: string): number {
const item = pack().items[itemId]
if (!item) return 0
@@ -9,10 +11,18 @@ export function marketPrice(w: World, itemId: string): number {
const fam = w.state.family
const mult = typeof fam.flag['priceMult'] === 'number' ? (fam.flag['priceMult'] as number) : 1
const mood = fam.reputation >= 40 ? 1.06 : fam.reputation >= 20 ? 1.02 : 0.98
// 世界行情乘子(缺省 1
let simMult = 1
if (w.state.worldSim?.marketPool) {
const pool = w.state.worldSim.marketPool[itemId] as number | undefined
const basePool = POOL_BASE[itemId] ?? 100
const r = (pool ?? basePool) / basePool
simMult = Math.max(0.55, Math.min(2.3, r))
}
// 利己(priceMult)与信誉修正
const sellers = w.aliveMembers().filter((c) => traitBonuses(c).priceMult > 0).length
const liarPct = Math.min(0.2, sellers * 0.04)
return Math.max(1, Math.round(base * mult * mood * (1 - liarPct)))
return Math.max(1, Math.round(base * mult * mood * simMult * (1 - liarPct)))
}
export function buyItem(w: World, itemId: string, count: number): boolean {
@@ -50,6 +60,8 @@ export function techniquePrice(techId: string): number {
import { TECHNIQUES } from '../../data/techniques'
const POOL_BASE: Record<string, number> = { lingcao: 600, lingkuang: 300, beastcore: 80, 'pill-qiyuan': 90, 'pill-ningyuan': 40 }
const TECHNIQUE_GRADE_PRICE: Record<number, number> = { 1: 120, 2: 300, 3: 700, 4: 1600 }
const TECH_GRADE_BASE: Record<string, number> = Object.fromEntries(
TECHNIQUES.map((t) => [t.id, TECHNIQUE_GRADE_PRICE[t.grade] ?? 300])