feat(walls): one-way sight per-viewer filter and ONEWAY fault (#58)
The vision fan blocks a sight-blocking one-way wall only for a viewer on its blind side (sight_dir names it; left is the (-dy,dx) normal of a->b), one sign test inline after the radius cull, so the hoisted wall list stays viewer-independent. Movement never reads the direction: one-way walls block both ways. Explored and tiles therefore differ by side and only ever grow. - geometry: WallDir + Wall.sightDir + blindTo, filter in visibilityPolygon. - worldmap: sight_dir mapping (movement mapping unchanged). - vision: the ONEWAY leak-fault build drops sight_dir player-side. - leakcheck: own side test for the fan and the clear-segment oracle; ONEWAY class detected against the sight_dir-dropped fan. - leak scenario gains a one-way wall the subject sees across; fault test asserts exactly ONEWAY. - oneway.test.mjs: both sides, tile sweep with its own oracle, flip with fixed endpoints, monotone explored/tiles, restart, two-way movement. - docs: DESIGN 5.8 mechanism sentence corrected; TESTING #58 markers built. - nginx harness: temp dirs created recursively (restart on one state dir).
This commit is contained in:
@@ -131,6 +131,28 @@ suite "visibility":
|
||||
check sees(opened, (0.0, 0.0), (90.0, 0.0))
|
||||
check not sees(opened, (0.0, 0.0), (90.0, 40.0))
|
||||
|
||||
test "one-way: sight_dir names the blind side (left is the (-dy, dx) normal)":
|
||||
# a=(0,0) -> b=(0,100): the left normal (-dy, dx) = (-100, 0) points west.
|
||||
let left = @[W(0, 0, 0, 100, sightDir = wdLeft)]
|
||||
check not sees(left, (-50.0, 50.0), (50.0, 50.0)) # viewer on the blind (west) side
|
||||
check sees(left, (50.0, 50.0), (-50.0, 50.0)) # positive control: the east side sees across
|
||||
let right = @[W(0, 0, 0, 100, sightDir = wdRight)]
|
||||
check sees(right, (-50.0, 50.0), (50.0, 50.0))
|
||||
check not sees(right, (50.0, 50.0), (-50.0, 50.0))
|
||||
|
||||
test "one-way: flipping the direction swaps the blind side and moves nothing":
|
||||
var w = @[W(0, 0, 0, 100, sightDir = wdLeft)]
|
||||
check not sees(w, (-50.0, 50.0), (50.0, 50.0))
|
||||
w[0].sightDir = wdRight
|
||||
check (w[0].a, w[0].b) == ((0.0, 0.0), (0.0, 100.0))
|
||||
check sees(w, (-50.0, 50.0), (50.0, 50.0))
|
||||
check not sees(w, (50.0, 50.0), (-50.0, 50.0))
|
||||
|
||||
test "one-way: an open door blocks neither side whatever the direction says":
|
||||
let door = @[W(0, 0, 0, 100, door = true, open = true, sightDir = wdLeft)]
|
||||
check sees(door, (-50.0, 50.0), (50.0, 50.0))
|
||||
check sees(door, (50.0, 50.0), (-50.0, 50.0))
|
||||
|
||||
test "token exactly at wall endpoint":
|
||||
let w = @[W(0, 0, 100, 0), W(0, 0, 0, 100)] # corner, token on it
|
||||
let poly = visibilityPolygon((0.0, 0.0), w, 200)
|
||||
|
||||
Reference in New Issue
Block a user