summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Kernel.Tests
Commit message (Collapse)AuthorAgeFilesLines
* p51: 职业系统实现首切片——开局钱/体力/背包侧车 + ↵Somhairle H. Marisol6 days1-2/+6
| | | | 当日任务/跨日刷新 + StartNewGameWith 读回(design §2.4-1)
* feat(kernel,desktop): P31 step3 story annals + identity entry + glyph atlasSomhairle H. Marisol12 days1-1/+52
| | | | | | | | | | | | | | | | | | - Sim.AnnalKind gains StoryAnnal (summary lives in the existing Summary field); WorldSave v3 serializes it with the new 'story' token. v1/v2 saves never contain the token and stay byte-identical; v3 save -> load -> save roundtrips byte-for-byte (tested). - Occupation.Story.identitySummaryOf: plain chronicle-style identity line written to the yearbook at game start (design section 3), e.g. yi-da-yu-wei-sheng. - Desktop: story summaries render in the chronicle panel; StartNewGame appends the identity annal; chooseIntent now routes responses through Occupation.biasResponse and advances the storyline (one stage per player dialogue) with the summary appended as a StoryAnnal. - M5View gains Seed (world seed source for the story start-day hash). - Chinese copy synced into requiredUiLabels; cjk-glyphs.txt + CjkGlyphAtlas.characterTable extended 238 -> 307 glyphs (384x480), atlas regenerated with the deterministic script. - 4 new kernel tests (115 -> 119); performance digest unchanged.
* feat(kernel): P31 step2 story stage state machineSomhairle H. Marisol12 days2-0/+231
| | | | | | | | | | | | | | | - Occupation.Story: three-segment arc per occupation (accept task -> visit households -> conclude), driven one stage per player dialogue with day gates derived from the same splitmix pattern as the daily task pool (start day = hash(seed ^ storySeed, day 0) mod 3 + 2, range [2,4]). - relationMeanToPlayer: decayed valence mean over acquainted NPCs only (same decay formula as Sim.relationMatrix); no acquaintances = 0. - Three endings (warm/plain/distant) chosen by deterministic thresholds (>=0.3 / >=0.0 / <0); ending text is fixed at the concluding dialogue. - onDialogue returns (state, summary text option) for the caller to write into the yearbook; StoryStage itself is unchanged (0..3) and already roundtrips through the existing v3 occupation segment. - 14 new kernel tests (101 -> 115); performance digest unchanged.
* feat(kernel): P31 step1 occupation dialogue response biasSomhairle H. Marisol12 days2-0/+147
| | | | | | | | | | | | | - Occupation.biasResponse: deterministic pure remap over Sim.responseFor; no occupation = byte-identical pass-through (all intents x personalities). farmer AskHelp Refused->Helpful; fisher SmallTalk Reserved->Friendly; peddler SmallTalk Reserved->Bargaining; scholar Joke fully overridden to Reserved (documented total-override semantics, opposite of personality). - Sim.responseFor made public (same pure function, reused as the base path). - Sim.chooseDialogueWith: extracted body of chooseDialogue with an injectable respond function; chooseDialogue keeps identity semantics unchanged. - Sim.appendAnnal made public for the upcoming story annal writes. - 9 new kernel tests (92 -> 101); performance digest unchanged.
* perf(kernel): P27 第二步 — Rumor 扫描去装箱 + 裁剪判定 O(1)Somhairle H. Marisol13 days3-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 两条互相独立、均不改变保留集合与查询结果的优化: 1) 扫描去装箱:latestRumorFor / rumorIsDuplicate 用 `=` 比较 [<Struct>] 的 NpcId/RumorId(含 RumorId option)会走泛型结构相等并逐条装箱(实测 ~24 B/条, Sim.chat 单独测得 N=16000 时 393,736 B/次、随 N 线性)。改为先解构底层 int/int64 再比较;Parent 用 int64 option 比较替代 RumorId option 结构相等。 语义完全等价,扫描不再逐条分配。 2) 裁剪判定 O(1):World 新增派生镜像 RumorCount/RumorOldestDay(不参与存档, 读档由列表经 rumorWorkingSetStats 重建)。appendRumor 用「count+1>capacity 或 min(oldest,day)<cutoff」O(1) 判定,仅真需裁剪时才走 trimRumors;旧 consRumor 每次追加都 rumorsNeedTrim 全表扫一遍。条件与 needTrim 逐字等价,保留集合相同。 等价性验证:5 天 2000 聊天/天跑两遍 WorldSave.save 逐字节相同, RumorCount/RumorOldestDay 与对列表重算一致(count=8000、oldest_day=1)。 Kernel 长跑基准 30 NPC × 2000 聊天/天(--rumor-bench D 30 2000): days 修复前 alloc / ms 修复后 alloc / ms 3 930,716,456 / 1626.7 482,716,192 / 1511.3 30 13,419,045,864 / 12182.5 4,884,067,640 / 8879.6 60 27,297,668,608 / 23769.7 9,774,660,360 / 17078.2 60 天分配 -64%、耗时 -28%,retained_id_checksum=927964000 前后一致。 门槛:final_digest=953775FAEB2F... 三次一致、performance_determinism=PASS; Kernel 92 / Desktop 143 全绿;--cost-probe 1/5 天 18.7s/18.8GB、90.4s/94.6GB (全模拟分配由逐 tick NPC 快照主导,谣言子系统占比很小,故全模拟基本持平)。
* test(kernel): 512x384 参数化边界存档 round-trip 与 NPC ↵Somhairle H. Marisol13 days2-0/+50
| | | | | | | | | 边界回归(P23) - Sim.configureBounds 512 384 下 v2 存档 round-trip 且同 world 两次保存逐字节一致, 读回再保存仍与原文一致;v1 的 64x48 兼容由既有用例覆盖。 - DriverHarness 长跑 20000 tick 断言 avatar 与全部 NPC 有限且留在 [0,max] 内。 - Kernel 测试 90 -> 92。
* feat(mapgen): 参数化确定性生成器与视口裁剪(P20 第一步)Somhairle H. Marisol13 days1-0/+22
| | | | | | | | | | - 新增纯函数 MapGen:尺寸参数化(默认 64x48,可 256x192),splitmix64 随机游走河道 + 2-3 octave value noise + 泊松式布点;核心区整平后以 BFS 校验 5x6=30 个 spawn 全部可达,不可达确定性修整并复验。 - visibleTileRange/visibleTileCount 纯函数,drawWorld 改为调用之(行为不变); drawMapFitted/drawMapViewport 仅证据用。 - 存档沿用 v2/v3 边界字段,补参数化边界 round-trip 测试,未改 Sim 语义。 - 回归:Desktop 109->115、Kernel 89->90;final_digest 与基线一致。
* test(sim): M6a ↵Somhairle H. Marisol13 days1-0/+87
| | | | 谣言裁剪回归——容量内零拷贝与逐字节一致/按天淘汰/单调 id/DayIndex 存档往返
* feat(occupation): P15 补齐货郎/书生各 2 条每日任务模板 + ↵Somhairle H. Marisol13 days1-7/+93
| | | | | | | | | | | | | | 既有事件通道信号桥(Kernel 纯函数 TDD) - TaskTemplateId 扩出 BuyGoods(收货)/Resell(转卖)/ObserveNotes(观察记事)/ReasonDebate(论理), taskPoolOf 货郎=[收货,转卖]、书生=[观察记事,论理],四职业池均非空。 - TaskSignal 增 Purchased(玩家买入)/Observed(观察),satisfiesCompletion 给出四模板完成判定; 新增 occupationSeedOf/refreshToday(跨日才重生成,同日含 Done/Failed 终态保留)。 - signalOfInteraction/advanceTask:仅 playerId 发起的 DialogueEvent/TradeEvent 产生信号, NPC 互动不派任务;Offered 须先 acceptTask,终态不可复活。WorldSave 模板 token 双向同步。 - 测试 83 全绿(新增 6:池非空、货郎书生逐日池内确定、模板中文名、完成信号正负、 事件桥含玩家买/卖与 NPC 忽略、既有 DialogueEvent→accept→Done 全链路、refreshToday 逐日)。 - 不动 Sim.step 数值路径;旧档 v3 模板 token 仅新增合法值,未知模板仍拒绝。
* test(kernel): 用 List.item 替换弃用的 List.nth,全解决方案 ↵Somhairle H. Marisol13 days1-3/+3
| | | | Release 构建归零告警
* feat(occupation): P12 ↵Somhairle H. Marisol13 days2-0/+72
| | | | 报价偏置纯函数——货郎买卖±3.00%/书生解读±1.00%,4位定点基点,默认无职业=旧行为(TDD 6例)
* feat(occupation): P11 存档 v3 today-task 尾段(annals 后追加)+ ↵Somhairle H. Marisol13 days1-0/+109
| | | | | | 双向兼容 Occupation.State 增 Today: DailyTask option(State 声明移至 DailyTask 之后;TaskToken 保留为 v3 前缀占位扩展位)。WorldSave:saveWith 有任务时在 annals 之后追加尾段 task-today|<template>|<state>|<offered>|<due>|npc-none/some|tile-none/some;无任务/无职业不追加(默认 None = 旧行为,v2 逐字节不变)。load 重构为内部 parse 返回 (World, Occupation.State option):尾段可选——旧 v3(P10 版式无尾段)新 reader 读出 Today=None;v1/v2 无任务;尾段后多余 token 或未知模板 token 拒绝(不吞档)。loadFromFileWith 顺手修正:不再经 stateOf 重置,前缀 task/stage 与 Today 全量保真。5 例测试:尾段位置(marker 在 annal 之后)+ 全字段 round-trip + 重存逐字节一致、无任务 v3 旧版式、v1/v2 无尾段 + 未知模板拒绝、尾段后垃圾拒绝、字节级双跑一致。
* feat(occupation): P11 每日任务生成纯函数 + TaskState ↵Somhairle H. Marisol13 days2-0/+192
| | | | | | 状态机(Kernel 侧) Occupation.fs 增补:TaskState(Offered|Active|Done|Failed)、TaskTemplateId 首期池=农夫3(送粮/帮工/翻土)+渔夫3(夜捕/卖渔/询价)、DailyTask 记录(设计 §2/§3)。生成 = taskHash(seed ^ occupationSeed, dayIndex) mod |pool|,与 Rng.fs splitmix 同源(禁 System.Random),输出只依赖三元组;taskHash 以 5 个 splitmix 已知向量钉死。完成判定 = satisfiesCompletion 纯谓词,信号 TaskSignal(Dialogued/Traded/ArrivedAt/NightAtWater) 全部来自既有事件通道(DialogueEvent/TradeEvent/到达瓦片/夜+水边),TargetNpc/TargetTile None=通配;acceptTask/applySignal/expireAt 状态机纯函数,Sim.step 数值路径零改动。货郎/书生空池 → dailyTaskOf = None。13 例测试:splitmix 向量、池约束、逐日确定性、窗口=整日、中文名、状态机转移、六模板正负完成信号、终态不可复活、逾期判负。
* feat(occupation): 职业系统第一片 — Kernel 结构 / bootstrap 注入 ↵Somhairle H. Marisol13 days2-1/+67
| | | | | | / 存档 v3 Occupation.fs(Kind/Profile/State + 农夫/渔夫/货郎/书生 中文名常量,按设计 §1 表给初始 Money/Energy/Inventory);ItemKind 扩出 Fish/Spice/Scroll(basePrice 分支补齐,Food 10.0f 数值路径不变 → 无职业 digest 不动);WorldBootstrap.initialWorldWithOccupation 默认 None = 旧行为(Money/Energy 覆盖,库存字段先留数据侧、物理挂接留交易单——取舍见 design §2-C 反对加字段);WorldSave: v3 头仅在有职业时写入(保存 saveToFileWith / loadFromFileWith,v1/v2/v3 无职业类型默认,token 顺序 version|w|h|kind|task|story|…),默认路径 save 输出逐字节等同现行 v2;P10 测试 5 例(§1 表值、v3 round-trip、v1/v2 不吞档、双 seed 逐字节、中文名);Kernel.Tests 引用 Desktop 以驱动 WorldBootstrap(取舍:不做测试专用 shim)。TaskToken/StoryStage 为 v3 占位(任务系统后续单实现)。
* feat(kernel): 地图边界参数化与存档 v2Somhairle H. Marisol14 days1-0/+58
| | | | Sim 地图边界由常量 52 改为可配置(configureBounds,默认 64x48 = 与全部基线一致);Sim.step 裁剪、initialWorld 中心出生时点按当前边界读取;WorldSave 升级 V2 头携带 width/height 两字段,V1 旧存档照常读入并自动回退到 64x48;回归:512x384 边界裁剪/初界转正/双份存档往返/案例 v1 档兼容读。修复前一段中报错已修正的测试代码(Ensure saved-file timeouts)。
* feat(m6a): add file save acceptance smokeSomhairle H. Marisol2026-09-201-21/+92
| | | | | | | | | | | | | | | | | [Change Nature] This commit adds the bounded M6a file-save acceptance path. [New Capability] - Add file-level round-trip and deterministic continuation coverage. - Add Headless --m6a-smoke with digest checks and explicit PASS/FAIL output. [Implementation] - Reject non-finite numeric values and negative inventory quantities. - Exercise dialogue, chat/rumor, trade, events, annals, time, and RNG state. [Impact] - Affects Kernel save parsing, Kernel tests, and Headless smoke tooling. - Preserves the existing save format and M5 smoke behavior.
* perf: add simulation baseline probeSomhairle H. Marisol2026-09-202-0/+53
|
* feat(m6a): add save speed and day-night controlsSomhairle H. Marisol2026-09-202-0/+100
|
* feat(m5): 增加可交互对话、需求观察与编年史Somhairle H. Marisol2026-09-206-14/+211
| | | | | | | | | | | | | | | [变更性质] - 本提交新增 M5 用户能力,不是缺陷修复。 [新增功能] - 增加玩家六意图对话、需求面板、可见 NPC 观察、编年史与因果谣言冒烟验收。 [实现方案] - 在 Kernel 中扩展 Avatar Mind、对话结果、观察数据、Annals 和确定性谣言链。 - 在 Desktop 中加入键盘交互、像素文本面板和运行时状态展示,并补充 Headless 与测试覆盖。 [影响范围] - 覆盖 Kernel、Headless、Desktop 及测试工程;保留既有 M3/M4 确定性与交易、关系、谣言行为。
* feat(m4b): 增加可追踪谣言传播与回放Somhairle H. Marisol2026-09-205-3/+187
| | | | | | | | | | | | | | | | [变更性质] - 本提交新增 M4b 谣言传播与确定性验收能力,不是单纯缺陷修复。 [新增功能] - 支持带来源、父节点、深度、强度和路径的谣言传播、去重、衰减与过期处理。 - Headless 支持稳定谣言 dump、replay,以及与 batch 模式的互斥校验。 [实现方案] - 通过不可变 World 更新和失败原子返回保持模拟确定性。 - 新增多跳传播、重复转述、过期父节点、非法参与者和稳定 trace 测试。 [影响范围] - 影响 Kernel、Headless 和 Kernel 测试;不包含 M5/M6 或无关配置与文档改动。
* feat(m4a): 增加交易库存金钱与动态定价Somhairle H. Marisol2026-09-204-0/+160
| | | | | | | | | | | | | | | | | [变更性质] - 本提交新增 M4a 交易能力,不扩大到 M4b、M5 或 M6。 [新增功能] - 支持 Food 库存、买卖双方金钱转移、原子成功与拒绝结果。 - 支持基于需求、库存、性格和近期成交记忆的动态定价。 [实现方案] - 在 Sim 中增加 TradeRequest、TradeResult、交易失败类型、交易记忆与 TradeEvent。 - 以不可变 World 更新和确定性定价保持库存、金钱及事件守恒。 - 增加交易测试,并补齐既有 NPC fixture 与 MemoryKind 穷举匹配。 [影响范围] - 仅影响 LivingVillage.Kernel 交易逻辑及五个 M4a 相关测试项目文件。
* fix(m3): 保留关系记忆并避免立即重复聊天Somhairle H. Marisol2026-09-201-0/+54
| | | | | | | | | | | | | | | | | | | [问题原因] - 常规记忆写入会挤出 Chatted 事件,导致关系权重失去长期输入。 - NPC 聊天选伴没有排除最近对象,可能立即重复同一聊天伙伴。 [问题根因] - 记忆列表只使用单一容量截断策略,没有区分关系记忆和常规记忆。 - 聊天伙伴搜索只按距离选择,没有读取最近聊天记忆。 [修复方案] - 为关系记忆保留容量,并继续限制总记忆容量。 - 优先选择非最近聊天伙伴;无替代对象时回退到原有选择逻辑。 - 增加记忆保留和重复聊天回归测试。 [影响范围] - 修改 LivingVillage.Kernel 的 NPC 记忆与聊天伙伴选择。 - 不改变 headless 参数或关系矩阵接口;现有构建与测试流程保持兼容。
* fix: M3c 关系半衰期单位错误 ↵Somhairle H. Marisol2026-09-191-2/+20
| | | | 86400L(=24模拟分钟)→ticksPerDay(1模拟日=5,184,000tick) + 衰减改真半衰 exp(-ln2*age/halfLife)(age=halfLife 处权重恰0.5, 旧式 exp(-age/halfLife) 为 e^-1≈0.368) + 单测锁定(1天=5184000tick/halfLife=1天/半衰权重0.5, 手算期望随真半衰语义更新) + headless 批验新增旧判据 old_crit 观测报告(60% 覆盖判据保留为门)
* feat: M3b 关系网络派生 — Sim.relationMatrix ↵Somhairle H. Marisol2026-09-192-0/+123
| | | | 双向累加+时间衰减(halfLife 86400tick, |r|>0.5 阈值) + headless --dump-relations 与 --batch K D 验收(chats max/avg、relcnt 差异、无NaN) + Desktop L 键关系视图(暂停+快照, 绿/红线粗细∝|r|, cyan NPC 点) + LV_STEPS_PER_FRAME 调试快进 + 衰减/矩阵/30npc 对称测试(19/19) + xvfb 截图验证 PASS
* feat: M3a 30 NPC 社区 — initialWorldN 网格布局 + Wander 寻伴闲聊 ↵Somhairle H. Marisol2026-09-191-2/+58
| | | | v1(ChatInit 事件队列 + 双方 Chatted 记忆 valence+0.3 + Social+40) + headless 聊天统计; 修复 clamp 泛型比较装箱(30npc 1天 63.5s→15.7s, 输出逐字节一致) + M3a 对拍/闲聊对称测试
* feat: M2b NPC 记忆与行为稳定化 — 环形记忆(≤64: ↵Somhairle H. Marisol2026-09-191-0/+61
| | | | tick/kind/valence) + 行动粘性(最小600tick, urgent<20豁免) + 夜间(22-6)sleep权重x3 + Desktop蓝色NPC与标题行动名 + headless摘要(mem_count/last_valence/行动平均持续/昼夜sleep占比) + 粘性与valence测试
* feat: M2a NPC 心智基础 — Needs 衰减 + Personality(seed) + ↵Somhairle H. Marisol2026-09-191-0/+47
| | | | 决策层v1(需求缺口×性格权重) + 四语义点直线移动 + headless NPC 摘要 + 对拍/衰减测试
* feat: M1 模拟器内核 — SplitMix64 RNG + 确定性 step + 对拍测试 ↵Somhairle H. Marisol2026-09-192-0/+157
+ headless 冒烟工具 + Desktop 自动演示 [变更性质] 本 commit 为功能开发,交付设计文档 §2 模拟器内核(里程碑 M1),非缺陷修复或结构重构。 [新增功能] - Kernel:Rng.fs 提供 SplitMix64 纯函数 RNG(ofSeed / nextUInt64 / nextFloat32),World 携带种子状态。 - Kernel:Sim.fs 重写为 struct record(Vec2/Avatar/Input/TimeStep/World),step : World → TimeStep → World 纯函数,dt 固定 1/60 由内核常量给定,Time = Tick * dt 不做浮点累加;initialWorld 由无参改为带 seed。 - Tests:MSTest 确定性对拍——同 seed 轨迹逐 tick 相等、异 seed 发散、step 纯度、长跑有限/有界/时间-刻度关系、SplitMix64 已知向量、nextFloat32 值域。 - Headless:--days N --seed S 冒烟工具,每 1000 tick 输出摘要行,统计 NaN/越界计数并决定退出码。 - Desktop:LV_AUTOPLAY=1 环境变量启用正弦驱动自动演示,窗口标题与启动日志标注模式。 [实现方案] - 全部状态用 [<Struct>] record,模拟路径零堆分配,支撑 51.84 亿刻长跑。 - step 不消费 World 内 RNG,种子经由外部确定性驱动脚本生效(每 900 刻换段,8 方向查表 + 三档幅值,避开三角函数保证跨平台位精确)。 - Headless 内存口径取 GC.GetTotalMemory(true)(全收集后的稳态驻留),避免 GetTotalMemory(false) 随 Gen0 段扩张漂移误报泄漏。 [影响范围] - Kernel 保持零 MonoGame 引用,模拟与渲染彻底分离;sln 新增 Headless 与 Tests 两个项目。 - Release 构建 0 警告 0 错误,7/7 测试通过;1000 天长跑 5,184,000,000 刻退出码 0,无 NaN 无越界,内存 87,824 → 93,000 字节(1.06x < 2x)。 - 同 seed 两次运行 stdout 字节一致,seed 42/43 轨迹不同。