diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 09:00:11 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 09:00:11 +0800 |
| commit | 91b7204d45f4f11d9cd75afcfbea9bd7034a3de4 (patch) | |
| tree | eea09262064fb8478d3b225038389abc12f9fc04 /src/LivingVillage.Desktop.Tests/MapGenTests.fs | |
| parent | 621770554dd17924900450692da25d30b6630536 (diff) | |
| download | living-village-91b7204d45f4f11d9cd75afcfbea9bd7034a3de4.tar.gz | |
fix(mapgen): 大图关闭孤立装饰石块,杜绝草地上游离石板 tile(P25)
- 新增 Params.DecorativeStones(默认 true);paramsForSize 对 >256x192 关闭,
512x384 不再产生 292 个孤立石板(stone 非路网计数归零,石块全部属于路网)。
- 64x48/256x192 保持开启,checksum 6042052/1284656962 不变。
- 新增 NoIsolatedStoneTiles / DecorativeStonesDisabledOnLargeMaps 回归;Desktop 134 -> 136。
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/MapGenTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/MapGenTests.fs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/MapGenTests.fs b/src/LivingVillage.Desktop.Tests/MapGenTests.fs index 4a09865..f426a8a 100644 --- a/src/LivingVillage.Desktop.Tests/MapGenTests.fs +++ b/src/LivingVillage.Desktop.Tests/MapGenTests.fs @@ -261,6 +261,37 @@ type MapGenTests () = Assert.AreEqual<int>(4, (MapGen.generateWithSize 64 48 (uint64 4242)).Buildings.Length) Assert.AreEqual<int>(4, (MapGen.generateWithSize 256 192 (uint64 4242)).Buildings.Length) + // ---- P25:大图不产孤立石板 tile(装饰石块默认开启仅限小图) ---- + + [<TestMethod>] + member _.DecorativeStonesDisabledOnLargeMaps () = + Assert.IsTrue((MapGen.paramsForSize 64 48 (uint64 1)).DecorativeStones) + Assert.IsTrue((MapGen.paramsForSize 256 192 (uint64 1)).DecorativeStones) + Assert.IsFalse((MapGen.paramsForSize 512 384 (uint64 1)).DecorativeStones) + + [<TestMethod>] + member _.LargeMapHasNoIsolatedStoneTiles () = + let map = MapGen.generateWithSize 512 384 (uint64 4242) + let pathSet = System.Collections.Generic.HashSet<int>(map.Paths |> List.map (fun (x, y) -> y * map.Width + x)) + let stone x y = map.Tiles.[y * map.Width + x] = int MapGen.GroundTile.Stone + let mutable isolated = 0 + for y in 0 .. map.Height - 1 do + for x in 0 .. map.Width - 1 do + if stone x y && not (pathSet.Contains(y * map.Width + x)) then + let neighbours = + [ (x + 1, y); (x - 1, y); (x, y + 1); (x, y - 1) ] + |> List.filter (fun (nx, ny) -> nx >= 0 && nx < map.Width && ny >= 0 && ny < map.Height) + |> List.filter (fun (nx, ny) -> stone nx ny) + |> List.length + if neighbours = 0 then isolated <- isolated + 1 + Assert.AreEqual<int>(0, isolated) + // 装饰关闭后,大图所有石板都应属于路网。 + let stonesOutsidePaths = + [ for y in 0 .. map.Height - 1 do + for x in 0 .. map.Width - 1 do + if stone x y && not (pathSet.Contains(y * map.Width + x)) then yield (x, y) ] + Assert.AreEqual<int>(0, stonesOutsidePaths.Length) + /// 锁定当前默认尺寸的生成结果,防止 P23 参数适配无意改变 64x48 / 256x192。 [<TestMethod>] member _.DefaultSizeChecksumsArePinned () = |
