FA-82781 / Chess move legality / Open access
King may retreat along the queen's line · case 01
A black king on d7 checked from d1 is allowed to step to d8.
ROOT CAUSE
The black king's origin square is treated as a shield when testing its own escape squares.
VERIFIED REPAIR
Only the white king blocks the queen; the black king has left its origin.
Unsuccessful approach: Ignoring every blocker makes the white king transparent to the queen.
Case contract
Input: {"wk", "wq", "bk"} squares, black to move. Return "checkmate" if black has no legal king move and is attacked by the queen, "stalemate" if it has none and is not attacked, else "ongoing". The queen attacks along ranks, files and diagonals and is blocked only by the white king; the black king may capture the queen when it is not adjacent to the white king.
Why this case matters
Game-end detection must distinguish mate from stalemate exactly.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def c(q): return ord(q[0])-97,int(q[1])-1
wk,wq,bk=c(x['wk']),c(x['wq']),c(x['bk'])
def queen_hits(t, occupied):
if t==wq: return False
df,dr=t[0]-wq[0],t[1]-wq[1]
if not (df==0 or dr==0 or abs(df)==abs(dr)): return False
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
f,r=wq[0]+sf,wq[1]+sr
while (f,r)!=t:
if (f,r) in occupied: return False
f+=sf; r+=sr
return True
def near(a,b2): return max(abs(a[0]-b2[0]),abs(a[1]-b2[1]))<=1
in_check=queen_hits(bk,{wk})
moves=0
for df in (-1,0,1):
for dr in (-1,0,1):
if not (df or dr): continue
t=(bk[0]+df,bk[1]+dr)
if not (0<=t[0]<8 and 0<=t[1]<8): continue
if near(t,wk): continue
if queen_hits(t,set()): continue
moves+=1
if moves: return 'ongoing'
return 'checkmate' if in_check else 'stalemate'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')],
[('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('shielded by king', {'bk': 'e5', 'wk': 'e3', 'wq': 'e1'}, 'ongoing'),
('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate')],
[('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate'),
('orthogonal free capture', {'bk': 'a8', 'wk': 'h1', 'wq': 'a7'}, 'ongoing'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| corner stalemate | stalemate | stalemate | Passed |
| queen kiss mate | checkmate | checkmate | Passed |
| back rank long mate | checkmate | checkmate | Passed |
| capture free queen | ongoing | ongoing | Passed |
| queen check escape | ongoing | ongoing | Passed |
| queen behind white king | stalemate | ongoing | Failed |
| mate with rank retreat | checkmate | checkmate | Passed |
| queen kiss far side | checkmate | checkmate | Passed |
SHA-256 / ab8ea20ef261e392c18fba2dd2e09071759b48188ba3010752cdeae6cd4265ac
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def c(q): return ord(q[0])-97,int(q[1])-1
wk,wq,bk=c(x['wk']),c(x['wq']),c(x['bk'])
def queen_hits(t, occupied):
if t==wq: return False
df,dr=t[0]-wq[0],t[1]-wq[1]
if not (df==0 or dr==0 or abs(df)==abs(dr)): return False
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
f,r=wq[0]+sf,wq[1]+sr
while (f,r)!=t:
if (f,r) in occupied: return False
f+=sf; r+=sr
return True
def near(a,b2): return max(abs(a[0]-b2[0]),abs(a[1]-b2[1]))<=1
in_check=queen_hits(bk,{wk})
moves=0
for df in (-1,0,1):
for dr in (-1,0,1):
if not (df or dr): continue
t=(bk[0]+df,bk[1]+dr)
if not (0<=t[0]<8 and 0<=t[1]<8): continue
if near(t,wk): continue
if queen_hits(t,{wk,bk}): continue
moves+=1
if moves: return 'ongoing'
return 'checkmate' if in_check else 'stalemate'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')],
[('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('shielded by king', {'bk': 'e5', 'wk': 'e3', 'wq': 'e1'}, 'ongoing'),
('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate')],
[('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate'),
('orthogonal free capture', {'bk': 'a8', 'wk': 'h1', 'wq': 'a7'}, 'ongoing'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| corner stalemate | stalemate | stalemate | Passed |
| queen kiss mate | checkmate | checkmate | Passed |
| back rank long mate | checkmate | checkmate | Passed |
| capture free queen | ongoing | ongoing | Passed |
| queen check escape | ongoing | ongoing | Passed |
| queen behind white king | ongoing | ongoing | Passed |
| mate with rank retreat | ongoing | checkmate | Failed |
| queen kiss far side | ongoing | checkmate | Failed |
SHA-256 / 766ae63e279ce7397f441c0d5fba26260490f90f5ebac0aa5e53377249643e32
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def c(q): return ord(q[0])-97,int(q[1])-1
wk,wq,bk=c(x['wk']),c(x['wq']),c(x['bk'])
def queen_hits(t, occupied):
if t==wq: return False
df,dr=t[0]-wq[0],t[1]-wq[1]
if not (df==0 or dr==0 or abs(df)==abs(dr)): return False
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
f,r=wq[0]+sf,wq[1]+sr
while (f,r)!=t:
if (f,r) in occupied: return False
f+=sf; r+=sr
return True
def near(a,b2): return max(abs(a[0]-b2[0]),abs(a[1]-b2[1]))<=1
in_check=queen_hits(bk,{wk})
moves=0
for df in (-1,0,1):
for dr in (-1,0,1):
if not (df or dr): continue
t=(bk[0]+df,bk[1]+dr)
if not (0<=t[0]<8 and 0<=t[1]<8): continue
if near(t,wk): continue
if queen_hits(t,{wk}): continue
moves+=1
if moves: return 'ongoing'
return 'checkmate' if in_check else 'stalemate'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')],
[('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('shielded by king', {'bk': 'e5', 'wk': 'e3', 'wq': 'e1'}, 'ongoing'),
('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate')],
[('stalemate h-file', {'bk': 'h8', 'wk': 'f7', 'wq': 'g6'}, 'stalemate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('edge mate', {'bk': 'e8', 'wk': 'e6', 'wq': 'e7'}, 'checkmate'),
('orthogonal free capture', {'bk': 'a8', 'wk': 'h1', 'wq': 'a7'}, 'ongoing'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate'),
('far queen ongoing', {'bk': 'd5', 'wk': 'a1', 'wq': 'h2'}, 'ongoing'),
('king retreat along queen file', {'bk': 'd7', 'wk': 'a1', 'wq': 'd1'}, 'ongoing')],
[('corner stalemate', {'bk': 'a8', 'wk': 'c6', 'wq': 'b6'}, 'stalemate'),
('queen kiss mate', {'bk': 'a8', 'wk': 'b6', 'wq': 'b7'}, 'checkmate'),
('back rank long mate', {'bk': 'h8', 'wk': 'g6', 'wq': 'a8'}, 'checkmate'),
('capture free queen', {'bk': 'a8', 'wk': 'h1', 'wq': 'b7'}, 'ongoing'),
('queen check escape', {'bk': 'e5', 'wk': 'a1', 'wq': 'e1'}, 'ongoing'),
('queen behind white king', {'bk': 'a1', 'wk': 'b3', 'wq': 'b5'}, 'ongoing'),
('mate with rank retreat', {'bk': 'b1', 'wk': 'a3', 'wq': 'd1'}, 'checkmate'),
('queen kiss far side', {'bk': 'b8', 'wk': 'a6', 'wq': 'd8'}, 'checkmate')]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| corner stalemate | stalemate | stalemate | Passed |
| queen kiss mate | checkmate | checkmate | Passed |
| back rank long mate | checkmate | checkmate | Passed |
| capture free queen | ongoing | ongoing | Passed |
| queen check escape | ongoing | ongoing | Passed |
| queen behind white king | ongoing | ongoing | Passed |
| mate with rank retreat | checkmate | checkmate | Passed |
| queen kiss far side | checkmate | checkmate | Passed |
SHA-256 / 06dbcde51faee81c55bc187df114e7cdd982bc4e92d05701866e226125634cc0
Verification & scope
A deterministic toy model with an explicitly stated contract; boards are {square: piece} with white upper-case and black lower-case pieces; no claim of full FIDE Laws conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:15.332768+00:00.
Case digest / d34ef52e34a3ca916ec3cdda9b99088e31bc3b39537fa2d979ad0eb2a68a96be