FA-83746 / Card game rule engines / Open access
A single can beat a pair · case 01
Plays of a different size are compared by rank alone.
ROOT CAUSE
The same-size requirement is missing.
VERIFIED REPAIR
A response must have the same number of cards.
Unsuccessful approach: Allowing larger combinations over smaller ones still breaks the same-size rule.
Case contract
Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".
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):
cur, play = x
order = '3456789TJQKA2'
suits = 'DCHS'
def key(c):
return (order.index(c[0]), suits.index(c[1]))
if not play:
return 'pass'
if len(set(c[0] for c in play)) != 1 or len(play) > 3:
return 'invalid'
if not cur:
return 'ok'
if max(key(c) for c in play) > max(key(c) for c in cur):
return 'ok'
return 'invalid'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7S'], ['9S', '9C']], 'invalid'], [[['KC', 'KD'], ['KH', 'KS']], 'ok'], [[['8S', '8C', '8H'], ['KD', 'KC', 'KS']], 'ok'], [[['6S'], ['6H']], 'invalid'], [[['9C'], ['6S']], 'invalid'], [[[], ['3H', '3S', '3C']], 'ok'], [[['7D'], ['7S']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['8D', '8H'], ['8S', '8D', '8H', '8C']], 'invalid'], [[['AS'], ['AH', 'AC', 'AD']], 'invalid'], [[[], ['3C']], 'ok'], [[['QD'], ['QH']], 'ok'], [[['JD', 'JS'], ['TD', 'TS', 'TC', 'TH']], 'invalid'], [[['9S', '9H'], ['8S', '8C']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['KD'], ['AH']], 'ok'], [[[], ['KS', 'KD']], 'ok'], [[['JC'], ['7C']], 'invalid'], [[['5S'], ['5H']], 'invalid'], [[['2S'], ['5D']], 'invalid'], [[['3C', '3H'], ['3S', '3D']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['JH', 'JC'], ['JC', 'JS']], 'ok'], [[['7C'], ['2D']], 'ok'], [[['2H'], ['2H']], 'invalid'], [[['TH', 'TD'], ['8D', '2S']], 'invalid'], [[['5H', '5D'], ['JS', 'JC']], 'ok'], [[[], ['QC', 'QH']], 'ok'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['3D', '3H', '3C'], ['3S', '3D', '3H', 'AC']], 'invalid'], [[['5S'], ['3S']], 'invalid'], [[['9C'], ['9C']], 'invalid'], [[['7C', '7S', '7D'], ['3D', '3S', '3C']], 'invalid'], [[['3H', '3C'], ['3D', '3C', '3S', '3H']], 'invalid'], [[[], ['5H']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("play 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 |
|---|---|---|---|
| play case 0 | ok | invalid | Failed |
| play case 1 | ok | ok | Passed |
| play case 2 | ok | ok | Passed |
| play case 3 | invalid | invalid | Passed |
| play case 4 | invalid | invalid | Passed |
| play case 5 | ok | ok | Passed |
| play case 6 | ok | ok | Passed |
| play case 7 | ok | invalid | Failed |
SHA-256 / c02f4351c34204fa44ed1f183fcec6ebcbcfad0b5c2a2be1eecc6c1e74cd0fd2
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cur, play = x
order = '3456789TJQKA2'
suits = 'DCHS'
def key(c):
return (order.index(c[0]), suits.index(c[1]))
if not play:
return 'pass'
if len(set(c[0] for c in play)) != 1 or len(play) > 3:
return 'invalid'
if not cur:
return 'ok'
if len(play) < len(cur):
return 'invalid'
if max(key(c) for c in play) > max(key(c) for c in cur):
return 'ok'
return 'invalid'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7S'], ['9S', '9C']], 'invalid'], [[['KC', 'KD'], ['KH', 'KS']], 'ok'], [[['8S', '8C', '8H'], ['KD', 'KC', 'KS']], 'ok'], [[['6S'], ['6H']], 'invalid'], [[['9C'], ['6S']], 'invalid'], [[[], ['3H', '3S', '3C']], 'ok'], [[['7D'], ['7S']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['8D', '8H'], ['8S', '8D', '8H', '8C']], 'invalid'], [[['AS'], ['AH', 'AC', 'AD']], 'invalid'], [[[], ['3C']], 'ok'], [[['QD'], ['QH']], 'ok'], [[['JD', 'JS'], ['TD', 'TS', 'TC', 'TH']], 'invalid'], [[['9S', '9H'], ['8S', '8C']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['KD'], ['AH']], 'ok'], [[[], ['KS', 'KD']], 'ok'], [[['JC'], ['7C']], 'invalid'], [[['5S'], ['5H']], 'invalid'], [[['2S'], ['5D']], 'invalid'], [[['3C', '3H'], ['3S', '3D']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['JH', 'JC'], ['JC', 'JS']], 'ok'], [[['7C'], ['2D']], 'ok'], [[['2H'], ['2H']], 'invalid'], [[['TH', 'TD'], ['8D', '2S']], 'invalid'], [[['5H', '5D'], ['JS', 'JC']], 'ok'], [[[], ['QC', 'QH']], 'ok'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['3D', '3H', '3C'], ['3S', '3D', '3H', 'AC']], 'invalid'], [[['5S'], ['3S']], 'invalid'], [[['9C'], ['9C']], 'invalid'], [[['7C', '7S', '7D'], ['3D', '3S', '3C']], 'invalid'], [[['3H', '3C'], ['3D', '3C', '3S', '3H']], 'invalid'], [[[], ['5H']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("play 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 |
|---|---|---|---|
| play case 0 | ok | invalid | Failed |
| play case 1 | ok | ok | Passed |
| play case 2 | ok | ok | Passed |
| play case 3 | invalid | invalid | Passed |
| play case 4 | invalid | invalid | Passed |
| play case 5 | ok | ok | Passed |
| play case 6 | ok | ok | Passed |
| play case 7 | ok | invalid | Failed |
SHA-256 / e8591d0cd1651cc00f83e0c0abb35a54556b0ba072d309b283fe110bf4ac88dd
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cur, play = x
order = '3456789TJQKA2'
suits = 'DCHS'
def key(c):
return (order.index(c[0]), suits.index(c[1]))
if not play:
return 'pass'
if len(set(c[0] for c in play)) != 1 or len(play) > 3:
return 'invalid'
if not cur:
return 'ok'
if len(play) != len(cur):
return 'invalid'
if max(key(c) for c in play) > max(key(c) for c in cur):
return 'ok'
return 'invalid'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7S'], ['9S', '9C']], 'invalid'], [[['KC', 'KD'], ['KH', 'KS']], 'ok'], [[['8S', '8C', '8H'], ['KD', 'KC', 'KS']], 'ok'], [[['6S'], ['6H']], 'invalid'], [[['9C'], ['6S']], 'invalid'], [[[], ['3H', '3S', '3C']], 'ok'], [[['7D'], ['7S']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['8D', '8H'], ['8S', '8D', '8H', '8C']], 'invalid'], [[['AS'], ['AH', 'AC', 'AD']], 'invalid'], [[[], ['3C']], 'ok'], [[['QD'], ['QH']], 'ok'], [[['JD', 'JS'], ['TD', 'TS', 'TC', 'TH']], 'invalid'], [[['9S', '9H'], ['8S', '8C']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid'], [[['9C'], ['TD', 'TS']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['KD'], ['AH']], 'ok'], [[[], ['KS', 'KD']], 'ok'], [[['JC'], ['7C']], 'invalid'], [[['5S'], ['5H']], 'invalid'], [[['2S'], ['5D']], 'invalid'], [[['3C', '3H'], ['3S', '3D']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']], [[[['JH', 'JC'], ['JC', 'JS']], 'ok'], [[['7C'], ['2D']], 'ok'], [[['2H'], ['2H']], 'invalid'], [[['TH', 'TD'], ['8D', '2S']], 'invalid'], [[['5H', '5D'], ['JS', 'JC']], 'ok'], [[[], ['QC', 'QH']], 'ok'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid'], [[['QH'], ['QS', 'QH', 'QC']], 'invalid']], [[[['7S'], ['9S', '9C']], 'invalid'], [[['3D', '3H', '3C'], ['3S', '3D', '3H', 'AC']], 'invalid'], [[['5S'], ['3S']], 'invalid'], [[['9C'], ['9C']], 'invalid'], [[['7C', '7S', '7D'], ['3D', '3S', '3C']], 'invalid'], [[['3H', '3C'], ['3D', '3C', '3S', '3H']], 'invalid'], [[[], ['5H']], 'ok'], [[['6S'], ['2S', '2H', '2C']], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("play 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 |
|---|---|---|---|
| play case 0 | invalid | invalid | Passed |
| play case 1 | ok | ok | Passed |
| play case 2 | ok | ok | Passed |
| play case 3 | invalid | invalid | Passed |
| play case 4 | invalid | invalid | Passed |
| play case 5 | ok | ok | Passed |
| play case 6 | ok | ok | Passed |
| play case 7 | invalid | invalid | Passed |
SHA-256 / 91ea2439311766145b9346b2b141ecf2f12bd35a8a7021aa173cb40321c336cb
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.578959+00:00.
Case digest / 6fe74317ca32be1013b94514d50e5dc64e9e7687e7e2a83dee091ec79d7c2c34