FA-82506 / Chess move legality / Open access
Bishop on the king's file pins a knight · case 01
A knight between its king and an enemy bishop on the same file may not move.
ROOT CAUSE
Any enemy slider behind the piece counts as a pinner regardless of the line type.
VERIFIED REPAIR
Rooks and queens pin along ranks and files; bishops and queens along diagonals.
Unsuccessful approach: Swapping the table makes rooks pin diagonally and bishops orthogonally.
Case contract
Input: {"board", "from": square of a non-king piece, "to": its pseudo-legal destination}. Return false only when the piece is absolutely pinned (it is the first piece on a line from its own king and the next piece beyond it on that line is an enemy rook/queen on a rank or file, or bishop/queen on a diagonal) and the destination leaves that line; moves along the pin line, including capturing the pinner, return true.
Why this case matters
Move validators gate every move in engines, servers and arbiters; accepting an illegal move or rejecting a legal one corrupts the game record.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; fr,to=x['from'],x['to']; p=b[fr]; white=p.isupper()
ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
def c(s): return ord(s[0])-97,int(s[1])-1
kf,kr=c(ks); pf,pr=c(fr); tf,tr=c(to)
df,dr=pf-kf,pr-kr
if not (df==0 or dr==0 or abs(df)==abs(dr)): return True
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
cf,cr=kf+sf,kr+sr
while (cf,cr)!=(pf,pr):
if chr(97+cf)+str(cr+1) in b: return True
cf+=sf; cr+=sr
cf,cr=pf+sf,pr+sr
while 0<=cf<8 and 0<=cr<8:
v=b.get(chr(97+cf)+str(cr+1))
if v:
kinds=('r','b','q')
if v.isupper()!=white and v.lower() in kinds:
tdf,tdr=tf-kf,tr-kr
return tdf*sr==tdr*sf and tdf*sf+tdr*sr>0
return True
cf+=sf; cr+=sr
return True
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True)],
[('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('shield next to king diagonal',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'P', 'e3': 'N', 'h6': 'b'}, 'from': 'e3', 'to': 'g4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True)],
[('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False),
('not on a line',
{'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'N'}, 'from': 'f3', 'to': 'g5'}, True)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)]]
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 |
|---|---|---|---|
| file-pinned rook slides | True | True | Passed |
| file-pinned rook leaves | False | False | Passed |
| capture the pinner | True | True | Passed |
| diagonal pin knight | False | False | Passed |
| diagonal pinned bishop off line | False | False | Passed |
| diagonal pinned bishop on line | True | True | Passed |
| bishop on file is not a pinner | False | True | Failed |
| rook on diagonal is not a pinner | False | True | Failed |
SHA-256 / c596353f6ccd4a5d70295828c1835b5474f46859d7189ac157fedbed796ae9fd
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; fr,to=x['from'],x['to']; p=b[fr]; white=p.isupper()
ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
def c(s): return ord(s[0])-97,int(s[1])-1
kf,kr=c(ks); pf,pr=c(fr); tf,tr=c(to)
df,dr=pf-kf,pr-kr
if not (df==0 or dr==0 or abs(df)==abs(dr)): return True
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
cf,cr=kf+sf,kr+sr
while (cf,cr)!=(pf,pr):
if chr(97+cf)+str(cr+1) in b: return True
cf+=sf; cr+=sr
cf,cr=pf+sf,pr+sr
while 0<=cf<8 and 0<=cr<8:
v=b.get(chr(97+cf)+str(cr+1))
if v:
kinds=('b','q') if sf==0 or sr==0 else ('r','q')
if v.isupper()!=white and v.lower() in kinds:
tdf,tdr=tf-kf,tr-kr
return tdf*sr==tdr*sf and tdf*sf+tdr*sr>0
return True
cf+=sf; cr+=sr
return True
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True)],
[('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('shield next to king diagonal',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'P', 'e3': 'N', 'h6': 'b'}, 'from': 'e3', 'to': 'g4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True)],
[('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False),
('not on a line',
{'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'N'}, 'from': 'f3', 'to': 'g5'}, True)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)]]
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 |
|---|---|---|---|
| file-pinned rook slides | True | True | Passed |
| file-pinned rook leaves | True | False | Failed |
| capture the pinner | True | True | Passed |
| diagonal pin knight | True | False | Failed |
| diagonal pinned bishop off line | False | False | Passed |
| diagonal pinned bishop on line | True | True | Passed |
| bishop on file is not a pinner | False | True | Failed |
| rook on diagonal is not a pinner | False | True | Failed |
SHA-256 / 33ab351cc5108b0d1b198729492988dab8c1c51aca51af3398d3b2f5468966b7
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; fr,to=x['from'],x['to']; p=b[fr]; white=p.isupper()
ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
def c(s): return ord(s[0])-97,int(s[1])-1
kf,kr=c(ks); pf,pr=c(fr); tf,tr=c(to)
df,dr=pf-kf,pr-kr
if not (df==0 or dr==0 or abs(df)==abs(dr)): return True
sf=(df>0)-(df<0); sr=(dr>0)-(dr<0)
cf,cr=kf+sf,kr+sr
while (cf,cr)!=(pf,pr):
if chr(97+cf)+str(cr+1) in b: return True
cf+=sf; cr+=sr
cf,cr=pf+sf,pr+sr
while 0<=cf<8 and 0<=cr<8:
v=b.get(chr(97+cf)+str(cr+1))
if v:
kinds=('r','q') if sf==0 or sr==0 else ('b','q')
if v.isupper()!=white and v.lower() in kinds:
tdf,tdr=tf-kf,tr-kr
return tdf*sr==tdr*sf and tdf*sf+tdr*sr>0
return True
cf+=sf; cr+=sr
return True
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True)],
[('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('shield next to king diagonal',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'P', 'e3': 'N', 'h6': 'b'}, 'from': 'e3', 'to': 'g4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True)],
[('file-pinned rook leaves',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, False),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('own queen behind',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'Q'}, 'from': 'e4', 'to': 'c5'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False),
('not on a line',
{'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'N'}, 'from': 'f3', 'to': 'g5'}, True)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pin knight',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'b'}, 'from': 'd2', 'to': 'f3'}, False),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop to e1',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
[('file-pinned rook slides',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e6'}, True),
('capture the pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'e8'}, True),
('diagonal pinned bishop off line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'c3'}, False),
('diagonal pinned bishop on line',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'q'}, 'from': 'd2', 'to': 'e3'}, True),
('shield between king and piece',
{'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
True),
('bishop on file is not a pinner',
{'board': {'a8': 'k', 'e1': 'K', 'e4': 'N', 'e8': 'b'}, 'from': 'e4', 'to': 'c5'}, True),
('rook on diagonal is not a pinner',
{'board': {'a8': 'k', 'c1': 'K', 'd2': 'N', 'g5': 'r'}, 'from': 'd2', 'to': 'f3'}, True),
('black rank pin',
{'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)]]
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 |
|---|---|---|---|
| file-pinned rook slides | True | True | Passed |
| file-pinned rook leaves | False | False | Passed |
| capture the pinner | True | True | Passed |
| diagonal pin knight | False | False | Passed |
| diagonal pinned bishop off line | False | False | Passed |
| diagonal pinned bishop on line | True | True | Passed |
| bishop on file is not a pinner | True | True | Passed |
| rook on diagonal is not a pinner | True | True | Passed |
SHA-256 / d85a7093075687b040a01c6caa7a0eb1926ec73c9d0485f348595d63c57610b4
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:12.752619+00:00.
Case digest / 70f42874e2aa35f7a2bf0454895385a0d297d744265a175e486fbb74bf1a633d