diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -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 () = |
