FA-82306 / Poker hand evaluation / Open access
Chen score rounded to even instead of up · case 01
Nine-seven offsuit scores 2 instead of 3.
ROOT CAUSE
The final score uses round(), which rounds halves to the even neighbour.
VERIFIED REPAIR
Round the final Chen score up.
Unsuccessful approach: int() truncates halves downward.
Case contract
Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.
Why this case matters
Starting-hand heuristics in training tools and bots use this scoring.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
pts={14:10,13:8,12:7,11:6}
a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
s=pts.get(a, a/2)
if a==b:
s=max(s*2,5)
else:
if x[0][1]==x[1][1]: s+=2
gap=a-b-1
s-={0:0,1:1,2:2,3:4}.get(gap,5)
if gap<=1 and a<12: s+=1
return round(s)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
[('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
[('seven six suited', ['7h', '6h'], 7), ('king nine suited', ['Kc', '9c'], 6),
('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, 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 |
|---|---|---|---|
| pocket aces | 20 | 20 | Passed |
| pocket deuces | 5 | 5 | Passed |
| pocket fives | 5 | 5 | Passed |
| ace king suited | 12 | 12 | Passed |
| seven six suited | 6 | 7 | Failed |
| nine seven offsuit | 4 | 5 | Failed |
| queen jack suited | 9 | 9 | Passed |
| ace five offsuit | 5 | 5 | Passed |
SHA-256 / 7167d5e27441e7aebffb810bfb8ca6c2976d4b3f8e5f46e9bf4491860070fa32
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
pts={14:10,13:8,12:7,11:6}
a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
s=pts.get(a, a/2)
if a==b:
s=max(s*2,5)
else:
if x[0][1]==x[1][1]: s+=2
gap=a-b-1
s-={0:0,1:1,2:2,3:4}.get(gap,5)
if gap<=1 and a<12: s+=1
return int(s)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
[('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
[('seven six suited', ['7h', '6h'], 7), ('king nine suited', ['Kc', '9c'], 6),
('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, 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 |
|---|---|---|---|
| pocket aces | 20 | 20 | Passed |
| pocket deuces | 5 | 5 | Passed |
| pocket fives | 5 | 5 | Passed |
| ace king suited | 12 | 12 | Passed |
| seven six suited | 6 | 7 | Failed |
| nine seven offsuit | 4 | 5 | Failed |
| queen jack suited | 9 | 9 | Passed |
| ace five offsuit | 5 | 5 | Passed |
SHA-256 / 6230d33449e858c8405d2dddd7ad5d93f19862d0841f3c3266c7982e5373dbfa
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
pts={14:10,13:8,12:7,11:6}
a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
s=pts.get(a, a/2)
if a==b:
s=max(s*2,5)
else:
if x[0][1]==x[1][1]: s+=2
gap=a-b-1
s-={0:0,1:1,2:2,3:4}.get(gap,5)
if gap<=1 and a<12: s+=1
return math.ceil(s)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
[('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
[('seven six suited', ['7h', '6h'], 7), ('king nine suited', ['Kc', '9c'], 6),
('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, 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 |
|---|---|---|---|
| pocket aces | 20 | 20 | Passed |
| pocket deuces | 5 | 5 | Passed |
| pocket fives | 5 | 5 | Passed |
| ace king suited | 12 | 12 | Passed |
| seven six suited | 7 | 7 | Passed |
| nine seven offsuit | 5 | 5 | Passed |
| queen jack suited | 9 | 9 | Passed |
| ace five offsuit | 5 | 5 | Passed |
SHA-256 / 8f4e1ff53392ac49603d7479d6b85ee90e32faf28c1465346de4d61c2cf2a770
Verification & scope
A deterministic toy model with an explicitly stated contract; card strings are rank+suit (for example "As", "Td"); no claim of conformance to any casino or tournament rulebook. 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:10.819167+00:00.
Case digest / 20a8cd45de50f29e4751b5e81e2e58b3dc0071e191a31e50799a12d40117bad5