FA-83726 / Card game rule engines / Open access
Surrender is offered after splitting · case 01
Split hands may surrender.
ROOT CAUSE
The surrender test only checks the card count.
VERIFIED REPAIR
Surrender only on the initial two-card hand.
Unsuccessful approach: Dropping the two-card test allows surrender after 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:
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']], [[['9C', '2S', '9H'], 0, False, True], ['stand', 'hit']]], [[[['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']], [[['KH', '9H'], 1, False, True], ['stand', 'hit', 'double']], [[['AC', '4H', '4S'], 0, False, False], ['stand', 'hit']]], [[[['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']], [[['KC', 'KH'], 1, True, True], ['stand']], [[['KS', '3D', '2C'], 0, 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']], [[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['6D', '2C', '8D', 'AD'], 0, False, True], ['stand', 'hit']]], [[[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]]]
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', 'surrender'] | ['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'] | ['stand', 'hit'] | Passed |
SHA-256 / ca5e3f6c41e4219d32dd80d3e6bd6a126f1f5eeb7b11d9600629f5e4d870def3
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 (splits == 0 or das):
acts.append('double')
if two and v(cards[0]) == v(cards[1]) and splits < 3:
acts.append('split')
if 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']], [[['9C', '2S', '9H'], 0, False, True], ['stand', 'hit']]], [[[['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']], [[['KH', '9H'], 1, False, True], ['stand', 'hit', 'double']], [[['AC', '4H', '4S'], 0, False, False], ['stand', 'hit']]], [[[['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']], [[['KC', 'KH'], 1, True, True], ['stand']], [[['KS', '3D', '2C'], 0, 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']], [[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['6D', '2C', '8D', 'AD'], 0, False, True], ['stand', 'hit']]], [[[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]]]
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', 'surrender'] | ['stand', 'hit'] | Failed |
| actions case 7 | ['stand', 'hit', 'surrender'] | ['stand', 'hit'] | Failed |
SHA-256 / de6899d8bb67fdde1d4478fff3ff8bd034443a67bfd177a58dbc991b51f21d16
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']], [[['9C', '2S', '9H'], 0, False, True], ['stand', 'hit']]], [[[['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']], [[['KH', '9H'], 1, False, True], ['stand', 'hit', 'double']], [[['AC', '4H', '4S'], 0, False, False], ['stand', 'hit']]], [[[['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']], [[['KC', 'KH'], 1, True, True], ['stand']], [[['KS', '3D', '2C'], 0, 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']], [[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['6D', '2C', '8D', 'AD'], 0, False, True], ['stand', 'hit']]], [[[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['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']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]]]
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'] | ['stand', 'hit'] | Passed |
SHA-256 / 27763e905e004776b6de5b835e2912be2259f34ca4f6e74e6654913b92fcabc8
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.263210+00:00.
Case digest / 64d9067438c96631d1d0c718bb786835f52b9d0c6feeeb664ca451d0558149ea