FAILURE MAP
← Case archive

FA-83351 / Card game rule engines / Open access

Trumping a led suit does not win the trick · case 01

A player who ruffs with a small trump loses to the led ace.

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

ROOT CAUSE

The ruff branch is missing, so trumps are treated like any off-suit card.

THE FAILURE

The ruff branch is missing, so trumps are treated like any off-suit card.

Unsuccessful approach: Requiring the trump to outrank the current winner by rank ignores that any trump beats the led suit.

Case contract

Input [cards_in_play_order, leader_seat, trump_or_None, seats]. The highest trump wins; with no trump played the highest card of the led suit wins (A high). Off-suit non-trump cards never win. Return the winning seat, counting clockwise from the leader.

Why this case matters

Card-game engines, scoring apps and online tables apply this rule automatically on every hand.

1 / The failure

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

N = 1
observations = []
def solve(x):
    cards, leader, trump, seats = x
    order = '23456789TJQKA'
    best = 0
    for i in range(1, len(cards)):
        card, top = cards[i], cards[best]
        if card[1] == top[1]:
            if order.index(card[0]) > order.index(top[0]):
                best = i
    return (leader + best) % seats
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['JS', 'AC', 'TS', '3S'], 3, 'C', 4], 0], [[['KC', 'AC', '8H', '8D'], 2, None, 4], 3], [[['3H', '9S', 'QD', '5H'], 3, 'D', 4], 1], [[['KD', '2H', '9D', '2D', '6C'], 4, None, 5], 4], [[['QH', '4D', 'TS', '5D', '2S'], 4, None, 5], 4], [[['8H', 'TS', '7D', 'JS'], 2, None, 4], 2], [[['8S', 'AD', 'KC'], 0, None, 3], 0], [[['KD', 'JD', '7S', '9S'], 3, 'S', 4], 2]], [[[['JH', '9C', 'TS', '8H'], 0, 'C', 4], 1], [[['9C', '7D', '8D', '2S', 'TD'], 4, 'D', 5], 3], [[['JD', '2H', 'KD', '5D', 'QS'], 0, None, 5], 2], [[['2D', 'QC', '3S', '3H'], 3, 'S', 4], 1], [[['5C', '6H', '3C', 'AC'], 2, 'D', 4], 1], [[['4D', '6S', 'TH'], 2, 'D', 3], 2], [[['9H', 'KS', '7S', '9C'], 0, 'D', 4], 0], [[['KC', 'KH', '6C', 'KS', '4D'], 4, 'H', 5], 0]], [[[['2D', 'QC', '3S', '3H'], 3, 'S', 4], 1], [[['5D', 'AD', '8H'], 1, None, 3], 2], [[['TD', '5D', 'QS', 'AC', 'KS'], 1, None, 5], 1], [[['8H', 'QC', 'JS'], 2, 'C', 3], 0], [[['KC', '6C', '4S'], 0, 'D', 3], 0], [[['3S', '6C', 'QS'], 0, 'S', 3], 2], [[['JH', '5H', 'JS'], 2, None, 3], 2], [[['KS', 'JS', 'KC', '7H'], 2, 'C', 4], 0]], [[[['8S', '5S', 'KS'], 2, 'H', 3], 1], [[['3D', 'QD', '8S', '6D', 'TS'], 2, None, 5], 3], [[['6D', '2H', '4D', '5S', '7S'], 4, 'H', 5], 0], [[['8C', '5H', '6H', '9C'], 2, None, 4], 1], [[['AH', 'TD', '4H', '3S', 'KD'], 1, None, 5], 1], [[['6H', 'AS', '7H', 'JD'], 2, 'D', 4], 1], [[['7H', '3C', '6D', '5C'], 3, 'H', 4], 3], [[['8D', '6H', '9D', 'KS'], 3, 'H', 4], 0]], [[[['7S', '4S', '8D'], 1, 'S', 3], 1], [[['3S', 'JS', 'TC', '5D', '3H'], 2, 'D', 5], 0], [[['9H', '6H', '3D'], 1, 'S', 3], 1], [[['3H', '8D', '3C'], 0, 'H', 3], 0], [[['AD', 'JH', '8D', '5D'], 1, 'H', 4], 2], [[['8C', '8S', 'AC'], 1, None, 3], 0], [[['KH', '7H', '7S', '3D'], 0, 'S', 4], 2], [[['QC', '7C', '6H'], 1, 'H', 3], 0]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("trick case %d" % i, solve(args), 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
trick case 030Failed
trick case 133Passed
trick case 221Failed
trick case 344Passed
trick case 444Passed
trick case 522Passed
trick case 600Passed
trick case 732Failed

SHA-256 / ee1cda54ce57cb99ed695aa1b055f905e0b8ed5ec8f4a802baab7d746e05793d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    cards, leader, trump, seats = x
    order = '23456789TJQKA'
    best = 0
    for i in range(1, len(cards)):
        card, top = cards[i], cards[best]
        if card[1] == top[1]:
            if order.index(card[0]) > order.index(top[0]):
                best = i
        elif card[1] == trump and order.index(card[0]) > order.index(top[0]):
            best = i
    return (leader + best) % seats
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['JS', 'AC', 'TS', '3S'], 3, 'C', 4], 0], [[['KC', 'AC', '8H', '8D'], 2, None, 4], 3], [[['3H', '9S', 'QD', '5H'], 3, 'D', 4], 1], [[['KD', '2H', '9D', '2D', '6C'], 4, None, 5], 4], [[['QH', '4D', 'TS', '5D', '2S'], 4, None, 5], 4], [[['8H', 'TS', '7D', 'JS'], 2, None, 4], 2], [[['8S', 'AD', 'KC'], 0, None, 3], 0], [[['KD', 'JD', '7S', '9S'], 3, 'S', 4], 2]], [[[['JH', '9C', 'TS', '8H'], 0, 'C', 4], 1], [[['9C', '7D', '8D', '2S', 'TD'], 4, 'D', 5], 3], [[['JD', '2H', 'KD', '5D', 'QS'], 0, None, 5], 2], [[['2D', 'QC', '3S', '3H'], 3, 'S', 4], 1], [[['5C', '6H', '3C', 'AC'], 2, 'D', 4], 1], [[['4D', '6S', 'TH'], 2, 'D', 3], 2], [[['9H', 'KS', '7S', '9C'], 0, 'D', 4], 0], [[['KC', 'KH', '6C', 'KS', '4D'], 4, 'H', 5], 0]], [[[['2D', 'QC', '3S', '3H'], 3, 'S', 4], 1], [[['5D', 'AD', '8H'], 1, None, 3], 2], [[['TD', '5D', 'QS', 'AC', 'KS'], 1, None, 5], 1], [[['8H', 'QC', 'JS'], 2, 'C', 3], 0], [[['KC', '6C', '4S'], 0, 'D', 3], 0], [[['3S', '6C', 'QS'], 0, 'S', 3], 2], [[['JH', '5H', 'JS'], 2, None, 3], 2], [[['KS', 'JS', 'KC', '7H'], 2, 'C', 4], 0]], [[[['8S', '5S', 'KS'], 2, 'H', 3], 1], [[['3D', 'QD', '8S', '6D', 'TS'], 2, None, 5], 3], [[['6D', '2H', '4D', '5S', '7S'], 4, 'H', 5], 0], [[['8C', '5H', '6H', '9C'], 2, None, 4], 1], [[['AH', 'TD', '4H', '3S', 'KD'], 1, None, 5], 1], [[['6H', 'AS', '7H', 'JD'], 2, 'D', 4], 1], [[['7H', '3C', '6D', '5C'], 3, 'H', 4], 3], [[['8D', '6H', '9D', 'KS'], 3, 'H', 4], 0]], [[[['7S', '4S', '8D'], 1, 'S', 3], 1], [[['3S', 'JS', 'TC', '5D', '3H'], 2, 'D', 5], 0], [[['9H', '6H', '3D'], 1, 'S', 3], 1], [[['3H', '8D', '3C'], 0, 'H', 3], 0], [[['AD', 'JH', '8D', '5D'], 1, 'H', 4], 2], [[['8C', '8S', 'AC'], 1, None, 3], 0], [[['KH', '7H', '7S', '3D'], 0, 'S', 4], 2], [[['QC', '7C', '6H'], 1, 'H', 3], 0]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("trick case %d" % i, solve(args), 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
trick case 000Passed
trick case 133Passed
trick case 211Passed
trick case 344Passed
trick case 444Passed
trick case 522Passed
trick case 600Passed
trick case 732Failed

SHA-256 / e80e5f02d79fd0832a3d7d0e0361990e02e5e8978b50ca657679e5dfe6fd0d64

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 bounded toy rule contract stated explicitly in the contract field; cards are two-character codes (rank, suit). Not a complete implementation of any published rulebook or casino table rules. 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:20.703234+00:00.

Case digest / 0b0d0c39f346af29b94e9bef8e2b979affc00c419acde22d62048be83ffc8316