moverules: blocked policy set/keep/clear (GM moves and placements set/clear, KEEP while any wall overlaps); tests; mutations k, l

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 18:47:39 +01:00
co-authored by Claude Sonnet 5.5
parent 0e0b1a6052
commit 388e901541
4 changed files with 116 additions and 34 deletions
+91 -21
View File
@@ -162,7 +162,7 @@ suite "move rules: player vs GM, step cap, uniform nack":
check s.moveToken(gm, 0, (200.0, 500.0)).kind == mkAck # onto the wall
check s.moveToken(gm, 0, (-1.0, 0.0)) == MoveResult(kind: mkNack, pos: (200.0, 500.0))
check s.moveToken(gm, 0, (5000.0, 0.0)).kind == mkNack
check s.tokens[0].blocked # GM moves never touch the flag
check s.tokens[0].blocked # ended on the wall: GM move set the flag
check s.moveToken(gm, 9, (1.0, 1.0)).kind == mkError
suite "blocked flag":
@@ -186,13 +186,13 @@ suite "blocked flag":
check not s.tokens[0].blocked
check s.setDoor(id, false)
check s.tokens[0].blocked
test "blocked token: player moves refused, GM move allowed and does not clear":
test "blocked token: player moves refused, GM move allowed":
var s = blockedSc()
discard s.addWall(W(110, 0, 110, 200))
check s.moveToken(me, 0, (40.0, 100.0)).kind == mkNack # would be a perfectly clear step
check s.tokens[0].pos == (100.0, 100.0)
check s.moveToken(gm, 0, (40.0, 100.0)).kind == mkAck
check s.tokens[0].blocked
check s.moveToken(gm, 0, (40.0, 100.0)).kind == mkAck # GM bypasses `blocked`
check not s.tokens[0].blocked # and landed clear of every wall: cleared
test "cleared by removing the wall; unrelated removals keep it":
var s = blockedSc()
let a = s.addWall(W(110, 0, 110, 200))
@@ -231,42 +231,112 @@ suite "blocked flag":
check s.updateWall(id, W(110, 0, 110, 200, door = true, open = true)) # became an open door: clears
check not s.tokens[0].blocked
check not s.updateWall(9, W(0, 0, 1, 1))
test "GM placement and GM move onto a wall never set blocked, and the token can escape":
test "GM placement and GM move onto a wall: blocked; player escape works only after a GM clear":
var s = scene(@[W(500, 0, 500, 1000)])
let i = s.addToken(tok(500, 400)) # placed exactly on the wall
check not s.tokens[i].blocked
check s.moveToken(me, i, (530.0, 400.0)).kind == mkAck # escape works (was the KNOWN LIMITATION)
check s.tokens[i].blocked
check s.moveToken(me, i, (530.0, 400.0)).kind == mkNack # stuck
s.gmClearBlocked(i)
check s.moveToken(me, i, (530.0, 400.0)).kind == mkAck # escape sideways
check s.moveToken(gm, i, (505.0, 400.0)).kind == mkAck # GM puts it back within r
check not s.tokens[i].blocked
check s.tokens[i].blocked
s.gmClearBlocked(i)
check s.moveToken(me, i, (505.0, 450.0)).kind == mkNack # still overlapped: refused
check s.moveToken(me, i, (540.0, 400.0)).kind == mkAck # but it can leave
test "Q14: a door closed 10 px from a token: token blocked, player refused, GM moves it, opening frees it":
test "Q14: a door closed 10 px from a token: token blocked, player refused, GM moves it clear, opening frees it":
var s = scene(@[], @[tok(110, 100)])
let id = s.addWall(W(100, 50, 100, 150, door = true, open = true))
check s.setDoor(id, false)
check s.tokens[0].blocked
check s.moveToken(me, 0, (140.0, 100.0)).kind == mkNack
check s.moveToken(gm, 0, (60.0, 100.0)).kind == mkAck # through the closed door
check s.tokens[0].blocked # GM moved it off the door; the bool flag cannot say which wall set it
check s.setDoor(id, true)
check s.tokens[0].blocked # GAP: opening clears only tokens still overlapping that door
s.gmClearBlocked(0)
check s.moveToken(gm, 0, (60.0, 100.0)).kind == mkAck # through the closed door, ends clear of every wall
check not s.tokens[0].blocked
check s.setDoor(id, false) # closing on nobody sets nothing
check s.setDoor(id, true) and s.setDoor(id, false) # closing on nobody sets nothing
check not s.tokens[0].blocked
s.tokens[0].pos = (110.0, 100.0)
check s.setDoor(id, true) and s.setDoor(id, false) # token back on the door: set again, then opening frees it
check s.setDoor(id, true) and s.setDoor(id, false) # token back on the door: set, then opening frees it
check s.tokens[0].blocked
check s.setDoor(id, true)
check not s.tokens[0].blocked
test "unconfirmed (b), pinned: opening a door clears blocked although another closed wall still overlaps":
test "doorway: token in an open doorway, door closes -> blocked, door opens -> free":
var s = scene(@[], @[tok(100, 100)])
discard s.addWall(W(110, 0, 110, 200)) # plain wall, overlaps
let id = s.addWall(W(100, 0, 100, 200, door = true)) # closed door, overlaps
let id = s.addWall(W(100, 50, 100, 150, door = true, open = true))
check not s.tokens[0].blocked
check s.setDoor(id, false)
check s.tokens[0].blocked
check s.moveToken(me, 0, (140.0, 100.0)).kind == mkNack
check s.setDoor(id, true)
check not s.tokens[0].blocked # literal Q14; DESIGN 5.5 lists this as unconfirmed
check s.moveToken(me, 0, (100.0, 150.0)).kind == mkNack # but the capsule still refuses an overlapped destination
check not s.tokens[0].blocked
check s.moveToken(me, 0, (140.0, 100.0)).kind == mkAck
test "KEEP: opening one door / removing one wall while another overlaps -> still blocked; last one frees":
var s = scene(@[], @[tok(100, 100)])
let a = s.addWall(W(110, 0, 110, 200))
let door = s.addWall(W(100, 0, 100, 200, door = true))
check s.tokens[0].blocked
check s.setDoor(door, true)
check s.tokens[0].blocked # plain wall still overlaps
check s.moveToken(me, 0, (40.0, 100.0)).kind == mkNack
check s.removeWall(a)
check not s.tokens[0].blocked
var t = scene(@[], @[tok(100, 100)])
let x = t.addWall(W(110, 0, 110, 200))
let y = t.addWall(W(90, 0, 90, 200))
check t.removeWall(y)
check t.tokens[0].blocked
check t.removeWall(x)
check not t.tokens[0].blocked
test "KEEP: wall update away from one of two overlapping walls keeps blocked":
var s = scene(@[], @[tok(100, 100)])
let a = s.addWall(W(110, 0, 110, 200))
let b = s.addWall(W(90, 0, 90, 200))
check s.updateWall(b, W(500, 0, 500, 200))
check s.tokens[0].blocked
check s.updateWall(a, W(500, 0, 500, 100))
check not s.tokens[0].blocked
test "GM moves a stuck token clear -> free; to another wall-overlapping spot -> still blocked":
var s = scene(@[W(110, 0, 110, 200), W(500, 0, 500, 200)], @[])
let i = s.addToken(tok(100, 100))
check s.tokens[i].blocked
check s.moveToken(gm, i, (505.0, 100.0)).kind == mkAck
check s.tokens[i].blocked # other wall overlaps
check s.moveToken(gm, i, (300.0, 100.0)).kind == mkAck
check not s.tokens[i].blocked
check s.moveToken(me, i, (330.0, 100.0)).kind == mkAck
test "GM drops a token inside a wall -> blocked; a door counts only while closed":
var s = scene(@[W(110, 0, 110, 200, door = true, open = true)], @[tok(300, 300), tok(100, 100)])
check not s.tokens[1].blocked
check s.moveToken(gm, 0, (100.0, 100.0)).kind == mkAck
check not s.tokens[0].blocked # open door: no wall
check s.setDoor(0, false)
check s.tokens[0].blocked and s.tokens[1].blocked
check s.setDoor(0, true)
check not s.tokens[0].blocked and not s.tokens[1].blocked
var t = scene(@[W(110, 0, 110, 200)], @[tok(300, 300)])
check t.moveToken(gm, 0, (100.0, 100.0)).kind == mkAck
check t.tokens[0].blocked
test "GM manual clear inside a wall: player escapes sideways, cannot cross":
var s = scene(@[W(500, 0, 500, 1000)], @[tok(500, 400)])
check s.moveToken(gm, 0, (505.0, 400.0)).kind == mkAck
check s.tokens[0].blocked
s.gmClearBlocked(0)
check not s.tokens[0].blocked
check s.moveToken(me, 0, (530.0, 400.0)).kind == mkAck # sideways out
var t = scene(@[W(500, 0, 500, 1000)], @[tok(505, 400)])
t.gmClearBlocked(0)
check t.moveToken(me, 0, (470.0, 400.0)).kind == mkNack # across the wall
check t.moveToken(me, 0, (510.0, 450.0)).kind == mkNack # destination still overlapping
test "an unrelated wall change elsewhere does not re-block a GM-cleared token":
var s = scene(@[W(110, 0, 110, 200)], @[tok(100, 100)])
s.tokens[0].blocked = true
s.gmClearBlocked(0)
let far = s.addWall(W(2000, 0, 2000, 200))
check not s.tokens[0].blocked
check s.updateWall(far, W(2100, 0, 2100, 200))
check s.removeWall(far)
check not s.tokens[0].blocked
let d = s.addWall(W(3000, 0, 3000, 200, door = true))
check s.setDoor(d, true) and s.setDoor(d, false)
check not s.tokens[0].blocked
suite "seed scene":
test "no escape hatch: a player cannot walk through any wall of a boxed room":