FA-83356 / Card game rule engines / Open access
Aces rank low in trick comparison · case 01
A led ace loses to a deuce of the same suit.
ROOT CAUSE
The rank string starts with A.
THE FAILURE
The rank string starts with A.
Unsuccessful approach: Reversing the rank string makes low cards win.
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 = 'A23456789TJQK'
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:
best = i
return (leader + best) % seats
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['2H', '8D', 'TC', 'AH'], 2, 'S', 4], 1], [[['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], [[['9C', '7D', '8D', '2S', 'TD'], 4, 'D', 5], 3]], [[[['8C', '2C', '9D', '7C'], 1, None, 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], [[['7H', '8D', 'AH', '5S', '6S'], 4, 'C', 5], 1], [[['TD', '5D', 'QS', 'AC', 'KS'], 1, None, 5], 1]], [[[['7H', '8D', 'AH', '5S', '6S'], 4, 'C', 5], 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], [[['3D', 'QD', '8S', '6D', 'TS'], 2, None, 5], 3], [[['8C', '8S', 'AC'], 1, None, 3], 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], [[['8C', '8S', 'AC'], 1, None, 3], 0], [[['QC', '9S', 'AC'], 1, None, 3], 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], [[['AH', '4H', '7S', 'JH'], 2, 'H', 4], 2], [[['5S', '8H', '4D', 'AS'], 0, 'S', 4], 3]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| trick case 0 | 2 | 1 | Failed |
| trick case 1 | 2 | 3 | Failed |
| trick case 2 | 1 | 1 | Passed |
| trick case 3 | 4 | 4 | Passed |
| trick case 4 | 4 | 4 | Passed |
| trick case 5 | 2 | 2 | Passed |
| trick case 6 | 0 | 0 | Passed |
| trick case 7 | 3 | 3 | Passed |
SHA-256 / e979083e03263de309ac2b9e15922bacde278116de983ef19b235a799aea28c9
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'[::-1]
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:
best = i
return (leader + best) % seats
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['2H', '8D', 'TC', 'AH'], 2, 'S', 4], 1], [[['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], [[['9C', '7D', '8D', '2S', 'TD'], 4, 'D', 5], 3]], [[[['8C', '2C', '9D', '7C'], 1, None, 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], [[['7H', '8D', 'AH', '5S', '6S'], 4, 'C', 5], 1], [[['TD', '5D', 'QS', 'AC', 'KS'], 1, None, 5], 1]], [[[['7H', '8D', 'AH', '5S', '6S'], 4, 'C', 5], 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], [[['3D', 'QD', '8S', '6D', 'TS'], 2, None, 5], 3], [[['8C', '8S', 'AC'], 1, None, 3], 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], [[['8C', '8S', 'AC'], 1, None, 3], 0], [[['QC', '9S', 'AC'], 1, None, 3], 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], [[['AH', '4H', '7S', 'JH'], 2, 'H', 4], 2], [[['5S', '8H', '4D', 'AS'], 0, 'S', 4], 3]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| trick case 0 | 2 | 1 | Failed |
| trick case 1 | 2 | 3 | Failed |
| trick case 2 | 1 | 1 | Passed |
| trick case 3 | 2 | 4 | Failed |
| trick case 4 | 4 | 4 | Passed |
| trick case 5 | 2 | 2 | Passed |
| trick case 6 | 0 | 0 | Passed |
| trick case 7 | 0 | 3 | Failed |
SHA-256 / 0552911381516ff0bf7370497291afc2f64fb4bdd8acaf2672c88aea82c011fc
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.746035+00:00.
Case digest / 9cb1b30a1123bc584e8286258114f4ab9adeaf4d664f532c3916bf72fc136019