From c348da258f072bc88ea422cbc534c0831817b3c8 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 19:30:33 +0800 Subject: feat(occupation): P12 报价偏置纯函数——货郎买卖±3.00%/书生解读±1.00%,4位定点基点,默认无职业=旧行为(TDD 6例) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LivingVillage.Kernel/Occupation.fs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/LivingVillage.Kernel') diff --git a/src/LivingVillage.Kernel/Occupation.fs b/src/LivingVillage.Kernel/Occupation.fs index a3c37bd..5c75c81 100644 --- a/src/LivingVillage.Kernel/Occupation.fs +++ b/src/LivingVillage.Kernel/Occupation.fs @@ -171,3 +171,24 @@ module Occupation = let stateOf (kind: Kind) : State = { Profile = profileOf kind; TaskToken = 0; Today = None; StoryStage = 0 } + + // ---- 报价偏置(design §2/§3):Kernel 纯函数旁路,不改 Sim.fs 数值口径 ---- + // 4 位定点整数基点(1/10000)表达偏置,避免浮点漂移;结果钳在 [0.95, 1.05]。 + // 货郎:买卖双向有利(买压价/卖抬价 ±3.00%);书生:解读行情小幅加成 ±1.00%; + // 农夫/渔夫/无职业:恒 1.0,与旧行为逐位一致。 + + let private peddlerTradeBasisPoints = 300 + let private scholarTradeBasisPoints = 100 + + let quoteBiasBasisPoints (kind: Kind option) (playerIsBuyer: bool) : int = + match kind with + | Some Peddler -> if playerIsBuyer then -peddlerTradeBasisPoints else peddlerTradeBasisPoints + | Some Scholar -> if playerIsBuyer then -scholarTradeBasisPoints else scholarTradeBasisPoints + | _ -> 0 + + let quoteBiasOf (kind: Kind option) (playerIsBuyer: bool) : float32 = + float32 (10000 + quoteBiasBasisPoints kind playerIsBuyer) / 10000.0f + + /// Sim.quotePrice 的输出经职业偏置映射;None(无报价)原样穿透。 + let biasedQuote (kind: Kind option) (playerIsBuyer: bool) (baseQuote: float32 option) : float32 option = + baseQuote |> Option.map (fun price -> price * quoteBiasOf kind playerIsBuyer) -- cgit v1.2.3