FAILURE MAP
← Case archive

FA-82486 / Chess move legality / Open access

King captures a defended piece · case 01

The king takes a pawn on e5 that is protected by another pawn.

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

ROOT CAUSE

Captures return early as legal without the attack test on the destination.

VERIFIED REPAIR

Capturing moves need the same safety test as quiet moves.

Unsuccessful approach: Exempting pawn captures from the shortcut still waves through defended pieces of other types.

Case contract

Input: {"board", "from": king square, "to": square}. Return true when the king move is legal: exactly one square in any direction, not onto a friendly piece, and the destination is not attacked by the opponent (including the enemy king) once the king has left its origin square. Captures of undefended enemy pieces are allowed.

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):
    def attacked(bd, sq, by_white):
        f,r=ord(sq[0])-97,int(sq[1])-1
        def at(ff,rr):
            return bd.get(chr(97+ff)+str(rr+1)) if 0<=ff<8 and 0<=rr<8 else None
        P,N,B,R,Q,K=('PNBRQK' if by_white else 'pnbrqk')
        pr=r-1 if by_white else r+1
        if at(f-1,pr)==P or at(f+1,pr)==P: return True
        for df,dr in ((1,2),(2,1),(-1,2),(-2,1),(1,-2),(2,-1),(-1,-2),(-2,-1)):
            if at(f+df,r+dr)==N: return True
        for df in (-1,0,1):
            for dr in (-1,0,1):
                if (df or dr) and at(f+df,r+dr)==K: return True
        for df,dr,kinds in ((1,0,(R,Q)),(-1,0,(R,Q)),(0,1,(R,Q)),(0,-1,(R,Q)),(1,1,(B,Q)),(1,-1,(B,Q)),(-1,1,(B,Q)),(-1,-1,(B,Q))):
            ff,rr=f+df,r+dr
            while 0<=ff<8 and 0<=rr<8:
                v=at(ff,rr)
                if v:
                    if v in kinds: return True
                    break
                ff+=df; rr+=dr
        return False
    
    b=x['board']; fr,to=x['from'],x['to']; k=b[fr]; white=k=='K'
    df=ord(to[0])-ord(fr[0]); dr=int(to[1])-int(fr[1])
    if max(abs(df),abs(dr))!=1: return False
    occ=b.get(to)
    if occ and occ.isupper()!=white: return True
    if occ and occ.isupper()==white: return False
    nb=dict(b); del nb[fr]; nb[to]=k
    return not attacked(nb, to, not white)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture undefended', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'},
   True),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)]]
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 fileFalseFalsePassed
sidestep rook fileTrueTruePassed
diagonal stepTrueTruePassed
stand stillFalseFalsePassed
capture ownFalseFalsePassed
capture defendedTrueFalseFailed
capture along check lineTrueFalseFailed
capture defended knightTrueFalseFailed

SHA-256 / 49baa7df8dee389d6a7a0f2c4678987090ada99be14b67ae870ffbf67de67ccf

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    def attacked(bd, sq, by_white):
        f,r=ord(sq[0])-97,int(sq[1])-1
        def at(ff,rr):
            return bd.get(chr(97+ff)+str(rr+1)) if 0<=ff<8 and 0<=rr<8 else None
        P,N,B,R,Q,K=('PNBRQK' if by_white else 'pnbrqk')
        pr=r-1 if by_white else r+1
        if at(f-1,pr)==P or at(f+1,pr)==P: return True
        for df,dr in ((1,2),(2,1),(-1,2),(-2,1),(1,-2),(2,-1),(-1,-2),(-2,-1)):
            if at(f+df,r+dr)==N: return True
        for df in (-1,0,1):
            for dr in (-1,0,1):
                if (df or dr) and at(f+df,r+dr)==K: return True
        for df,dr,kinds in ((1,0,(R,Q)),(-1,0,(R,Q)),(0,1,(R,Q)),(0,-1,(R,Q)),(1,1,(B,Q)),(1,-1,(B,Q)),(-1,1,(B,Q)),(-1,-1,(B,Q))):
            ff,rr=f+df,r+dr
            while 0<=ff<8 and 0<=rr<8:
                v=at(ff,rr)
                if v:
                    if v in kinds: return True
                    break
                ff+=df; rr+=dr
        return False
    
    b=x['board']; fr,to=x['from'],x['to']; k=b[fr]; white=k=='K'
    df=ord(to[0])-ord(fr[0]); dr=int(to[1])-int(fr[1])
    if max(abs(df),abs(dr))!=1: return False
    occ=b.get(to)
    if occ and occ.lower()!='p' and occ.isupper()!=white: return True
    if occ and occ.isupper()==white: return False
    nb=dict(b); del nb[fr]; nb[to]=k
    return not attacked(nb, to, not white)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture undefended', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'},
   True),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)]]
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 fileFalseFalsePassed
sidestep rook fileTrueTruePassed
diagonal stepTrueTruePassed
stand stillFalseFalsePassed
capture ownFalseFalsePassed
capture defendedFalseFalsePassed
capture along check lineFalseFalsePassed
capture defended knightTrueFalseFailed

