FA-83606 / Card game rule engines / Open access
Vulnerable small slams get the non-vulnerable bonus · case 01
6S vulnerable made is 250 short.
ROOT CAUSE
The small-slam bonus ignores vulnerability.
VERIFIED REPAIR
Small slam is 750 vulnerable and 500 not.
Unsuccessful approach: Granting the bonus only with exactly twelve tricks drops it when an overtrick is made.
Case contract
Input [level, strain, doubled(0/1/2), vulnerable, tricks]. Trick score C/D 20, H/S 30, NT 40+30; x2/x4 doubled/redoubled. Game bonus 300/500 when trick score >= 100 else 50 partscore; slam 500/750 (6) or 1000/1500 (7); overtricks trick value undoubled, 100/200 per double level; insult 50 per double level. Undertricks: 50/100 undoubled; doubled NV 100, 200, 200, then 300; doubled V 200 then 300; redoubled x2.
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):
level, strain, dbl, vul, tricks = x
need = 6 + level
if tricks < need:
down = need - tricks
if dbl == 0:
return -(100 if vul else 50) * down
pen = 0
for k in range(1, down + 1):
if vul:
pen += 200 if k == 1 else 300
else:
pen += 100 if k == 1 else 200 if k <= 3 else 300
return -pen * dbl
per = 20 if strain in 'CD' else 30
base = per * level + (10 if strain == 'N' else 0)
mult = [1, 2, 4][dbl]
trick_score = base * mult
score = trick_score
score += (500 if vul else 300) if trick_score >= 100 else 50
if level == 6:
score += 500
elif level == 7:
score += 1500 if vul else 1000
over = tricks - need
if dbl == 0:
score += over * per
else:
score += over * (200 if vul else 100) * dbl
score += 50 * dbl
return score
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[4, 'C', 1, False, 10], 510], [[7, 'S', 0, True, 12], -100], [[6, 'N', 0, True, 12], 1440], [[2, 'H', 1, True, 9], 870], [[3, 'H', 2, False, 11], 1160], [[5, 'N', 0, False, 11], 460], [[2, 'D', 0, True, 8], 90], [[6, 'H', 0, False, 13], 1010]], [[[6, 'S', 0, False, 12], 980], [[7, 'D', 0, True, 8], -500], [[6, 'H', 0, False, 12], 980], [[6, 'H', 0, False, 11], -50], [[6, 'N', 0, False, 12], 990], [[6, 'D', 2, True, 13], 2230], [[6, 'S', 0, True, 12], 1430], [[6, 'H', 1, True, 13], 1860]], [[[6, 'H', 0, True, 13], 1460], [[2, 'C', 0, True, 9], 110], [[4, 'N', 0, False, 12], 490], [[7, 'C', 0, True, 13], 2140], [[3, 'S', 1, False, 5], -800], [[5, 'C', 2, False, 13], 1200], [[6, 'S', 1, True, 13], 1860], [[6, 'D', 2, True, 12], 1830]], [[[6, 'D', 2, True, 13], 2230], [[2, 'C', 2, False, 7], -200], [[2, 'H', 2, False, 5], -1000], [[7, 'H', 2, False, 11], -600], [[3, 'N', 1, True, 7], -500], [[6, 'S', 0, True, 12], 1430], [[4, 'C', 0, False, 6], -200], [[6, 'H', 1, True, 13], 1860]], [[[1, 'D', 2, True, 6], -400], [[5, 'H', 0, True, 11], 650], [[4, 'D', 0, True, 7], -300], [[7, 'D', 1, True, 10], -800], [[4, 'C', 1, True, 9], -200], [[3, 'S', 2, True, 9], 960], [[6, 'S', 0, True, 13], 1460], [[6, 'S', 0, True, 13], 1460]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("duplicate score 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 |
|---|---|---|---|
| duplicate score case 0 | 510 | 510 | Passed |
| duplicate score case 1 | -100 | -100 | Passed |
| duplicate score case 2 | 1190 | 1440 | Failed |
| duplicate score case 3 | 870 | 870 | Passed |
| duplicate score case 4 | 1160 | 1160 | Passed |
| duplicate score case 5 | 460 | 460 | Passed |
| duplicate score case 6 | 90 | 90 | Passed |
| duplicate score case 7 | 1010 | 1010 | Passed |
SHA-256 / 66b8f6308cd0f00fdf01f2731f2dc063b9981bd8f359b3e509263b953c350de9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
level, strain, dbl, vul, tricks = x
need = 6 + level
if tricks < need:
down = need - tricks
if dbl == 0:
return -(100 if vul else 50) * down
pen = 0
for k in range(1, down + 1):
if vul:
pen += 200 if k == 1 else 300
else:
pen += 100 if k == 1 else 200 if k <= 3 else 300
return -pen * dbl
per = 20 if strain in 'CD' else 30
base = per * level + (10 if strain == 'N' else 0)
mult = [1, 2, 4][dbl]
trick_score = base * mult
score = trick_score
score += (500 if vul else 300) if trick_score >= 100 else 50
if level == 6 and tricks == 12:
score += 750 if vul else 500
elif level == 7:
score += 1500 if vul else 1000
over = tricks - need
if dbl == 0:
score += over * per
else:
score += over * (200 if vul else 100) * dbl
score += 50 * dbl
return score
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[4, 'C', 1, False, 10], 510], [[7, 'S', 0, True, 12], -100], [[6, 'N', 0, True, 12], 1440], [[2, 'H', 1, True, 9], 870], [[3, 'H', 2, False, 11], 1160], [[5, 'N', 0, False, 11], 460], [[2, 'D', 0, True, 8], 90], [[6, 'H', 0, False, 13], 1010]], [[[6, 'S', 0, False, 12], 980], [[7, 'D', 0, True, 8], -500], [[6, 'H', 0, False, 12], 980], [[6, 'H', 0, False, 11], -50], [[6, 'N', 0, False, 12], 990], [[6, 'D', 2, True, 13], 2230], [[6, 'S', 0, True, 12], 1430], [[6, 'H', 1, True, 13], 1860]], [[[6, 'H', 0, True, 13], 1460], [[2, 'C', 0, True, 9], 110], [[4, 'N', 0, False, 12], 490], [[7, 'C', 0, True, 13], 2140], [[3, 'S', 1, False, 5], -800], [[5, 'C', 2, False, 13], 1200], [[6, 'S', 1, True, 13], 1860], [[6, 'D', 2, True, 12], 1830]], [[[6, 'D', 2, True, 13], 2230], [[2, 'C', 2, False, 7], -200], [[2, 'H', 2, False, 5], -1000], [[7, 'H', 2, False, 11], -600], [[3, 'N', 1, True, 7], -500], [[6, 'S', 0, True, 12], 1430], [[4, 'C', 0, False, 6], -200], [[6, 'H', 1, True, 13], 1860]], [[[1, 'D', 2, True, 6], -400], [[5, 'H', 0, True, 11], 650], [[4, 'D', 0, True, 7], -300], [[7, 'D', 1, True, 10], -800], [[4, 'C', 1, True, 9], -200], [[3, 'S', 2, True, 9], 960], [[6, 'S', 0, True, 13], 1460], [[6, 'S', 0, True, 13], 1460]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("duplicate score 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 |
|---|---|---|---|
| duplicate score case 0 | 510 | 510 | Passed |
| duplicate score case 1 | -100 | -100 | Passed |
| duplicate score case 2 | 1440 | 1440 | Passed |
| duplicate score case 3 | 870 | 870 | Passed |
| duplicate score case 4 | 1160 | 1160 | Passed |
| duplicate score case 5 | 460 | 460 | Passed |
| duplicate score case 6 | 90 | 90 | Passed |
| duplicate score case 7 | 510 | 1010 | Failed |
SHA-256 / a09e69373d7780f5d8488c4ec5b48b9d004a2f1f69fc347883db050edcf5be1d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
level, strain, dbl, vul, tricks = x
need = 6 + level
if tricks < need:
down = need - tricks
if dbl == 0:
return -(100 if vul else 50) * down
pen = 0
for k in range(1, down + 1):
if vul:
pen += 200 if k == 1 else 300
else:
pen += 100 if k == 1 else 200 if k <= 3 else 300
return -pen * dbl
per = 20 if strain in 'CD' else 30
base = per * level + (10 if strain == 'N' else 0)
mult = [1, 2, 4][dbl]
trick_score = base * mult
score = trick_score
score += (500 if vul else 300) if trick_score >= 100 else 50
if level == 6:
score += 750 if vul else 500
elif level == 7:
score += 1500 if vul else 1000
over = tricks - need
if dbl == 0:
score += over * per
else:
score += over * (200 if vul else 100) * dbl
score += 50 * dbl
return score
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[4, 'C', 1, False, 10], 510], [[7, 'S', 0, True, 12], -100], [[6, 'N', 0, True, 12], 1440], [[2, 'H', 1, True, 9], 870], [[3, 'H', 2, False, 11], 1160], [[5, 'N', 0, False, 11], 460], [[2, 'D', 0, True, 8], 90], [[6, 'H', 0, False, 13], 1010]], [[[6, 'S', 0, False, 12], 980], [[7, 'D', 0, True, 8], -500], [[6, 'H', 0, False, 12], 980], [[6, 'H', 0, False, 11], -50], [[6, 'N', 0, False, 12], 990], [[6, 'D', 2, True, 13], 2230], [[6, 'S', 0, True, 12], 1430], [[6, 'H', 1, True, 13], 1860]], [[[6, 'H', 0, True, 13], 1460], [[2, 'C', 0, True, 9], 110], [[4, 'N', 0, False, 12], 490], [[7, 'C', 0, True, 13], 2140], [[3, 'S', 1, False, 5], -800], [[5, 'C', 2, False, 13], 1200], [[6, 'S', 1, True, 13], 1860], [[6, 'D', 2, True, 12], 1830]], [[[6, 'D', 2, True, 13], 2230], [[2, 'C', 2, False, 7], -200], [[2, 'H', 2, False, 5], -1000], [[7, 'H', 2, False, 11], -600], [[3, 'N', 1, True, 7], -500], [[6, 'S', 0, True, 12], 1430], [[4, 'C', 0, False, 6], -200], [[6, 'H', 1, True, 13], 1860]], [[[1, 'D', 2, True, 6], -400], [[5, 'H', 0, True, 11], 650], [[4, 'D', 0, True, 7], -300], [[7, 'D', 1, True, 10], -800], [[4, 'C', 1, True, 9], -200], [[3, 'S', 2, True, 9], 960], [[6, 'S', 0, True, 13], 1460], [[6, 'S', 0, True, 13], 1460]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("duplicate score 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 |
|---|---|---|---|
| duplicate score case 0 | 510 | 510 | Passed |
| duplicate score case 1 | -100 | -100 | Passed |
| duplicate score case 2 | 1440 | 1440 | Passed |
| duplicate score case 3 | 870 | 870 | Passed |
| duplicate score case 4 | 1160 | 1160 | Passed |
| duplicate score case 5 | 460 | 460 | Passed |
| duplicate score case 6 | 90 | 90 | Passed |
| duplicate score case 7 | 1010 | 1010 | Passed |
SHA-256 / 9824a2f6823c53bb57b1230e46fff914793bbdaee91cc7a138ec8ff82ee13100
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:23.294386+00:00.
Case digest / 80e8c6e65379c82afd257dd4871db2195721ef4d107a38f093e91cb059823afe