FA-83731 / Card game rule engines / Open access
A hand totalling 21 is offered hit · case 01
Players at 21 can still draw.
ROOT CAUSE
The stop test uses > 21.
VERIFIED REPAIR
At 21 or more the only action is stand.
Unsuccessful approach: Stopping 21 only on two-card hands lets multi-card 21s keep hitting.
Case contract
Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.
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, splits, from_aces, das = x
def v(c):
return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
acts = ['stand']
if from_aces:
return acts
total = 0
aces = 0
for c in cards:
total += v(c)
aces += c[0] == 'A'
while total > 21 and aces:
total -= 10
aces -= 1
if total > 21:
return acts
acts.append('hit')
two = len(cards) == 2
if two and (splits == 0 or das):
acts.append('double')
if two and v(cards[0]) == v(cards[1]) and splits < 3:
acts.append('split')
if two and splits == 0:
acts.append('surrender')
return acts
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'QS'], 0, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['JH', '6S', 'TH'], 3, False, False], ['stand']], [[['3S', '9S', '9D'], 3, False, False], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['4H', 'AD', 'QC', 'JC'], 3, False, True], ['stand']], [[['KS', 'AC'], 2, False, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['KD', 'KD', 'JH', '6C'], 0, False, False], ['stand']], [[['9S', 'TH', '2D'], 0, False, True], ['stand']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['JH', 'JD', 'AS'], 0, False, True], ['stand']], [[['QC', 'QH', 'TH', '8H'], 0, False, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("actions 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 |
|---|---|---|---|
| actions case 0 | ['stand', 'hit', 'double', 'surrender'] | ['stand'] | Failed |
| actions case 1 | ['stand', 'hit', 'double', 'surrender'] | ['stand', 'hit', 'double', 'surrender'] | Passed |
| actions case 2 | ['stand'] | ['stand'] | Passed |
| actions case 3 | ['stand'] | ['stand'] | Passed |
| actions case 4 | ['stand'] | ['stand'] | Passed |
| actions case 5 | ['stand'] | ['stand'] | Passed |
| actions case 6 | ['stand', 'hit'] | ['stand', 'hit'] | Passed |
| actions case 7 | ['stand'] | ['stand'] | Passed |
SHA-256 / fab3367241bbba3729ba4291d4fc82f23f3bede1d6597146139e738a1d27be69
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cards, splits, from_aces, das = x
def v(c):
return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
acts = ['stand']
if from_aces:
return acts
total = 0
aces = 0
for c in cards:
total += v(c)
aces += c[0] == 'A'
while total > 21 and aces:
total -= 10
aces -= 1
if total >= 21 and len(cards) == 2:
return acts
acts.append('hit')
two = len(cards) == 2
if two and (splits == 0 or das):
acts.append('double')
if two and v(cards[0]) == v(cards[1]) and splits < 3:
acts.append('split')
if two and splits == 0:
acts.append('surrender')
return acts
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'QS'], 0, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['JH', '6S', 'TH'], 3, False, False], ['stand']], [[['3S', '9S', '9D'], 3, False, False], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['4H', 'AD', 'QC', 'JC'], 3, False, True], ['stand']], [[['KS', 'AC'], 2, False, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['KD', 'KD', 'JH', '6C'], 0, False, False], ['stand']], [[['9S', 'TH', '2D'], 0, False, True], ['stand']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['JH', 'JD', 'AS'], 0, False, True], ['stand']], [[['QC', 'QH', 'TH', '8H'], 0, False, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("actions 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 |
|---|---|---|---|
| actions case 0 | ['stand'] | ['stand'] | Passed |
| actions case 1 | ['stand', 'hit', 'double', 'surrender'] | ['stand', 'hit', 'double', 'surrender'] | Passed |
| actions case 2 | ['stand', 'hit'] | ['stand'] | Failed |
| actions case 3 | ['stand', 'hit'] | ['stand'] | Failed |
| actions case 4 | ['stand'] | ['stand'] | Passed |
| actions case 5 | ['stand'] | ['stand'] | Passed |
| actions case 6 | ['stand', 'hit'] | ['stand', 'hit'] | Passed |
| actions case 7 | ['stand', 'hit'] | ['stand'] | Failed |
SHA-256 / 81426f32df88f7f0f4c7a13e3943a76e33c372814ba41dfe3dc5b058683bacab
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cards, splits, from_aces, das = x
def v(c):
return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
acts = ['stand']
if from_aces:
return acts
total = 0
aces = 0
for c in cards:
total += v(c)
aces += c[0] == 'A'
while total > 21 and aces:
total -= 10
aces -= 1
if total >= 21:
return acts
acts.append('hit')
two = len(cards) == 2
if two and (splits == 0 or das):
acts.append('double')
if two and v(cards[0]) == v(cards[1]) and splits < 3:
acts.append('split')
if two and splits == 0:
acts.append('surrender')
return acts
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'QS'], 0, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['JH', '6S', 'TH'], 3, False, False], ['stand']], [[['3S', '9S', '9D'], 3, False, False], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['4H', 'AD', 'QC', 'JC'], 3, False, True], ['stand']], [[['KS', 'AC'], 2, False, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['KD', 'KD', 'JH', '6C'], 0, False, False], ['stand']], [[['9S', 'TH', '2D'], 0, False, True], ['stand']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['JH', 'JD', 'AS'], 0, False, True], ['stand']], [[['QC', 'QH', 'TH', '8H'], 0, False, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("actions 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 |
|---|---|---|---|
| actions case 0 | ['stand'] | ['stand'] | Passed |
| actions case 1 | ['stand', 'hit', 'double', 'surrender'] | ['stand', 'hit', 'double', 'surrender'] | Passed |
| actions case 2 | ['stand'] | ['stand'] | Passed |
| actions case 3 | ['stand'] | ['stand'] | Passed |
| actions case 4 | ['stand'] | ['stand'] | Passed |
| actions case 5 | ['stand'] | ['stand'] | Passed |
| actions case 6 | ['stand', 'hit'] | ['stand', 'hit'] | Passed |
| actions case 7 | ['stand'] | ['stand'] | Passed |
SHA-256 / 3e509d5a264648e9e8d6e5205278dc21f8d96cc3565c3b22fa2f28240f472908
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:24.403714+00:00.
Case digest / d4a67d5a5edab5216be96d33376b592a9b37de4c01d4937097b3c91d4d0aaca7