FA-83401 / Card game rule engines / Open access
A busted player is paid when the dealer also busts · case 01
Hands where both sides bust are settled in the player favour.
ROOT CAUSE
Dealer bust is checked before player bust.
THE FAILURE
Dealer bust is checked before player bust.
Unsuccessful approach: Turning double busts into pushes still ignores that the player bust first.
Case contract
Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.
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):
p, d, bet, doubled, split = x
def total(h):
t = 0
a = 0
for c in h:
if c[0] == 'A':
a += 1
t += 1
elif c[0] in 'TJQK':
t += 10
else:
t += int(c[0])
if a and t + 10 <= 21:
t += 10
return t
stake = bet * 2 if doubled else bet
pt = total(p)
dt = total(d)
pn = pt == 21 and len(p) == 2 and not split
dn = dt == 21 and len(d) == 2
if dt > 21:
return stake
if pt > 21:
return -stake
if pn and dn:
return 0
if pn:
return bet * 3 // 2
if dn:
return -bet
if dt > 21:
return stake
if pt > dt:
return stake
if pt < dt:
return -stake
return 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['8S', '5C', 'QS', '9S'], ['9D', '6C', 'TC'], 2, False, True], -2]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['9S', '8H', '7C'], ['9C', '7D', '8S'], 10, False, False], -10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['QC', 'TD', 'QD'], ['7D', '6S', 'JC'], 10, False, True], -10], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("settlement 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 |
|---|---|---|---|
| settlement case 0 | 4 | 4 | Passed |
| settlement case 1 | -4 | -4 | Passed |
| settlement case 2 | 0 | 0 | Passed |
| settlement case 3 | -20 | -20 | Passed |
| settlement case 4 | 8 | 8 | Passed |
| settlement case 5 | 40 | 40 | Passed |
| settlement case 6 | 20 | -20 | Failed |
| settlement case 7 | 2 | -2 | Failed |
SHA-256 / ce0f63930106b086c1bb5e9c8d08a78f86cfaae29a6451ba6bcbd18f9ff35713
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
p, d, bet, doubled, split = x
def total(h):
t = 0
a = 0
for c in h:
if c[0] == 'A':
a += 1
t += 1
elif c[0] in 'TJQK':
t += 10
else:
t += int(c[0])
if a and t + 10 <= 21:
t += 10
return t
stake = bet * 2 if doubled else bet
pt = total(p)
dt = total(d)
pn = pt == 21 and len(p) == 2 and not split
dn = dt == 21 and len(d) == 2
if pt > 21 and dt <= 21:
return -stake
if pt > 21:
return 0
if pn and dn:
return 0
if pn:
return bet * 3 // 2
if dn:
return -bet
if dt > 21:
return stake
if pt > dt:
return stake
if pt < dt:
return -stake
return 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['8S', '5C', 'QS', '9S'], ['9D', '6C', 'TC'], 2, False, True], -2]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['9S', '8H', '7C'], ['9C', '7D', '8S'], 10, False, False], -10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['QC', 'TD', 'QD'], ['7D', '6S', 'JC'], 10, False, True], -10], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("settlement 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 |
|---|---|---|---|
| settlement case 0 | 4 | 4 | Passed |
| settlement case 1 | -4 | -4 | Passed |
| settlement case 2 | 0 | 0 | Passed |
| settlement case 3 | -20 | -20 | Passed |
| settlement case 4 | 8 | 8 | Passed |
| settlement case 5 | 40 | 40 | Passed |
| settlement case 6 | 0 | -20 | Failed |
| settlement case 7 | 0 | -2 | Failed |
SHA-256 / 63599cc8ccace2f32a2d4a713976b89b0d92c1897199d36734c2d86f94f531c1
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:21.303582+00:00.
Case digest / 0d91f1b593ccf857ea574130e20ddd0ef1f4a0aa62209c319e90bce041283710