FAILURE MAP
← Case archive

FA-83646 / Card game rule engines / Open access

Left bower outranks right bower · case 01

The same-colour jack beats the jack of trump.

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

ROOT CAUSE

Bower powers are swapped.

THE FAILURE

Bower powers are swapped.

Unsuccessful approach: Ranking jacks in their natural slot makes the bowers lose to trump aces.

Case contract

Input [four_cards, leader, trump]. The jack of trump (right bower) is highest, the jack of the same-colour suit (left bower) is second and belongs to the trump suit; then A K Q T 9 of trump. Otherwise the highest card of the effective led suit (A K Q J T 9) wins. Return the winning seat.

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 = x
    partner = {'S': 'C', 'C': 'S', 'H': 'D', 'D': 'H'}[trump]
    def suit(c):
        if c[0] == 'J' and c[1] == partner:
            return trump
        return c[1]
    def power(c):
        if suit(c) == trump:
            if c[0] == 'J':
                return 99 if c[1] == trump else 100
            return 50 + '9TJQKA'.index(c[0])
        return '9TJQKA'.index(c[0])
    best = 0
    for i in range(1, len(cards)):
        c = cards[i]
        b = cards[best]
        if suit(c) == suit(b) and power(c) > power(b):
            best = i
        elif suit(c) == trump and suit(b) != trump:
            best = i
    return (leader + best) % 4
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['JC', 'JD', 'TC', 'JH'], 3, 'H'], 2], [[['9H', 'JS', 'TH', 'QC'], 3, 'C'], 0], [[['KS', '9H', 'QC', '9D'], 3, 'S'], 3], [[['JD', 'QD', 'AD', 'AC'], 0, 'H'], 0], [[['JD', 'AS', 'JC', 'QH'], 3, 'S'], 1], [[['KH', '9S', 'JH', 'QS'], 3, 'D'], 1], [[['TS', 'JS', 'TC', 'QC'], 2, 'S'], 3], [[['9D', 'AS', 'JS', 'TD'], 0, 'S'], 2]], [[[['JH', 'AH', 'KD', 'JD'], 2, 'D'], 1], [[['JD', '9H', 'TH', 'AS'], 0, 'H'], 0], [[['JD', 'TS', '9C', 'QD'], 3, 'C'], 1], [[['QS', 'KD', '9S', '9C'], 1, 'S'], 1], [[['TH', 'AS', 'TD', 'KD'], 2, 'C'], 2], [[['QS', 'TC', 'KH', 'AS'], 0, 'D'], 3], [[['TH', 'JS', 'QC', 'JC'], 2, 'C'], 1], [[['KD', 'AS', 'JD', 'JH'], 0, 'D'], 2]], [[[['KC', 'KD', 'JS', 'QH'], 1, 'C'], 3], [[['JC', 'TH', '9H', 'QD'], 1, 'D'], 0], [[['9D', 'AS', 'JS', 'TD'], 0, 'S'], 2], [[['JS', 'TH', 'TC', 'JD'], 2, 'C'], 2], [[['TC', 'JS', 'AC', 'TH'], 1, 'C'], 2], [[['QC', 'QD', 'KC', 'JS'], 2, 'C'], 1], [[['JD', '9D', 'AH', 'JS'], 1, 'H'], 1], [[['KC', 'JD', 'QS', 'JH'], 0, 'D'], 1]], [[[['AH', 'KD', '9S', 'KC'], 3, 'S'], 1], [[['JD', 'QD', 'KC', 'JC'], 3, 'S'], 2], [[['TH', 'AH', 'JD', 'QD'], 2, 'S'], 3], [[['KS', '9D', 'TD', 'JS'], 0, 'C'], 3], [[['9C', 'JH', 'JS', 'TC'], 2, 'C'], 0], [[['QD', 'AH', 'KS', 'TC'], 3, 'H'], 0], [[['9D', 'JH', 'QH', 'QD'], 3, 'D'], 0], [[['JS', 'AH', '9H', 'JC'], 2, 'C'], 1]], [[[['QH', 'AD', 'AS', 'QC'], 3, 'D'], 0], [[['TC', 'JD', 'QS', 'JC'], 3, 'C'], 2], [[['AH', 'JH', '9C', 'TS'], 0, 'D'], 1], [[['AD', 'KS', 'JH', 'JD'], 2, 'H'], 0], [[['TH', 'JS', 'QC', 'JC'], 2, 'C'], 1], [[['KC', '9H', 'JS', 'JC'], 2, 'S'], 0], [[['9D', 'JS', 'TS', 'QC'], 1, 'C'], 2], [[['KH', 'JC', 'JS', 'TC'], 3, 'C'], 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 002Failed
trick case 100Passed
trick case 233Passed
trick case 300Passed
trick case 411Passed
trick case 511Passed
trick case 633Passed
trick case 722Passed

SHA-256 / 7b448dde3e2e36f1cd2235dbbf4004bd92faea5e9bb5105738ed1e904787046b

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 = x
    partner = {'S': 'C', 'C': 'S', 'H': 'D', 'D': 'H'}[trump]
    def suit(c):
        if c[0] == 'J' and c[1] == partner:
            return trump
        return c[1]
    def power(c):
        if suit(c) == trump:
            return 50 + '9TJQKA'.index(c[0])
        return '9TJQKA'.index(c[0])
    best = 0
    for i in range(1, len(cards)):
        c = cards[i]
        b = cards[best]
        if suit(c) == suit(b) and power(c) > power(b):
            best = i
        elif suit(c) == trump and suit(b) != trump:
            best = i
    return (leader + best) % 4
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['JC', 'JD', 'TC', 'JH'], 3, 'H'], 2], [[['9H', 'JS', 'TH', 'QC'], 3, 'C'], 0], [[['KS', '9H', 'QC', '9D'], 3, 'S'], 3], [[['JD', 'QD', 'AD', 'AC'], 0, 'H'], 0], [[['JD', 'AS', 'JC', 'QH'], 3, 'S'], 1], [[['KH', '9S', 'JH', 'QS'], 3, 'D'], 1], [[['TS', 'JS', 'TC', 'QC'], 2, 'S'], 3], [[['9D', 'AS', 'JS', 'TD'], 0, 'S'], 2]], [[[['JH', 'AH', 'KD', 'JD'], 2, 'D'], 1], [[['JD', '9H', 'TH', 'AS'], 0, 'H'], 0], [[['JD', 'TS', '9C', 'QD'], 3, 'C'], 1], [[['QS', 'KD', '9S', '9C'], 1, 'S'], 1], [[['TH', 'AS', 'TD', 'KD'], 2, 'C'], 2], [[['QS', 'TC', 'KH', 'AS'], 0, 'D'], 3], [[['TH', 'JS', 'QC', 'JC'], 2, 'C'], 1], [[['KD', 'AS', 'JD', 'JH'], 0, 'D'], 2]], [[[['KC', 'KD', 'JS', 'QH'], 1, 'C'], 3], [[['JC', 'TH', '9H', 'QD'], 1, 'D'], 0], [[['9D', 'AS', 'JS', 'TD'], 0, 'S'], 2], [[['JS', 'TH', 'TC', 'JD'], 2, 'C'], 2], [[['TC', 'JS', 'AC', 'TH'], 1, 'C'], 2], [[['QC', 'QD', 'KC', 'JS'], 2, 'C'], 1], [[['JD', '9D', 'AH', 'JS'], 1, 'H'], 1], [[['KC', 'JD', 'QS', 'JH'], 0, 'D'], 1]], [[[['AH', 'KD', '9S', 'KC'], 3, 'S'], 1], [[['JD', 'QD', 'KC', 'JC'], 3, 'S'], 2], [[['TH', 'AH', 'JD', 'QD'], 2, 'S'], 3], [[['KS', '9D', 'TD', 'JS'], 0, 'C'], 3], [[['9C', 'JH', 'JS', 'TC'], 2, 'C'], 0], [[['QD', 'AH', 'KS', 'TC'], 3, 'H'], 0], [[['9D', 'JH', 'QH', 'QD'], 3, 'D'], 0], [[['JS', 'AH', '9H', 'JC'], 2, 'C'], 1]], [[[['QH', 'AD', 'AS', 'QC'], 3, 'D'], 0], [[['TC', 'JD', 'QS', 'JC'], 3, 'C'], 2], [[['AH', 'JH', '9C', 'TS'], 0, 'D'], 1], [[['AD', 'KS', 'JH', 'JD'], 2, 'H'], 0], [[['TH', 'JS', 'QC', 'JC'], 2, 'C'], 1], [[['KC', '9H', 'JS', 'JC'], 2, 'S'], 0], [[['9D', 'JS', 'TS', 'QC'], 1, 'C'], 2], [[['KH', 'JC', 'JS', 'TC'], 3, 'C'], 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 002Failed
trick case 120Failed
trick case 233Passed
trick case 300Passed
trick case 401Failed
trick case 511Passed
trick case 633Passed
trick case 712Failed

SHA-256 / 8fb58c246d392e5192e905423b54f19bbb958653bbab7f28f839e0f129fe4607

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

Case digest / 9459b3f6b0a04fe3c9d7e7958ba77e30e69f24b7429e06e4b7d5b3c44a68fe93