FA-83716 / Card game rule engines / Open access
Doubling is offered after a split without DAS · case 01
Split hands can double on tables that forbid it.
ROOT CAUSE
The double test ignores the split count and DAS flag.
VERIFIED REPAIR
Double on two cards when unsplit or DAS is allowed.
Unsuccessful approach: Requiring DAS for every double forbids doubling unsplit hands.
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:
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', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['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']], [[['6C', '6H'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['JH', 'JS'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]], [[[['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']], [[['TD', 'TH'], 2, False, False], ['stand', 'hit', 'split']], [[['7H', '6C'], 0, False, False], ['stand', 'hit', 'double', 'surrender']]], [[[['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']], [[['QH', '7C'], 3, False, False], ['stand', 'hit']], [[['4C', '4D'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]]]
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', 'split'] | ['stand', 'hit', 'split'] | 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', 'hit', 'double', 'split', 'surrender'] | ['stand', 'hit', 'double', 'split', 'surrender'] | Passed |
SHA-256 / a13d7991582f5fb9f041a622effe12e8fe036b99bf044fae2e7596a787827b01
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:
return acts
acts.append('hit')
two = len(cards) == 2
if two and 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', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['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']], [[['6C', '6H'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['JH', 'JS'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]], [[[['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']], [[['TD', 'TH'], 2, False, False], ['stand', 'hit', 'split']], [[['7H', '6C'], 0, False, False], ['stand', 'hit', 'double', 'surrender']]], [[[['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']], [[['QH', '7C'], 3, False, False], ['stand', 'hit']], [[['4C', '4D'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]]]
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', 'split'] | ['stand', 'hit', 'split'] | 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', 'hit', 'split', 'surrender'] | ['stand', 'hit', 'double', 'split', 'surrender'] | Failed |
SHA-256 / 1647dfa1b09a28e4f6b7e59efe76b9ef6457fd394ac73b2801139e72951bd934
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', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['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']], [[['6C', '6H'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['JH', 'JS'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]], [[[['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']], [[['TD', 'TH'], 2, False, False], ['stand', 'hit', 'split']], [[['7H', '6C'], 0, False, False], ['stand', 'hit', 'double', 'surrender']]], [[[['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']], [[['QH', '7C'], 3, False, False], ['stand', 'hit']], [[['4C', '4D'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]]]
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', 'split'] | ['stand', 'hit', 'split'] | 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', 'hit', 'double', 'split', 'surrender'] | ['stand', 'hit', 'double', 'split', 'surrender'] | Passed |
SHA-256 / ef53ac9dd24544bdcbd8f061882f9bb6f52f741d8aff6d5368705cb880921da3
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.099543+00:00.
Case digest / 9143dc3050dd51f4583f7718940710d015c1873a11e0fb5e8127d9a7e95259bb