Files
FFF_vtt_frozen/tests/refold.nim
T
SirStone fcd90529b6 test(m4): finish audit, measurement and archive (#76)
- client/e2e/audit.test.mjs: independent player-browser traffic audit (own
  frame catalogue and banned-key list, never leakcheck.nim), with a
  -d:leakfault/otherVision negative control.
- client/e2e/fogbench.test.mjs + tools/fogbench.nim: 50 tokens on a
  16384 px map (server move path and headless SwiftShader cadence);
  results/m4-fog-bench.md records both honestly (SW is not the phone gate).
- Archive prototype-* under docs/archive/prototypes (Q24); DESIGN 13 M4
  done, TESTING 13 M4 accept result, HANDOFF-M4 close-out.
- mutation.sh c1/c2 patch the post-#65 tile-gate line again (they had
  silently become sed no-ops).
2026-11-21 15:43:08 +01:00

34 lines
1.8 KiB
Nim

## TEST-ONLY reference: the prototype implementations that M2 replaced, kept verbatim (renamed) as differential oracles.
## Never imported by server code. Source: docs/archive/prototypes/server-vision/src/geometry.nim (M1 port).
import std/math
import geometry
proc cellsTouchedOld*(poly: openArray[Vec], cell: float): seq[(int, int)] =
## per-cell polygon test (O(cells x edges)); grid cells overlapped by the polygon, sorted by (iy, ix).
## Quirk kept on purpose: the bbox loop starts at floor(min/cell), so a cell that only touches the polygon's
## bbox minimum edge (min exactly on a cell line) is not visited; every other touch is inclusive.
if poly.len < 3: return
var x0, y0 = Inf
var x1, y1 = -Inf
for p in poly:
x0 = min(x0, p.x); x1 = max(x1, p.x); y0 = min(y0, p.y); y1 = max(y1, p.y)
for iy in int(floor(y0 / cell)) .. int(floor(y1 / cell)):
for ix in int(floor(x0 / cell)) .. int(floor(x1 / cell)):
let (cx0, cy0, cx1, cy1) = (ix.float * cell, iy.float * cell, (ix + 1).float * cell, (iy + 1).float * cell)
let c = [(cx0, cy0), (cx1, cy0), (cx1, cy1), (cx0, cy1)]
var hit = inside(poly, c[0]) or
(poly[0].x >= cx0 and poly[0].x <= cx1 and poly[0].y >= cy0 and poly[0].y <= cy1)
if not hit:
for i in 0 ..< poly.len:
let p = poly[i]; let q = poly[(i + 1) mod poly.len]
for k in 0 .. 3:
if segsCross(p, q, c[k], c[(k + 1) mod 4]): hit = true; break
if hit: break
if hit: result.add (ix, iy)
proc moveBlockedOld*(walls: openArray[Wall], a, b: Vec, r = 0.0): bool =
## prototype move check: centre path a->b (inclusive crossing) + destination circle only. Used as a LOS oracle
## (r = 0) by tests; its policy was replaced by server/moverules.nim.
for w in walls:
if w.blocks and (segsCross(a, b, w.a, w.b) or segDist(b, w.a, w.b) < r): return true