FA-83451 / Card game rule engines / Open access
A failed nil helps the partner make the contract · case 01
Tricks taken by a failed nil bidder count toward the partner bid.
ROOT CAUSE
Failed nil tricks are added to made tricks.
VERIFIED REPAIR
Failed nil tricks only become bags.
Unsuccessful approach: Dropping failed nil tricks entirely forgets the bags they produce.
Case contract
Input [[bid1, bid2], [tricks1, tricks2], bags_before]. Nil (0) bids score +100 if the player took no tricks, else -100 and their tricks become bags. Other bids combine into a contract made by the non-nil players tricks: made -> 10*bid + 1 per overtrick (overtricks are bags); set -> -10*bid. Every 10 accumulated bags costs 100 and removes 10 bags. Return [score_delta, bags].
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):
bids, tricks, bags = x
score = 0
contract = 0
made = 0
for b, t in zip(bids, tricks):
if b == 0:
if t == 0:
score += 100
else:
score -= 100
made += t
else:
contract += b
made += t
if made >= contract:
score += 10 * contract
over = made - contract
score += over
bags += over
else:
score -= 10 * contract
while bags >= 10:
score -= 100
bags -= 10
return [score, bags]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[5, 0], [13, 0], 5], [58, 3]], [[[0, 2], [12, 1], 4], [-220, 6]], [[[3, 5], [1, 12], 3], [85, 8]], [[[5, 5], [12, 1], 1], [103, 4]], [[[0, 4], [3, 10], 5], [-154, 4]], [[[3, 6], [3, 8], 9], [-8, 1]], [[[5, 5], [12, 0], 5], [102, 7]], [[[5, 0], [0, 10], 7], [-250, 7]]], [[[[1, 4], [6, 4], 5], [-45, 0]], [[[4, 0], [1, 8], 8], [-240, 6]], [[[1, 0], [9, 2], 4], [-182, 4]], [[[5, 1], [6, 7], 3], [-33, 0]], [[[1, 4], [3, 8], 0], [56, 6]], [[[1, 6], [2, 0], 5], [-70, 5]], [[[4, 5], [9, 4], 4], [94, 8]], [[[3, 0], [11, 2], 0], [-162, 0]]], [[[[2, 3], [8, 3], 4], [-44, 0]], [[[1, 5], [7, 0], 2], [61, 3]], [[[3, 4], [11, 1], 1], [75, 6]], [[[3, 1], [12, 0], 9], [-52, 7]], [[[5, 6], [7, 3], 6], [-110, 6]], [[[6, 0], [8, 3], 7], [-138, 2]], [[[5, 0], [0, 10], 7], [-250, 7]], [[[0, 5], [9, 4], 4], [-250, 3]]], [[[[1, 5], [10, 2], 7], [-34, 3]], [[[3, 5], [12, 0], 0], [84, 4]], [[[0, 4], [1, 4], 9], [-160, 0]], [[[6, 2], [3, 4], 8], [-80, 8]], [[[3, 2], [8, 2], 6], [-45, 1]], [[[3, 4], [7, 2], 9], [-28, 1]], [[[1, 0], [5, 8], 0], [-186, 2]], [[[0, 6], [11, 0], 1], [-260, 2]]], [[[[5, 3], [7, 2], 7], [81, 8]], [[[2, 2], [10, 1], 9], [-53, 6]], [[[3, 5], [9, 2], 5], [83, 8]], [[[5, 3], [7, 5], 2], [84, 6]], [[[6, 2], [8, 0], 9], [80, 9]], [[[3, 0], [2, 0], 9], [70, 9]], [[[0, 2], [8, 5], 5], [-177, 6]], [[[0, 0], [13, 0], 9], [-200, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("team 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 |
|---|---|---|---|
| team score case 0 | [58, 3] | [58, 3] | Passed |
| team score case 1 | [-169, 5] | [-220, 6] | Failed |
| team score case 2 | [85, 8] | [85, 8] | Passed |
| team score case 3 | [103, 4] | [103, 4] | Passed |
| team score case 4 | [-151, 4] | [-154, 4] | Failed |
| team score case 5 | [-8, 1] | [-8, 1] | Passed |
| team score case 6 | [102, 7] | [102, 7] | Passed |
| team score case 7 | [-145, 2] | [-250, 7] | Failed |
SHA-256 / b02e39819d6cd40bcd75d0c5696d7bbcf9c6526f8b62f0a2cbea763fc23ba9d7
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
bids, tricks, bags = x
score = 0
contract = 0
made = 0
for b, t in zip(bids, tricks):
if b == 0:
if t == 0:
score += 100
else:
score -= 100
else:
contract += b
made += t
if made >= contract:
score += 10 * contract
over = made - contract
score += over
bags += over
else:
score -= 10 * contract
while bags >= 10:
score -= 100
bags -= 10
return [score, bags]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[5, 0], [13, 0], 5], [58, 3]], [[[0, 2], [12, 1], 4], [-220, 6]], [[[3, 5], [1, 12], 3], [85, 8]], [[[5, 5], [12, 1], 1], [103, 4]], [[[0, 4], [3, 10], 5], [-154, 4]], [[[3, 6], [3, 8], 9], [-8, 1]], [[[5, 5], [12, 0], 5], [102, 7]], [[[5, 0], [0, 10], 7], [-250, 7]]], [[[[1, 4], [6, 4], 5], [-45, 0]], [[[4, 0], [1, 8], 8], [-240, 6]], [[[1, 0], [9, 2], 4], [-182, 4]], [[[5, 1], [6, 7], 3], [-33, 0]], [[[1, 4], [3, 8], 0], [56, 6]], [[[1, 6], [2, 0], 5], [-70, 5]], [[[4, 5], [9, 4], 4], [94, 8]], [[[3, 0], [11, 2], 0], [-162, 0]]], [[[[2, 3], [8, 3], 4], [-44, 0]], [[[1, 5], [7, 0], 2], [61, 3]], [[[3, 4], [11, 1], 1], [75, 6]], [[[3, 1], [12, 0], 9], [-52, 7]], [[[5, 6], [7, 3], 6], [-110, 6]], [[[6, 0], [8, 3], 7], [-138, 2]], [[[5, 0], [0, 10], 7], [-250, 7]], [[[0, 5], [9, 4], 4], [-250, 3]]], [[[[1, 5], [10, 2], 7], [-34, 3]], [[[3, 5], [12, 0], 0], [84, 4]], [[[0, 4], [1, 4], 9], [-160, 0]], [[[6, 2], [3, 4], 8], [-80, 8]], [[[3, 2], [8, 2], 6], [-45, 1]], [[[3, 4], [7, 2], 9], [-28, 1]], [[[1, 0], [5, 8], 0], [-186, 2]], [[[0, 6], [11, 0], 1], [-260, 2]]], [[[[5, 3], [7, 2], 7], [81, 8]], [[[2, 2], [10, 1], 9], [-53, 6]], [[[3, 5], [9, 2], 5], [83, 8]], [[[5, 3], [7, 5], 2], [84, 6]], [[[6, 2], [8, 0], 9], [80, 9]], [[[3, 0], [2, 0], 9], [70, 9]], [[[0, 2], [8, 5], 5], [-177, 6]], [[[0, 0], [13, 0], 9], [-200, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("team 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 |
|---|---|---|---|
| team score case 0 | [58, 3] | [58, 3] | Passed |
| team score case 1 | [-120, 4] | [-220, 6] | Failed |
| team score case 2 | [85, 8] | [85, 8] | Passed |
| team score case 3 | [103, 4] | [103, 4] | Passed |
| team score case 4 | [-154, 1] | [-154, 4] | Failed |
| team score case 5 | [-8, 1] | [-8, 1] | Passed |
| team score case 6 | [102, 7] | [102, 7] | Passed |
| team score case 7 | [-150, 7] | [-250, 7] | Failed |
SHA-256 / a936b1c4c6368f89ecfd5fc7594a3c9fd1a178d936914bf366d706e04990b687
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
bids, tricks, bags = x
score = 0
contract = 0
made = 0
for b, t in zip(bids, tricks):
if b == 0:
if t == 0:
score += 100
else:
score -= 100
bags += t
else:
contract += b
made += t
if made >= contract:
score += 10 * contract
over = made - contract
score += over
bags += over
else:
score -= 10 * contract
while bags >= 10:
score -= 100
bags -= 10
return [score, bags]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[5, 0], [13, 0], 5], [58, 3]], [[[0, 2], [12, 1], 4], [-220, 6]], [[[3, 5], [1, 12], 3], [85, 8]], [[[5, 5], [12, 1], 1], [103, 4]], [[[0, 4], [3, 10], 5], [-154, 4]], [[[3, 6], [3, 8], 9], [-8, 1]], [[[5, 5], [12, 0], 5], [102, 7]], [[[5, 0], [0, 10], 7], [-250, 7]]], [[[[1, 4], [6, 4], 5], [-45, 0]], [[[4, 0], [1, 8], 8], [-240, 6]], [[[1, 0], [9, 2], 4], [-182, 4]], [[[5, 1], [6, 7], 3], [-33, 0]], [[[1, 4], [3, 8], 0], [56, 6]], [[[1, 6], [2, 0], 5], [-70, 5]], [[[4, 5], [9, 4], 4], [94, 8]], [[[3, 0], [11, 2], 0], [-162, 0]]], [[[[2, 3], [8, 3], 4], [-44, 0]], [[[1, 5], [7, 0], 2], [61, 3]], [[[3, 4], [11, 1], 1], [75, 6]], [[[3, 1], [12, 0], 9], [-52, 7]], [[[5, 6], [7, 3], 6], [-110, 6]], [[[6, 0], [8, 3], 7], [-138, 2]], [[[5, 0], [0, 10], 7], [-250, 7]], [[[0, 5], [9, 4], 4], [-250, 3]]], [[[[1, 5], [10, 2], 7], [-34, 3]], [[[3, 5], [12, 0], 0], [84, 4]], [[[0, 4], [1, 4], 9], [-160, 0]], [[[6, 2], [3, 4], 8], [-80, 8]], [[[3, 2], [8, 2], 6], [-45, 1]], [[[3, 4], [7, 2], 9], [-28, 1]], [[[1, 0], [5, 8], 0], [-186, 2]], [[[0, 6], [11, 0], 1], [-260, 2]]], [[[[5, 3], [7, 2], 7], [81, 8]], [[[2, 2], [10, 1], 9], [-53, 6]], [[[3, 5], [9, 2], 5], [83, 8]], [[[5, 3], [7, 5], 2], [84, 6]], [[[6, 2], [8, 0], 9], [80, 9]], [[[3, 0], [2, 0], 9], [70, 9]], [[[0, 2], [8, 5], 5], [-177, 6]], [[[0, 0], [13, 0], 9], [-200, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("team 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 |
|---|---|---|---|
| team score case 0 | [58, 3] | [58, 3] | Passed |
| team score case 1 | [-220, 6] | [-220, 6] | Passed |
| team score case 2 | [85, 8] | [85, 8] | Passed |
| team score case 3 | [103, 4] | [103, 4] | Passed |
| team score case 4 | [-154, 4] | [-154, 4] | Passed |
| team score case 5 | [-8, 1] | [-8, 1] | Passed |
| team score case 6 | [102, 7] | [102, 7] | Passed |
| team score case 7 | [-250, 7] | [-250, 7] | Passed |
SHA-256 / 2c95a2ea757ea85b2b7a81464f5714c793d23a443052a3c250f8d6246c60238b
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:21.788925+00:00.
Case digest / ae0f7a6f7d4fb49f6689ad6fc14c599e273d4eeb61209df74143ddcaafe11449