diff options
Diffstat (limited to 'src/LivingVillage.Kernel/Occupation.fs')
| -rw-r--r-- | src/LivingVillage.Kernel/Occupation.fs | 21 |
1 files changed, 21 insertions, 0 deletions
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) |
