diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 15:06:03 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 15:06:03 +0800 |
| commit | 87aa4594ffe395318364feae9fd157d52b60a082 (patch) | |
| tree | 099b328b7996a98cd5e26631508bedb5a0d15ed3 /src/LivingVillage.Desktop.Tests | |
| parent | ab19df0ebad8da972cd30f89f7cfd8ef38b8c0ae (diff) | |
| download | living-village-87aa4594ffe395318364feae9fd157d52b60a082.tar.gz | |
feat(desktop): 512x384 程序生成地图与巡游取证模式
ProceduralMap 纯函数生成器:splitmix64 随机游走河道(三条西→东,宽 3,穿核心禁入)、三倍频值噪声草地/泥炭变化、泊松式最小距离布点(800 次尝试),村核矩形(24..38 x 16..34)由生成器不变式保证可通行;VillageArt 于大世界模式下按 terrain code 逐格绘制(可视化范围裁剪,无每帧分配);Game 新增 LV_MAP_SCALE(默认 1,表示规模倍数)与 LV_MAP_TOUR 巡游采样(八个地标位置含角/中心/河带);快照回归断言:同 seed 逐字节一致、异 seed 必然差异、核心矩形无水面。
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index 5a40868..ece7b23 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -737,6 +737,28 @@ type PrototypeTests () = Assert.AreEqual<float32>(TitleScreen.entranceProgress 37L, TitleScreen.entranceProgress 37L) [<TestMethod>] + member _.ProceduralMapGeneratesByteIdenticalTerrainFromSameSeed () = + let first = ProceduralMap.generate (uint64 4242) + let second = ProceduralMap.generate (uint64 4242) + Assert.AreEqual<int>(first.Tiles.Length, second.Tiles.Length) + let snapshot = Array.copy first.Tiles + for i in 0 .. snapshot.Length - 1 do + Assert.AreEqual<int>(snapshot.[i], second.Tiles.[i], (sprintf "tile %d diverged" i)) + + // Different seed must produce different terrain (sanity). + let other = ProceduralMap.generate (uint64 777) + let differs = [0 .. snapshot.Length - 1] |> List.tryFind (fun i -> other.Tiles.[i] <> snapshot.[i]) + Assert.IsTrue(differs.IsSome, "different seed should carve different terrain") + + // Village core stays walkable: no water/peat inside the handcrafted core rect. + let coreBad = + [ for y in ProceduralMap.villageCoreMinY .. ProceduralMap.villageCoreMaxY do + for x in ProceduralMap.villageCoreMinX .. ProceduralMap.villageCoreMaxX do + let code = first.Tiles.[y * ProceduralMap.width + x] + if code = ProceduralMap.GroundTile.Water || code = ProceduralMap.GroundTile.Peat then yield (x, y, code) ] + Assert.AreEqual<(int * int * int) list>([], coreBad) + + [<TestMethod>] member _.WorldPanelDoesNotRenderA永久KeyList () = let world = Sim.initialWorldN 42UL 0 let lines = M5Interaction.panelLines world M5Interaction.initial |
