FAILURE MAP
← Case archive

FA-82286 / Poker hand evaluation / Open access

Half-point card values truncated · case 01

Nine-high, seven-high and five-high hands score a point lower than they should.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Half the rank is computed with integer division, discarding the 0.5 before the final round-up.

VERIFIED REPAIR

Keep the half point and round only the final score.

Unsuccessful approach: round() uses banker's rounding, so 4.5 and 2.5 still round down.

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 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), ('nine five offsuit', ['9c', '5d'], 1)],
 [('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)],
 [('nine seven offsuit', ['9h', '7d'], 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), ('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)]]
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 fixtureActualExpectedOutcome
pocket aces2020Passed
pocket deuces55Passed
pocket fives55Passed
ace king suited1212Passed
seven six suited67Failed
nine seven offsuit45Failed
queen jack suited99Passed
nine five offsuit01Failed

SHA-256 / b0367f082571543eca89dec35dd93c1ed5a732e20cb3a8a631dcd6727ebbc67b

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, round(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), ('nine five offsuit', ['9c', '5d'], 1)],
 [('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)],
 [('nine seven offsuit', ['9h', '7d'], 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), ('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)]]
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 fixtureActualExpectedOutcome
pocket aces2020Passed
pocket deuces55Passed
pocket fives55Passed
ace king suited1212Passed
seven six suited77Passed
nine seven offsuit45Failed
queen jack suited99Passed
nine five offsuit01Failed

SHA-256 / b6b6808d3172d24db56e1b3873f677cbaf9b705bd3ac6c44688017c7ecd3131a

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), ('nine five offsuit', ['9c', '5d'], 1)],
 [('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)],
 [('nine seven offsuit', ['9h', '7d'], 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), ('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),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)]]
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 fixtureActualExpectedOutcome
pocket aces2020Passed
pocket deuces55Passed
pocket fives55Passed
ace king suited1212Passed
seven six suited77Passed
nine seven offsuit55Passed
queen jack suited99Passed
nine five offsuit11Passed

SHA-256 / d903aae546e9320a1d49f4969238c885b5c4970ef55a339d351ea0ba7d0a0bda

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.737703+00:00.

Case digest / 7edded46ab902a95cb62f78607eeadce0c335ae548bca081bcdafa38fdb306b9