feat(walls): windows — see-through barrier, movement follows blocks_movement (#57)

- geometry.Wall carries the stored blocks_sight/blocks_movement switches; sight asks
  blocksSight, movement and the status rules ask blocks (open door passes both).
- worldmap translates both switches; moverules only pushes on a movement barrier.
- leakcheck and the tile oracle read blocks_sight independently.
- Walls/token-details/tiles groups prove both forms, sight-through, stuck, push and
  the locked-window open refusal; existing scenes stay byte-identical.

Ref #57

# Conflicts:
#	server/geometry.nim
#	server/world.nim
#	server/worldmap.nim
#	tools/leakcheck.nim
This commit is contained in:
2026-11-19 23:09:05 +01:00
parent cc566ee16e
commit e989100f50
9 changed files with 226 additions and 36 deletions
+15 -2
View File
@@ -28,15 +28,28 @@ type
wdRight = "right"
Wall* = object
## The wall as geometry sees it. The two barrier fields are the stored switches (#57): a
## `window` stores `sightBarrier:false, movementBarrier:true`, so sight passes along its whole
## drawn length while movement and the status rules still treat it as a barrier. An open door
## passes both ways whatever the switches say (DESIGN 5.8). Both default to `true` so a wall
## built without switches (tests, fixtures) keeps the historic solid-wall behaviour.
a*, b*: Vec
door*, open*: bool
sightDir*: WallDir
sightBarrier*: bool = true
movementBarrier*: bool = true
const
Eps* = 1e-9 # geometric tolerance (px)
RayEps = 1e-4 # angular nudge past endpoints (rad)
proc blocks*(w: Wall): bool = not (w.door and w.open)
proc blocks*(w: Wall): bool =
## The movement rule: a wall blocks movement unless it is an open door or its switch is off.
w.movementBarrier and not (w.door and w.open)
proc blocksSight*(w: Wall): bool =
## The sight rule: a wall blocks sight unless it is an open door or its switch is off.
w.sightBarrier and not (w.door and w.open)
proc cross*(a, b: Vec): float = a.x * b.y - a.y * b.x
proc `-`*(a, b: Vec): Vec = (a.x - b.x, a.y - b.y)
@@ -76,7 +89,7 @@ proc visibilityPolygon*(o: Vec, walls: openArray[Wall], radius: float,
(o.x + radius * cos a1, o.y + radius * sin a1)))
angles.add arctan2(sin a0, cos a0) # same (-pi,pi] range as the wall angles, else the sort scrambles the fan
for w in walls:
if not w.blocks: continue
if not w.blocksSight: continue
# shortcut: walls beyond the circle are only culled by ray clipping, O(rays*walls); upgrade: spatial grid
if max(w.a.x, w.b.x) < o.x - radius or min(w.a.x, w.b.x) > o.x + radius or
max(w.a.y, w.b.y) < o.y - radius or min(w.a.y, w.b.y) > o.y + radius: continue
+13 -10
View File
@@ -279,16 +279,19 @@ proc setDoor*(sc: var Scene, id: int, open: bool, pushed: var seq[Push]): bool =
else:
sc.walls[id].open = false
let w = sc.walls[id]
for i in 0 ..< sc.tokens.len:
if not overlaps(sc, sc.tokens[i], w): continue
let (ok, p) = pushFrom(sc, sc.tokens[i], w)
if ok:
sc.tokens[i].prev = sc.tokens[i].pos; sc.tokens[i].hasPrev = true
sc.tokens[i].pos = p
sc.tokens[i].clearWalls() # a pushed token is clear of every blocking wall
pushed.add Push(ti: i, pos: p)
else:
sc.tokens[i].squeezedWalls = true
# Only a wall that blocks movement pushes: closing a see-through opening window is a solid
# barrier and pushes; a door whose movement switch is off (a custom shape) does not (#57).
if w.blocks:
for i in 0 ..< sc.tokens.len:
if not overlaps(sc, sc.tokens[i], w): continue
let (ok, p) = pushFrom(sc, sc.tokens[i], w)
if ok:
sc.tokens[i].prev = sc.tokens[i].pos; sc.tokens[i].hasPrev = true
sc.tokens[i].pos = p
sc.tokens[i].clearWalls() # a pushed token is clear of every blocking wall
pushed.add Push(ti: i, pos: p)
else:
sc.tokens[i].squeezedWalls = true
true
proc setDoor*(sc: var Scene, id: int, open: bool): bool =
+4 -4
View File
@@ -4,10 +4,10 @@
##
## Walls (DESIGN 8, FIXED #3): per-scene ids from `scene.next_wall_id`, monotonic and never reused
## (a removal leaves the counter alone). Identity is `(scene, id)` in the DB, in memory and on the
## wire. A wall's sight/movement behaviour is still `blocks = not (door and open)` in
## geometry.Wall plus the per-viewer one-way filter (`sight_dir`, #58); `blocks_sight` and
## `blocks_movement` gain their general behaviour in the window/movement round (#57). `flags` is a
## free JSON object the server never interprets.
## wire. A wall's behaviour is its stored switches: `blocks_sight` drives the vision fan and
## `blocks_movement` drives the move rules and the walls-sourced statuses, and an open door passes
## both (geometry.Wall, #57). `sight_dir` filters sight per viewer (the blind side, #58). `flags` is
## a free JSON object the server never interprets.
##
## Wire payload shapes are DESIGN 6.1; the parts it leaves open are fixed here (recorded FIXED
## owner-delegated, #19, in DESIGN 6.1/14):
+11 -8
View File
@@ -18,26 +18,29 @@ import std/options
import geometry, moverules, tokens, world, faults
proc geometryWalls*(sc: SceneRec, forSight = false): seq[Wall] =
## The scene's walls as the vision code sees them: an open door does not block (5.1), and a
## one-way wall carries the side that is blind (5.8, #58). Movement gets the same mapping and
## ignores `sightDir` (two-way).
## `forSight` is only the sight computation; `LEAK_FAULT=secretgap` (a -d:leakfault build only)
## opens a secret door there, the negative control for the door-equivalence group (#56).
## The scene's walls as the vision and move code see them. Each wall carries its stored switches:
## the sight fan asks `blocksSight` (and the one-way `sightDir`, 5.8/#58), the move rules and the
## statuses ask `blocks`, so a window is see-through but still a barrier to movement (#57). Every
## wall stays in the list, in scene order: `moverules` addresses walls by that index. `forSight`
## is only the sight computation; `LEAK_FAULT=secretgap` (a -d:leakfault build only) opens a
## secret door there, the negative control for the door-equivalence group (#56).
result = newSeqOfCap[Wall](sc.walls.len)
for w in sc.walls:
let dir = case w.sightDir
of sdBoth: wdBoth
of sdLeft: wdLeft
of sdRight: wdRight
var wall = Wall(a: w.a, b: w.b, door: w.door, open: w.open, sightDir: dir)
var wall = Wall(a: w.a, b: w.b, door: w.door, open: w.open, sightDir: dir,
sightBarrier: w.blocksSight, movementBarrier: w.blocksMovement)
if forSight and w.secret and faultActive("secretgap"):
wall.open = true
result.add wall
proc ruleWall*(w: WallRec): Wall =
## The same wall as the move rules see it (they need `door`/`open` to know what blocks; the
## The same wall as the move rules see it (they need the movement switch and `door`/`open`; the
## one-way direction is sight-only and never read by the move rules, so it is not mapped).
Wall(a: w.a, b: w.b, door: w.door, open: w.open)
Wall(a: w.a, b: w.b, door: w.door, open: w.open,
sightBarrier: w.blocksSight, movementBarrier: w.blocksMovement)
proc ruleToken*(sc: SceneRec, t: TokenRec): moverules.Token =
moverules.Token(pos: t.pos, owner: t.owner,