FAILURE MAP
← Case archive

FA-82716 / Chess move legality / Open access

Undefended rook can never be captured · case 01

A lone rook next to the black king is not offered as a capture.

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

ROOT CAUSE

The rook's own square is scored as attacked by the rook.

THE FAILURE

The rook's own square is scored as attacked by the rook.

Unsuccessful approach: Allowing only diagonal captures still forbids capturing an adjacent rook on a rank or file.

Case contract

Input: {"wk", "wr", "bk"} squares (black to move). Return the sorted squares the black king may move to: on the board, not adjacent to the white king, and not attacked by the rook along a rank or file (the white king blocks the rook; the black king's origin does not). Capturing the rook is legal when the rook is not adjacent to the white king.

Why this case matters

Endgame tablebase generators and mate detectors depend on exact escape squares.

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,wr,bk=c(x['wk']),c(x['wr']),c(x['bk'])
    def rook_hits(t):
        pass
        if wr[0]!=t[0] and wr[1]!=t[1]: return False
        sf=(t[0]>wr[0])-(t[0]<wr[0]); sr=(t[1]>wr[1])-(t[1]<wr[1])
        f,r=wr[0]+sf,wr[1]+sr
        while (f,r)!=t:
            if (f,r)==wk: return False
            f+=sf; r+=sr
        return True
    out=[]
    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 max(abs(t[0]-wk[0]),abs(t[1]-wk[1]))<=1: continue
            if rook_hits(t): continue
            out.append(chr(97+t[0])+str(t[1]+1))
    return sorted(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7'])],
 [('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])]]
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
retreat along rook file['d4', 'd5', 'd6', 'f4', 'f5', 'f6']['d4', 'd5', 'd6', 'f4', 'f5', 'f6']Passed
white king shields['c4', 'c5', 'c6', 'd6', 'e5', 'e6']['c4', 'c5', 'c6', 'd6', 'e5', 'e6']Passed
capture undefended rook['d5', 'd6', 'f5', 'f6']['d5', 'd6', 'e4', 'f5', 'f6']Failed
capture defended rook['d5', 'd6', 'f5', 'f6']['d5', 'd6', 'f5', 'f6']Passed
diagonal rook capture['d5', 'd6', 'e6']['d5', 'd6', 'e6', 'f4']Failed
back rank mate[][]Passed
rank cut['c7', 'c8', 'd7', 'e7', 'e8']['c7', 'c8', 'd7', 'e7', 'e8']Passed
rook far file['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']Passed

SHA-256 / a6855ac7eaeff9f904f3dc7211ac0e8ca830d3733cf283ca03ff9535e4cb95ed

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,wr,bk=c(x['wk']),c(x['wr']),c(x['bk'])
    def rook_hits(t):
        if wr==t and t[0]!=bk[0] and t[1]!=bk[1]: return False
        if wr[0]!=t[0] and wr[1]!=t[1]: return False
        sf=(t[0]>wr[0])-(t[0]<wr[0]); sr=(t[1]>wr[1])-(t[1]<wr[1])
        f,r=wr[0]+sf,wr[1]+sr
        while (f,r)!=t:
            if (f,r)==wk: return False
            f+=sf; r+=sr
        return True
    out=[]
    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 max(abs(t[0]-wk[0]),abs(t[1]-wk[1]))<=1: continue
            if rook_hits(t): continue
            out.append(chr(97+t[0])+str(t[1]+1))
    return sorted(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])],
 [('retreat along rook file', {'bk': 'e5', 'wk': 'a1', 'wr': 'e1'},
   ['d4', 'd5', 'd6', 'f4', 'f5', 'f6']),
  ('white king shields', {'bk': 'd5', 'wk': 'e3', 'wr': 'e1'},
   ['c4', 'c5', 'c6', 'd6', 'e5', 'e6']),
  ('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7'])],
 [('capture undefended rook', {'bk': 'e5', 'wk': 'a1', 'wr': 'e4'}, ['d5', 'd6', 'e4', 'f5', 'f6']),
  ('capture defended rook', {'bk': 'e5', 'wk': 'e3', 'wr': 'e4'}, ['d5', 'd6', 'f5', 'f6']),
  ('diagonal rook capture', {'bk': 'e5', 'wk': 'a1', 'wr': 'f4'}, ['d5', 'd6', 'e6', 'f4']),
  ('back rank mate', {'bk': 'h8', 'wk': 'g6', 'wr': 'a8'}, []),
  ('rank cut', {'bk': 'd8', 'wk': 'a1', 'wr': 'h6'}, ['c7', 'c8', 'd7', 'e7', 'e8']),
  ('corner king', {'bk': 'a8', 'wk': 'c3', 'wr': 'b7'}, ['b7']),
  ('rook far file', {'bk': 'e5', 'wk': 'h1', 'wr': 'c2'},
   ['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']),
  ('shield on rank', {'bk': 'e5', 'wk': 'c6', 'wr': 'a6'}, ['d4', 'e4', 'e6', 'f4', 'f5', 'f6'])]]
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
retreat along rook file['d4', 'd5', 'd6', 'f4', 'f5', 'f6']['d4', 'd5', 'd6', 'f4', 'f5', 'f6']Passed
white king shields['c4', 'c5', 'c6', 'd6', 'e5', 'e6']['c4', 'c5', 'c6', 'd6', 'e5', 'e6']Passed
capture undefended rook['d5', 'd6', 'f5', 'f6']['d5', 'd6', 'e4', 'f5', 'f6']Failed
capture defended rook['d5', 'd6', 'f5', 'f6']['d5', 'd6', 'f5', 'f6']Passed
diagonal rook capture['d5', 'd6', 'e6', 'f4']['d5', 'd6', 'e6', 'f4']Passed
back rank mate[][]Passed
rank cut['c7', 'c8', 'd7', 'e7', 'e8']['c7', 'c8', 'd7', 'e7', 'e8']Passed
rook far file['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']['d4', 'd5', 'd6', 'e4', 'e6', 'f4', 'f5', 'f6']Passed

SHA-256 / fddc71f3ae2b6bd92ee617adc88d457a647c530b3d2c0ebb7cabcfe4b3a33b7a

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / c1667f7f1d0f95c81fba82f4bafe5d96269180298ce93a5d11d4402379ee1160