FAILURE MAP
← Case archive

FA-82496 / Chess move legality / Open access

Diagonal pins are never detected · case 01

A knight pinned by a bishop against its king is allowed to jump away.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Only pieces on the king's rank or file are considered pin candidates.

VERIFIED REPAIR

Pins exist along ranks, files and diagonals.

Unsuccessful approach: Considering only diagonals now misses rank and file pins.

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): 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),
  ('shield between king and piece',
   {'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
   True),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('file-pinned rook leaves',
   {'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, 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),
  ('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),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('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 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),
  ('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),
  ('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),
  ('diagonal pinned bishop to e1',
   {'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
  ('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),
  ('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 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),
  ('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),
  ('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 fixtureActualExpectedOutcome
file-pinned rook slidesTrueTruePassed
file-pinned rook leavesFalseFalsePassed
capture the pinnerTrueTruePassed
diagonal pin knightTrueFalseFailed
diagonal pinned bishop off lineTrueFalseFailed
diagonal pinned bishop on lineTrueTruePassed
shield between king and pieceTrueTruePassed
black rank pinFalseFalsePassed

SHA-256 / 0282d39767ed5c956b61f9cc2f345ba15cee85cde729e32e1393a42841f379df

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 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),
  ('shield between king and piece',
   {'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
   True),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('file-pinned rook leaves',
   {'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, 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),
  ('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),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('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 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),
  ('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),
  ('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),
  ('diagonal pinned bishop to e1',
   {'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
  ('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),
  ('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 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),
  ('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),
  ('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 fixtureActualExpectedOutcome
file-pinned rook slidesTrueTruePassed
file-pinned rook leavesTrueFalseFailed
capture the pinnerTrueTruePassed
diagonal pin knightFalseFalsePassed
diagonal pinned bishop off lineFalseFalsePassed
diagonal pinned bishop on lineTrueTruePassed
shield between king and pieceTrueTruePassed
black rank pinTrueFalseFailed

SHA-256 / 627b6ea8104e5c7a5e12df2011e7e8908ee9fe8408e263d2a0f692396cd62342

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),
  ('shield between king and piece',
   {'board': {'a8': 'k', 'e1': 'K', 'e2': 'P', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'},
   True),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('file-pinned rook leaves',
   {'board': {'a8': 'k', 'e1': 'K', 'e4': 'R', 'e8': 'r'}, 'from': 'e4', 'to': 'a4'}, 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),
  ('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),
  ('black rank pin',
   {'board': {'a1': 'K', 'a8': 'R', 'e8': 'n', 'h8': 'k'}, 'from': 'e8', 'to': 'd6'}, False)],
 [('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 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),
  ('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),
  ('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),
  ('diagonal pinned bishop to e1',
   {'board': {'a8': 'k', 'c1': 'K', 'd2': 'B', 'g5': 'b'}, 'from': 'd2', 'to': 'e1'}, False),
  ('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),
  ('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 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),
  ('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),
  ('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 fixtureActualExpectedOutcome
file-pinned rook slidesTrueTruePassed
file-pinned rook leavesFalseFalsePassed
capture the pinnerTrueTruePassed
diagonal pin knightFalseFalsePassed
diagonal pinned bishop off lineFalseFalsePassed
diagonal pinned bishop on lineTrueTruePassed
shield between king and pieceTrueTruePassed
black rank pinFalseFalsePassed

SHA-256 / 288113bf40da11cfda7620214bd692a9ed460ffd081dd10a8fe55d18649ec4a9

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.706966+00:00.

Case digest / c4d14c6ba6b27600885da400e91a6da94aae7868b9ac1bbdad951f07696e1a7f