blob: 53cc274ee47b0884517c688e5f5968f360d3edb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
namespace LivingVillage.Desktop
open System
open System.IO
open System.Security.Cryptography
module Program =
/// P68 证据钩子:LV_P68_MAPSHOT=1 时离线渲染 512×384 / seed 4242 整图为 PNG 后退出,
/// 不启动图形设备(真正 headless)。打印尺寸/瓦片统计/要素统计/确定性供 analyze 核验。
let private runMapShot () : int =
let map = MapGen.generateWithSize 512 384 (uint64 4242)
let scale = MapSnapshot.defaultScale
let recordDirectory =
match Environment.GetEnvironmentVariable("LV_RECORD_DIR") with
| null | "" -> "/tmp/lv-p68-map"
| value -> value
Directory.CreateDirectory recordDirectory |> ignore
let png = MapSnapshot.renderPng map scale
let again = MapSnapshot.renderPng (MapGen.generateWithSize 512 384 (uint64 4242)) scale
let deterministic = png = again
let sha = SHA256.HashData png |> Convert.ToHexString
File.WriteAllBytes(Path.Combine(recordDirectory, "p68-map.png"), png)
let tiles code = map.Tiles |> Array.filter (fun c -> c = code) |> Array.length
let roadTiles =
map.MainRoadCenter
|> Array.filter (fun y -> y >= 0 && y < map.Height)
|> Array.length
printfn
"p68-map width=%d height=%d scale=%d png=%dx%d bytes=%d"
map.Width map.Height scale (map.Width * scale) (map.Height * scale) png.Length
printfn
"p68-tiles grass=%d water=%d stone=%d peat=%d paddy=%d vegetable=%d"
(tiles (int MapGen.GroundTile.Grass)) (tiles (int MapGen.GroundTile.Water))
(tiles (int MapGen.GroundTile.Stone)) (tiles (int MapGen.GroundTile.Peat))
(tiles (int MapGen.GroundTile.PaddyField)) (tiles (int MapGen.GroundTile.VegetablePlot))
printfn
"p68-features rivers=%d bridges=%d paths=%d buildings=%d farmhouses=%d groves=%d road_columns=%d"
map.Rivers.Length map.Bridges.Length map.Paths.Length map.Buildings.Length
map.Farmhouses.Length map.Groves.Length roadTiles
printfn "p68-render deterministic=%b sha256=%s" deterministic sha
0
[<EntryPoint>]
let main _ =
if Environment.GetEnvironmentVariable("LV_P68_MAPSHOT") = "1" then
runMapShot ()
else
use game = new LivingVillageGame()
game.Run()
0
|