FAILURE MAP
← Case archive

FA-82821 / Chess move legality / Open access

Moved piece left behind on its origin · case 01

A knight that moved from g1 can move from g1 again.

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

ROOT CAUSE

The origin square is not cleared when the piece moves.

THE FAILURE

The origin square is not cleared when the piece moves.

Unsuccessful approach: setdefault keeps a captured piece on the destination instead of replacing it.

Case contract

Input: {"board", "turn": "w" or "b", "moves": [[from, to], ...]}. Replay the moves; return the index of the first move that starts from an empty square, moves a piece of the side not to move, or lands on a piece of its own colour; return -1 if all pass. Each move replaces any piece on the destination and passes the turn.

Why this case matters

Game servers must reject out-of-turn and self-capturing moves in submitted move lists.

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']); white=x['turn']=='w'
    for i,(fr,to) in enumerate(x['moves']):
        p=b.get(fr)
        if p is None or p.isupper()!=white: return i
        q=b.get(to)
        if q is not None and q.isupper()==white: return i
        b[to]=p
        white=not white
    return -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('empty origin', {'board': {'e1': 'K', 'e8': 'k'}, 'moves': [['e2', 'e4']], 'turn': 'w'}, 0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('black captures own',
   {'board': {'d8': 'q', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e3'], ['d8', 'e7']],
    'turn': 'w'},
   1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('empty origin', {'board': {'e1': 'K', 'e8': 'k'}, 'moves': [['e2', 'e4']], 'turn': 'w'}, 0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('black captures own',
   {'board': {'d8': 'q', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e3'], ['d8', 'e7']],
    'turn': 'w'},
   1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)]]
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
clean sequence-1-1Passed
white moves twice11Passed
black to start-1-1Passed
captured piece moves11Passed
capture own piece00Passed
vacated square reused-12Failed
capture then recapture-1-1Passed
four clean moves2-1Failed

SHA-256 / f162673b039bd9706cb5e05639a73447c08ed2a79aec466941c7e3ebefb50748

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']); white=x['turn']=='w'
    for i,(fr,to) in enumerate(x['moves']):
        p=b.get(fr)
        if p is None or p.isupper()!=white: return i
        q=b.get(to)
        if q is not None and q.isupper()==white: return i
        del b[fr]
        b.setdefault(to,p)
        white=not white
    return -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('empty origin', {'board': {'e1': 'K', 'e8': 'k'}, 'moves': [['e2', 'e4']], 'turn': 'w'}, 0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('black captures own',
   {'board': {'d8': 'q', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e3'], ['d8', 'e7']],
    'turn': 'w'},
   1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('clean sequence',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['e7', 'e5']],
    'turn': 'w'},
   -1),
  ('white moves twice',
   {'board': {'d2': 'P', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e4'], ['d2', 'd4']],
    'turn': 'w'},
   1),
  ('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)],
 [('black to start',
   {'board': {'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e7', 'e5'], ['e2', 'e4']],
    'turn': 'b'},
   -1),
  ('captured piece moves',
   {'board': {'d1': 'Q', 'd8': 'q', 'e1': 'K', 'e8': 'k'},
    'moves': [['d1', 'd8'], ['d8', 'd1']],
    'turn': 'w'},
   1),
  ('capture own piece',
   {'board': {'d1': 'Q', 'd2': 'P', 'e1': 'K', 'e8': 'k'}, 'moves': [['d1', 'd2']], 'turn': 'w'},
   0),
  ('empty origin', {'board': {'e1': 'K', 'e8': 'k'}, 'moves': [['e2', 'e4']], 'turn': 'w'}, 0),
  ('vacated square reused',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['g1', 'h3']],
    'turn': 'w'},
   2),
  ('capture then recapture',
   {'board': {'d5': 'p', 'd8': 'q', 'e1': 'K', 'e4': 'P', 'e8': 'k'},
    'moves': [['e4', 'd5'], ['d8', 'd5']],
    'turn': 'w'},
   -1),
  ('black captures own',
   {'board': {'d8': 'q', 'e1': 'K', 'e2': 'P', 'e7': 'p', 'e8': 'k'},
    'moves': [['e2', 'e3'], ['d8', 'e7']],
    'turn': 'w'},
   1),
  ('four clean moves',
   {'board': {'e1': 'K', 'e8': 'k', 'g1': 'N', 'g8': 'n'},
    'moves': [['g1', 'f3'], ['g8', 'f6'], ['f3', 'g1'], ['f6', 'g8']],
    'turn': 'w'},
   -1)]]
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
clean sequence-1-1Passed
white moves twice11Passed
black to start-1-1Passed
captured piece moves-11Failed
capture own piece00Passed
vacated square reused22Passed
capture then recapture1-1Failed
four clean moves-1-1Passed

SHA-256 / 7bcfcfe3d033d851ac8882850a913fc6166f931370ef76cdc489f7a8ce173005

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

Case digest / c010170ccb3a72635fc02b6070aad59994ad3f57db14fddeb99cf0b12499c7aa