FA-82741 / Chess move legality / Open access
Ordinary pawn capture also removes a piece beside the pawn · case 01
exd5 also deletes the white knight on d4.
ROOT CAUSE
Every diagonal pawn move is treated as en passant, even when it captures on the destination.
VERIFIED REPAIR
Only a diagonal move onto an empty square is en passant.
Unsuccessful approach: Treating every move onto an empty square as en passant breaks ordinary pushes.
Case contract
Input: {"board", "moves": [uci strings]}. Apply the moves in order and return the final board sorted by square. A king moving two files castles: the rook jumps from h to f (g-file destination) or from a to d (c-file destination). A pawn moving diagonally onto an empty square captures en passant, removing the pawn on the destination file and origin rank. A fifth character promotes to that piece in the mover's colour.
Why this case matters
Move application defines the position every later legality check sees.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=dict(x['board'])
for u in x['moves']:
fr,to,pr=u[:2],u[2:4],u[4:]
p=b.pop(fr)
if p in ('K','k') and abs(ord(to[0])-ord(fr[0]))==2:
if to[0]=='g': b['f'+to[1]]=b.pop('h'+to[1])
else: b['d'+to[1]]=b.pop('a'+to[1])
if p in ('P','p') and fr[0]!=to[0]:
del b[to[0]+fr[1]]
if pr: p=pr.upper() if p=='P' else pr.lower()
b[to]=p
return dict(sorted(b.items()))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'})],
[('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})]]
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 |
|---|---|---|---|
| white long castle | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | Passed |
| black short castle | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | Passed |
| king step to g1 | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | Passed |
| king step to c8 | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | Passed |
| white en passant | {'d6': 'P', 'e1': 'K', 'e8': 'k'} | {'d6': 'P', 'e1': 'K', 'e8': 'k'} | Passed |
| black en passant | {'e1': 'K', 'e3': 'p', 'e8': 'k'} | {'e1': 'K', 'e3': 'p', 'e8': 'k'} | Passed |
| ordinary pawn capture | {'d5': 'P', 'e1': 'K', 'e8': 'k'} | {'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'} | Failed |
| quiet sequence | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | Passed |
SHA-256 / 663acb4dab443ff1d143b819b26688739ee3582aab6d939ec646fcb1e5fd94cf
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=dict(x['board'])
for u in x['moves']:
fr,to,pr=u[:2],u[2:4],u[4:]
p=b.pop(fr)
if p in ('K','k') and abs(ord(to[0])-ord(fr[0]))==2:
if to[0]=='g': b['f'+to[1]]=b.pop('h'+to[1])
else: b['d'+to[1]]=b.pop('a'+to[1])
if p in ('P','p') and to not in b:
del b[to[0]+fr[1]]
if pr: p=pr.upper() if p=='P' else pr.lower()
b[to]=p
return dict(sorted(b.items()))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'})],
[('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})]]
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 |
|---|---|---|---|
| white long castle | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | Passed |
| black short castle | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | Passed |
| king step to g1 | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | Passed |
| king step to c8 | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | Passed |
| white en passant | error:KeyError | {'d6': 'P', 'e1': 'K', 'e8': 'k'} | Failed |
| black en passant | error:KeyError | {'e1': 'K', 'e3': 'p', 'e8': 'k'} | Failed |
| ordinary pawn capture | {'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'} | {'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'} | Passed |
| quiet sequence | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | Passed |
SHA-256 / 01085fd71514058c1a060da08df6a9c69c307ff3dcb9573851ee4853f1142ecc
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=dict(x['board'])
for u in x['moves']:
fr,to,pr=u[:2],u[2:4],u[4:]
p=b.pop(fr)
if p in ('K','k') and abs(ord(to[0])-ord(fr[0]))==2:
if to[0]=='g': b['f'+to[1]]=b.pop('h'+to[1])
else: b['d'+to[1]]=b.pop('a'+to[1])
if p in ('P','p') and fr[0]!=to[0] and to not in b:
del b[to[0]+fr[1]]
if pr: p=pr.upper() if p=='P' else pr.lower()
b[to]=p
return dict(sorted(b.items()))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'})],
[('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('white promotion', {'board': {'b7': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['b7b8q']},
{'b8': 'Q', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('white long castle', {'board': {'a1': 'R', 'e1': 'K', 'e8': 'k'}, 'moves': ['e1c1']},
{'c1': 'K', 'd1': 'R', 'e8': 'k'}),
('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('black underpromotion', {'board': {'e1': 'K', 'e8': 'k', 'g2': 'p'}, 'moves': ['g2g1n']},
{'e1': 'K', 'e8': 'k', 'g1': 'n'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})],
[('black short castle', {'board': {'e1': 'K', 'e8': 'k', 'h8': 'r'}, 'moves': ['e8g8']},
{'e1': 'K', 'f8': 'r', 'g8': 'k'}),
('king step to g1', {'board': {'e8': 'k', 'f1': 'K', 'h1': 'R'}, 'moves': ['f1g1']},
{'e8': 'k', 'g1': 'K', 'h1': 'R'}),
('king step to c8', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K'}, 'moves': ['d8c8']},
{'a8': 'r', 'c8': 'k', 'e1': 'K'}),
('white en passant',
{'board': {'d7': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'moves': ['d7d5', 'e5d6']},
{'d6': 'P', 'e1': 'K', 'e8': 'k'}),
('black en passant',
{'board': {'d4': 'p', 'e1': 'K', 'e2': 'P', 'e8': 'k'}, 'moves': ['e2e4', 'd4e3']},
{'e1': 'K', 'e3': 'p', 'e8': 'k'}),
('ordinary pawn capture',
{'board': {'d4': 'N', 'd5': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'moves': ['e4d5']},
{'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'}),
('quiet sequence',
{'board': {'b8': 'n', 'e1': 'K', 'e8': 'k', 'g1': 'N'}, 'moves': ['g1f3', 'b8c6', 'f3e5']},
{'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'}),
('pawn push', {'board': {'c2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': ['c2c4']},
{'c4': 'P', 'e1': 'K', 'e8': 'k'})]]
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 |
|---|---|---|---|
| white long castle | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | {'c1': 'K', 'd1': 'R', 'e8': 'k'} | Passed |
| black short castle | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | {'e1': 'K', 'f8': 'r', 'g8': 'k'} | Passed |
| king step to g1 | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | {'e8': 'k', 'g1': 'K', 'h1': 'R'} | Passed |
| king step to c8 | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | {'a8': 'r', 'c8': 'k', 'e1': 'K'} | Passed |
| white en passant | {'d6': 'P', 'e1': 'K', 'e8': 'k'} | {'d6': 'P', 'e1': 'K', 'e8': 'k'} | Passed |
| black en passant | {'e1': 'K', 'e3': 'p', 'e8': 'k'} | {'e1': 'K', 'e3': 'p', 'e8': 'k'} | Passed |
| ordinary pawn capture | {'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'} | {'d4': 'N', 'd5': 'P', 'e1': 'K', 'e8': 'k'} | Passed |
| quiet sequence | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | {'c6': 'n', 'e1': 'K', 'e5': 'N', 'e8': 'k'} | Passed |
SHA-256 / fbb331d9ed6fa60dc15ec992fe683ee93c0452119f3f5ef3beca51fe9e23d051
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.857278+00:00.
Case digest / 60b5511849c06ae6fe1440215689ea633800c7e02495ef8ffc5a8d21b6d4f51b