## Synthetic wall scenes for the wall-count scaling bench (DESIGN 5.3 / 13 M2, H3). ## Layout: a square world of `world` px split into G x G rooms, G = ceil(sqrt(n / 2)); every room owns its EAST and SOUTH ## edge (2 candidate walls per room, west/north belong to the neighbour), so an n = 5000 scene is exactly 50 x 50 rooms. ## Each edge becomes ONE wall segment covering 55..95 % of the edge at a random offset (the rest is a doorway gap, so vision ## really passes between rooms); endpoints are jittered by up to +-6 px (no axis-aligned degeneracy); every 10th wall is a ## closed door. Generation stops after exactly n walls (row-major). Fully determined by (world, n, seed): xorshift64. ## Density: walls per vision bbox (800 x 800, radius 400) ~= 2 * (800 / pitch)^2: pitch 327.68 (world 16384) -> ~12, ## pitch 81.92 (world 4096, "dense") -> ~190. import std/math import geometry import ../tests/testutil # Rng proc genScene*(world: float, n: int, seed: uint64): seq[Wall] = var r = Rng(s: seed) let g = int(ceil(sqrt(n.float / 2))) let pitch = world / g.float proc jit(r: var Rng): float = r.uni(-6, 6) for gy in 0 ..< g: for gx in 0 ..< g: for edge in 0 .. 1: # 0 = east edge (vertical), 1 = south edge (horizontal) if result.len >= n: return let frac = r.uni(0.55, 0.95) let off = r.uni(0, 1 - frac) let (x0, y0) = (gx.float * pitch, gy.float * pitch) var a, b: Vec if edge == 0: a = (x0 + pitch + r.jit, y0 + off * pitch + r.jit); b = (x0 + pitch + r.jit, y0 + (off + frac) * pitch + r.jit) else: a = (x0 + off * pitch + r.jit, y0 + pitch + r.jit); b = (x0 + (off + frac) * pitch + r.jit, y0 + pitch + r.jit) result.add Wall(a: a, b: b, door: result.len mod 10 == 9, open: false)