FA-83416 / Card game rule engines / Open access
Doubled wagers lose the full stake to a dealer natural · case 01
The doubled portion is taken although the contract refunds it.
ROOT CAUSE
The dealer-natural branch returns the doubled stake.
THE FAILURE
The dealer-natural branch returns the doubled stake.
Unsuccessful approach: Refunding the whole wager on doubled hands loses nothing at all.
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 pt > 21:
return -stake
if pn and dn:
return 0
if pn:
return bet * 3 // 2
if dn:
return -stake
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], [[['6D', 'JS', '3D'], ['5D', '9H'], 4, True, True], 8], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['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], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, 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], [[['3H', 'TD'], ['8H', '5D'], 10, False, False], 0], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['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], [[['6S', 'AH'], ['8S', 'QC', '7D'], 4, False, False], 4]], [[[['KH', '5D'], ['AD', 'JD'], 4, 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], [[['8D', 'JH', '2S', '6S'], ['JD', 'TS'], 10, False, False], -10], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]]]
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 | -8 | -4 | Failed |
| 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 | 8 | 8 | Passed |
| settlement case 7 | -20 | -10 | Failed |
SHA-256 / c3e235f809aa9fec7aecfb9334cfebf56b9eedf3f1713fe9610a96ece6c3ad4d
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:
return -stake
if pn and dn:
return 0
if pn:
return bet * 3 // 2
if dn:
return 0 if doubled else -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], [[['6D', 'JS', '3D'], ['5D', '9H'], 4, True, True], 8], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['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], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, 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], [[['3H', 'TD'], ['8H', '5D'], 10, False, False], 0], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['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], [[['6S', 'AH'], ['8S', 'QC', '7D'], 4, False, False], 4]], [[[['KH', '5D'], ['AD', 'JD'], 4, 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], [[['8D', 'JH', '2S', '6S'], ['JD', 'TS'], 10, False, False], -10], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]]]
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 | 0 | -4 | Failed |
| 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 | 8 | 8 | Passed |
| settlement case 7 | 0 | -10 | Failed |
SHA-256 / ab3b5a41833a37650e8c5cc6ffa4e5240508304ecf79319fd8ac9d6b09baf9fd
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.343881+00:00.
Case digest / 17aa8c9b337a57c089ab9c534302a2c644b0492190febe662f1ccd0dae6f4bde