diff options
Diffstat (limited to 'src/LivingVillage.Desktop')
| -rw-r--r-- | src/LivingVillage.Desktop/MapGen.fs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/LivingVillage.Desktop/MapGen.fs b/src/LivingVillage.Desktop/MapGen.fs index 1e63ed2..63b14bc 100644 --- a/src/LivingVillage.Desktop/MapGen.fs +++ b/src/LivingVillage.Desktop/MapGen.fs @@ -32,7 +32,9 @@ module MapGen = SpawnColumns: int SpawnRows: int /// P24:大图额外沿河民居数量(沿现有路网泊松散布)。默认 0,64x48/256x192 不受影响。 - ExtraRiversideHouses: int } + ExtraRiversideHouses: int + /// P25:是否放置孤立装饰石块。默认 true;大图关闭,避免草地上出现游离石板 tile。 + DecorativeStones: bool } /// P20 第二步:一条贯穿全图的东西向河道(每列恰好一段,宽度下限 RiverWidth)。 type River = @@ -73,7 +75,8 @@ module MapGen = CoreSide = 14 SpawnColumns = 5 SpawnRows = 6 - ExtraRiversideHouses = 0 } + ExtraRiversideHouses = 0 + DecorativeStones = true } /// P23 尺寸自适应参数:河道数量随高度增长(约每 96 行一条),其余沿用默认。 /// 64x48 / 256x192 仍得到 2 条河道,与既有输出逐字节一致;512x384 得到 4 条。 @@ -85,7 +88,8 @@ module MapGen = Width = width Height = height RiverCount = max base_.RiverCount (max 1 (height / 96)) - ExtraRiversideHouses = (if large then 10 else 0) } + ExtraRiversideHouses = (if large then 10 else 0) + DecorativeStones = not large } // ---- splitmix64 与 value noise(无外部依赖、无时钟) ---- @@ -203,20 +207,22 @@ module MapGen = let attempts = max 100 ((w * h) / 16) let mutable placed: (int * int) list = [] let mutable scatterRng = p.Seed ^^^ 0xC0FFEEUL - for _ in 1 .. attempts do - let nextState, raw = splitmix scatterRng - scatterRng <- nextState - let x = int (raw % uint64 w) - let y = int ((raw >>> 20) % uint64 h) - let far = - placed - |> List.forall (fun (px, py) -> - let dx = px - x - let dy = py - y - dx * dx + dy * dy > minSq) - if far && not (inCore x y) && tiles.[idx x y] = int GroundTile.Grass then - tiles.[idx x y] <- int GroundTile.Stone - placed <- (x, y) :: placed + // P25:大图禁用孤立装饰石块,避免草地上出现游离石板 tile(64x48/256x192 保持开启)。 + if p.DecorativeStones then + for _ in 1 .. attempts do + let nextState, raw = splitmix scatterRng + scatterRng <- nextState + let x = int (raw % uint64 w) + let y = int ((raw >>> 20) % uint64 h) + let far = + placed + |> List.forall (fun (px, py) -> + let dx = px - x + let dy = py - y + dx * dx + dy * dy > minSq) + if far && not (inCore x y) && tiles.[idx x y] = int GroundTile.Grass then + tiles.[idx x y] <- int GroundTile.Stone + placed <- (x, y) :: placed // 5) 交通:桥 + 石板路网 + 沿河民居(白墙黑瓦矩形色块,门朝远岸路)。 let mutable structureRng = p.Seed ^^^ 0x51AB1EUL |
