summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-19 03:20:56 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-19 03:20:56 +0800
commit4993bc37cb00356b83cb4f8a2e4a92fc2fe77922 (patch)
tree5b08f5fde9c420c30a588c113b78c421f828d0ab /src/LivingVillage.Desktop
parent2f46d1789088eb165271bd915844376aa5a84768 (diff)
downloadliving-village-4993bc37cb00356b83cb4f8a2e4a92fc2fe77922.tar.gz
feat: M3a 30 NPC 社区 — initialWorldN 网格布局 + Wander 寻伴闲聊 v1(ChatInit 事件队列 + 双方 Chatted 记忆 valence+0.3 + Social+40) + headless 聊天统计; 修复 clamp 泛型比较装箱(30npc 1天 63.5s→15.7s, 输出逐字节一致) + M3a 对拍/闲聊对称测试
Diffstat (limited to 'src/LivingVillage.Desktop')
-rw-r--r--src/LivingVillage.Desktop/Game.fs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs
index e2b520f..2e28760 100644
--- a/src/LivingVillage.Desktop/Game.fs
+++ b/src/LivingVillage.Desktop/Game.fs
@@ -70,6 +70,8 @@ module NpcView =
| Sleep -> "sleep"
| Wander -> "wander"
| Work -> "work"
+ | Chat -> "chat"
+ | Work -> "work"
type LivingVillageGame() as this =
inherit Game()
@@ -82,7 +84,7 @@ type LivingVillageGame() as this =
let mutable atlas = Unchecked.defaultof<Texture2D>
let mutable pixel = Unchecked.defaultof<Texture2D>
let mutable map = MapGen.generate Sim.mapWidthTiles Sim.mapHeightTiles
- let mutable world = Sim.initialWorld 42UL
+ let mutable world = Sim.initialWorldN 42UL Sim.npcCount
let mutable camera = Vector2.Zero
let mutable fpsFrames = 0
let mutable fpsSeconds = 0.0
@@ -139,10 +141,10 @@ type LivingVillageGame() as this =
fpsFrames <- 0
fpsSeconds <- 0.0
let npcAction =
- match world.Npcs with
- | npc :: _ -> NpcView.actionName npc.Mind.Action
- | [] -> "none"
- this.Window.Title <- $"Living Village M1{titleSuffix} | fps {fps:F1} | tick {world.Tick} | npc {npcAction}"
+ if world.Npcs.Length > 0 then
+ NpcView.actionName world.Npcs.[0].Mind.Action
+ else "none"
+ this.Window.Title <- $"Living Village M3a{titleSuffix} | fps {fps:F1} | tick {world.Tick} | npc {npcAction}"
printfn $"fps={fps:F1} tick={world.Tick} pos=({world.Avatar.Pos.X:F0},{world.Avatar.Pos.Y:F0})"
override this.Draw(gameTime: GameTime) =
@@ -163,9 +165,12 @@ type LivingVillageGame() as this =
spriteBatch.Draw(atlas, dst, src, Color.White)
let avatarDst =
Rectangle(int world.Avatar.Pos.X - camX, int world.Avatar.Pos.Y - camY, Sim.tilePixels, Sim.tilePixels)
- spriteBatch.Draw(pixel, avatarDst, Color.IndianRed)
+ spriteBatch.Draw(pixel, avatarDst, Color.Red)
+ let npcShades =
+ [| Color.Navy; Color.MediumBlue; Color.Blue; Color.RoyalBlue; Color.DodgerBlue |]
for npc in world.Npcs do
let npcDst =
Rectangle(int npc.Pos.X - camX, int npc.Pos.Y - camY, Sim.tilePixels, Sim.tilePixels)
- spriteBatch.Draw(pixel, npcDst, Color.Blue)
+ let (NpcId idx) = npc.Id
+ spriteBatch.Draw(pixel, npcDst, npcShades.[idx % npcShades.Length])
spriteBatch.End()