SHA-256 / 285aabb2702f640a4916e50307242c30f77193d47407c137d1f244c3ab208c99

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    def attacked(bd, sq, by_white):
        f,r=ord(sq[0])-97,int(sq[1])-1
        def at(ff,rr):
            return bd.get(chr(97+ff)+str(rr+1)) if 0<=ff<8 and 0<=rr<8 else None
        P,N,B,R,Q,K=('PNBRQK' if by_white else 'pnbrqk')
        pr=r-1 if by_white else r+1
        if at(f-1,pr)==P or at(f+1,pr)==P: return True
        for df,dr in ((1,2),(2,1),(-1,2),(-2,1),(1,-2),(2,-1),(-1,-2),(-2,-1)):
            if at(f+df,r+dr)==N: return True
        for df in (-1,0,1):
            for dr in (-1,0,1):
                if (df or dr) and at(f+df,r+dr)==K: return True
        for df,dr,kinds in ((1,0,(R,Q)),(-1,0,(R,Q)),(0,1,(R,Q)),(0,-1,(R,Q)),(1,1,(B,Q)),(1,-1,(B,Q)),(-1,1,(B,Q)),(-1,-1,(B,Q))):
            ff,rr=f+df,r+dr
            while 0<=ff<8 and 0<=rr<8:
                v=at(ff,rr)
                if v:
                    if v in kinds: return True
                    break
                ff+=df; rr+=dr
        return False
    
    b=x['board']; fr,to=x['from'],x['to']; k=b[fr]; white=k=='K'
    df=ord(to[0])-ord(fr[0]); dr=int(to[1])-int(fr[1])
    if max(abs(df),abs(dr))!=1: return False
    occ=b.get(to)
    if occ and occ.isupper()==white: return False
    nb=dict(b); del nb[fr]; nb[to]=k
    return not attacked(nb, to, not white)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture own', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'P'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture undefended', {'board': {'a8': 'k', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'},
   True),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False)],
 [('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('next to enemy king orthogonal', {'board': {'e4': 'K', 'e6': 'k'}, 'from': 'e4', 'to': 'e5'},
   False),
  ('next to enemy king diagonal', {'board': {'e4': 'K', 'g6': 'k'}, 'from': 'e4', 'to': 'f5'},
   False),
  ('knight below', {'board': {'a8': 'k', 'e4': 'K', 'f1': 'n'}, 'from': 'e4', 'to': 'e3'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight above', {'board': {'a8': 'k', 'd7': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'e5'}, False),
  ('black king bishop diag retreat',
   {'board': {'b3': 'B', 'd5': 'k', 'h1': 'K'}, 'from': 'd5', 'to': 'e6'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('two squares', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e6'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)],
 [('retreat along rook file',
   {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('sidestep rook file', {'board': {'a1': 'k', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'd3'},
   True),
  ('diagonal step', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'f5'}, True),
  ('stand still', {'board': {'a8': 'k', 'e4': 'K'}, 'from': 'e4', 'to': 'e4'}, False),
  ('capture defended',
   {'board': {'a8': 'k', 'd6': 'p', 'e4': 'K', 'e5': 'p'}, 'from': 'e4', 'to': 'e5'}, False),
  ('capture along check line',
   {'board': {'a1': 'k', 'e3': 'p', 'e4': 'K', 'e8': 'r'}, 'from': 'e4', 'to': 'e3'}, False),
  ('capture defended knight',
   {'board': {'a8': 'k', 'e4': 'K', 'e5': 'n', 'e7': 'r'}, 'from': 'e4', 'to': 'e5'}, False),
  ('knight far below', {'board': {'a8': 'k', 'c4': 'n', 'e4': 'K'}, 'from': 'e4', 'to': 'd3'},
   True)]]
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 fileFalseFalsePassed
sidestep rook fileTrueTruePassed
diagonal stepTrueTruePassed
stand stillFalseFalsePassed
capture ownFalseFalsePassed
capture defendedFalseFalsePassed
capture along check lineFalseFalsePassed
capture defended knightFalseFalsePassed

SHA-256 / 9ba27e2acf57b4896a28a0044a7b4975e62f66beb39f3962000386b830120d14

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

Case digest / e18c82120788c5bda7fd255bb9c418517fc89d517bac0a06cac787a4b669c1fa