summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
-rw-r--r--src/LivingVillage.Desktop.Tests/MapGenTests.fs63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/MapGenTests.fs b/src/LivingVillage.Desktop.Tests/MapGenTests.fs
index 4079ad0..4d11dd1 100644
--- a/src/LivingVillage.Desktop.Tests/MapGenTests.fs
+++ b/src/LivingVillage.Desktop.Tests/MapGenTests.fs
@@ -172,6 +172,69 @@ type MapGenTests () =
Assert.IsTrue(visited.[ay * map.Width + ax], "avatar spawn must sit in the reachable core")
Assert.IsTrue(ax >= map.Core.MinX && ax <= map.Core.MaxX && ay >= map.Core.MinY && ay <= map.Core.MaxY, "avatar spawn must sit in the core")
+ // ---- P23:512x384 扩程(尺寸自适应参数 + 连续性/可达性 + 默认图锁定) ----
+
+ [<TestMethod>]
+ member _.SizeAdaptiveParamsScaleRiversWithHeight () =
+ Assert.AreEqual<int>(2, (MapGen.paramsForSize 64 48 (uint64 1)).RiverCount)
+ Assert.AreEqual<int>(2, (MapGen.paramsForSize 256 192 (uint64 1)).RiverCount)
+ Assert.AreEqual<int>(4, (MapGen.paramsForSize 512 384 (uint64 1)).RiverCount)
+
+ [<TestMethod>]
+ member _.HugeMap512SameSeedIsByteIdentical () =
+ let a = MapGen.generateWithSize 512 384 (uint64 4242)
+ let b = MapGen.generateWithSize 512 384 (uint64 4242)
+ tilesEqual a b "512x384 same seed"
+ Assert.AreEqual<string>(MapGen.serialize a, MapGen.serialize b)
+ Assert.AreEqual<int>(512, a.Width)
+ Assert.AreEqual<int>(384, a.Height)
+ Assert.AreEqual<int>(30, a.Spawns.Length)
+ Assert.IsTrue(a.ReachabilityOk, "512x384 must keep the core reachable")
+ Assert.IsTrue(a.BridgeCrossingsOk, "512x384 bridges must connect both banks")
+
+ [<TestMethod>]
+ member _.HugeMap512DifferentSeedsDiverge () =
+ let a = MapGen.generateWithSize 512 384 (uint64 4242)
+ let b = MapGen.generateWithSize 512 384 (uint64 7)
+ Assert.AreNotEqual<int64>(checksum a, checksum b, "different seeds must differ at 512x384")
+ Assert.AreNotEqual<string>(MapGen.serialize a, MapGen.serialize b)
+
+ [<TestMethod>]
+ member _.HugeMap512RiversStayContinuousAcrossAllBands () =
+ let map = MapGen.generateWithSize 512 384 (uint64 4242)
+ Assert.AreEqual<int>(4, map.Rivers.Length)
+ let minWidth = map.Rivers |> List.map (fun river -> river.Width) |> List.min
+ Assert.IsTrue(minWidth >= 3, "river width lower bound holds at 512x384")
+ for x in 1 .. map.Width - 2 do
+ let runs = waterRunsInColumn map x
+ if runs.Length <> map.Rivers.Length then
+ Assert.Fail(sprintf "column %d must hold exactly %d contiguous runs, saw %d" x map.Rivers.Length runs.Length)
+ for run in runs do
+ Assert.IsTrue(run >= minWidth, sprintf "column %d has a run of %d < min width %d" x run minWidth)
+ for y in 0 .. map.Height - 1 do
+ for x in 0 .. map.Width - 1 do
+ if map.Tiles.[y * map.Width + x] = int MapGen.GroundTile.Water then
+ Assert.IsTrue(waterNeighbourCount map x y >= 2, sprintf "water tile (%d,%d) is isolated" x y)
+
+ [<TestMethod>]
+ member _.HugeMap512ThirtySpawnsReachCoreAndBothBanks () =
+ let map = MapGen.generateWithSize 512 384 (uint64 4242)
+ let startX, startY = map.Spawns.Head
+ let visited = MapGen.floodFill map startX startY
+ for (x, y) in map.Spawns do
+ Assert.IsTrue(visited.[y * map.Width + x], sprintf "spawn (%d,%d) unreachable at 512x384" x y)
+ for building in map.Buildings do
+ Assert.IsTrue(visited.[building.DoorY * map.Width + building.DoorX], "building door unreachable at 512x384")
+ for (x, y) in map.Bridges do
+ Assert.IsTrue(visited.[y * map.Width + x], sprintf "bridge tile (%d,%d) unreachable at 512x384" x y)
+ Assert.IsTrue(map.Buildings.Length >= map.Rivers.Length, "riverside building per band at 512x384")
+
+ /// 锁定当前默认尺寸的生成结果,防止 P23 参数适配无意改变 64x48 / 256x192。
+ [<TestMethod>]
+ member _.DefaultSizeChecksumsArePinned () =
+ Assert.AreEqual<int64>(6042052L, checksum (MapGen.generateWithSize 64 48 (uint64 4242)))
+ Assert.AreEqual<int64>(1284656962L, checksum (MapGen.generateWithSize 256 192 (uint64 4242)))
+
[<TestMethod>]
member _.VisibleRangeClampsAtLegacyMapEdges () =
let x0, y0, x1, y1 = MapGen.visibleTileRange 64 48 0 0 2048 1536