diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 02:57:12 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 02:57:12 +0800 |
| commit | d06656aa968ccb2769ba7c90c97f57f2818bb828 (patch) | |
| tree | 4b1d8422233517830e1081c70eff86e241483590 /src/LivingVillage.Desktop/MapGen.fs | |
| parent | d3c0ef17cb1c4d30c1d586e2a5b616f58bd3d875 (diff) | |
| download | living-village-d06656aa968ccb2769ba7c90c97f57f2818bb828.tar.gz | |
feat(mapgen): 生成器序列化 + 世界站位接入(P20 第三步 A)
- MapGen.serialize:生成结果的确定性序列化(尺寸/seed/瓦片/Rivers/Bridges/
Paths/Buildings),同 seed 逐字节一致,供回归与跨机核对。
- WorldBootstrap.initialWorldWithPlacement:显式站位建世界;旧 64x48 路径
(initialWorld/initialWorldWithOccupation)字节口径不变。
- WorldBootstrap.initialWorldInMap:用生成器核心可达区做站位,30 spawn 全落
可达核心;新增 serialization/placement 两条测试。
- fsproj:MapGen 先于 WorldBootstrap 编译。
- Desktop 119->121,Kernel 90 不变。
Diffstat (limited to 'src/LivingVillage.Desktop/MapGen.fs')
| -rw-r--r-- | src/LivingVillage.Desktop/MapGen.fs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/MapGen.fs b/src/LivingVillage.Desktop/MapGen.fs index c59e6bd..7c7059a 100644 --- a/src/LivingVillage.Desktop/MapGen.fs +++ b/src/LivingVillage.Desktop/MapGen.fs @@ -312,6 +312,30 @@ module MapGen = let generateWithSize (width: int) (height: int) (seed: uint64) : Result = generate { defaultParams seed with Width = width; Height = height } + /// 生成结果的确定性序列化(同 seed 逐字节一致),供回归测试与跨机核对。 + let serialize (map: Result) : string = + let builder = System.Text.StringBuilder() + builder.Append(map.Width).Append('x').Append(map.Height).Append('|').Append(map.Seed).Append('|') |> ignore + for code in map.Tiles do + builder.Append(code).Append(',') |> ignore + builder.Append('|') |> ignore + for river in map.Rivers do + builder.Append(river.CenterY).Append('*').Append(river.Width).Append(';') |> ignore + builder.Append('|') |> ignore + for (x, y) in map.Bridges do + builder.Append(x).Append(':').Append(y).Append(';') |> ignore + builder.Append('|') |> ignore + for (x, y) in map.Paths do + builder.Append(x).Append(':').Append(y).Append(';') |> ignore + builder.Append('|') |> ignore + for building in map.Buildings do + builder + .Append(building.Left).Append(':').Append(building.Top).Append(':') + .Append(building.Width).Append(':').Append(building.Height).Append(':') + .Append(building.DoorX).Append(':').Append(building.DoorY).Append(';') + |> ignore + builder.ToString() + /// 可行走判定:非水,或位于桥面上(桥面仍标记为水但可通行)。 let isWalkable (map: Result) (x: int) (y: int) : bool = if x < 0 || x >= map.Width || y < 0 || y >= map.Height then |
