FA-82871 / Go territory scoring / Open access
Dead stones still block territory after being marked · case 01
Territory around a dead invader is scored as dame and the dead point itself is never territory.
ROOT CAUSE
The dead-stone loop credits prisoners but never clears the point on the working board.
THE FAILURE
The dead-stone loop credits prisoners but never clears the point on the working board.
Unsuccessful approach: Replacing the dead stone with a capturing-colour stone forms the border but never counts the point itself, and a repeated mark flips it back.
Case contract
Input [board, dead_points, prisoners_held_by_black, prisoners_held_by_white, komi_tenths]. Each listed dead stone is removed once and becomes a prisoner of its opponent (duplicates and empty points are ignored). Territory = empty regions (after removal) bordered by one colour only. Return [terr_b, terr_w, pris_b, pris_w, result] with result "B+x.y", "W+x.y" or "Jigo".
Why this case matters
Go servers and scoring tools compute this value automatically; a wrong answer changes a game result.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
board, dead, capb, capw, komi = x
g = [list(row) for row in board]
pb = capb
pw = capw
for r, c in dead:
if g[r][c] == 'B':
pw += 1
elif g[r][c] == 'W':
pb += 1
n = len(g)
m = len(g[0])
tb = 0
tw = 0
seen = set()
for r in range(n):
for c in range(m):
if g[r][c] != '.' or (r, c) in seen:
continue
stack = [(r, c)]
seen.add((r, c))
size = 0
owners = set()
while stack:
i, j = stack.pop()
size += 1
for p, q in ((i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)):
if 0 <= p < n and 0 <= q < m:
if g[p][q] == '.':
if (p, q) not in seen:
seen.add((p, q))
stack.append((p, q))
else:
owners.add(g[p][q])
if owners == {'B'}:
tb += size
elif owners == {'W'}:
tw += size
sb = (tb + pb) * 10
sw = (tw + pw) * 10 + komi
if sb > sw:
res = 'B+%d.%d' % ((sb - sw) // 10, (sb - sw) % 10)
elif sw > sb:
res = 'W+%d.%d' % ((sw - sb) // 10, (sw - sb) % 10)
else:
res = 'Jigo'
return [tb, tw, pb, pw, res]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['W...BW', '....BW', '....BW', '....BW'], [[1, 4], [1, 4]], 1, 0, 55], [0, 0, 1, 1, 'W+5.5']], [[['..WBW', '...BW', '...BW', 'W..BW'], [[0, 3], [3, 4], [3, 0]], 3, 0, 65], [0, 0, 5, 1, 'W+2.5']], [[['..BW.', '..BW.', '..BW.', '..BWB', '..BW.', '..BW.'], [[3, 2], [3, 2]], 1, 1, 0], [0, 0, 1, 2, 'W+1.0']], [[['.BW.B..', '.BW....', '.BW....', '.BW.B..', '.BW....', '.BW.B..', '.BW....'], [[4, 2], [2, 1], [6, 1]], 3, 0, 0], [0, 0, 4, 2, 'B+2.0']], [[['.....BW', '....WBW', '.W...BW', '..W..BW', '...W.BW'], [[4, 5]], 0, 0, 65], [0, 0, 0, 1, 'W+7.5']], [[['W..BW.', '..WBW.', 'W..BW.', '...BW.', '...BW.', '..WBW.'], [[1, 2], [5, 2], [0, 4]], 0, 3, 5], [0, 0, 3, 3, 'W+0.5']], [[['W.BW..', 'W.BW..', '..BW..', '.WBW..', '..BW..', '..BW..', '..BW..'], [[3, 2]], 3, 3, 0], [0, 14, 3, 4, 'W+15.0']], [[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']]], [[[['..BW.', '..BW.', '..BW.', '..BWB', '..BW.', '..BW.'], [[3, 2], [3, 2]], 1, 1, 0], [0, 0, 1, 2, 'W+1.0']], [[['....BW.', '....BW.', '.W..BW.', '...WBW.', '...WBWB', '....BW.'], [[5, 1]], 4, 3, 55], [0, 0, 4, 3, 'W+4.5']], [[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']], [[['..BW', '.WBW', '..BW', '..BW'], [[3, 2], [0, 3], [3, 2]], 0, 4, 60], [0, 0, 1, 5, 'W+10.0']], [[['....BWB', '....BW.', '....BW.', '....BWB'], [[2, 5]], 4, 1, 0], [16, 0, 5, 1, 'B+20.0']], [[['.BW.', '.BW.', '.BW.', '.BW.'], [[3, 1]], 1, 1, 60], [0, 4, 1, 2, 'W+11.0']], [[['..BW', '..BW', '..BW', '..BW', '..BW', '..BW', '..BW'], [[0, 2], [6, 2], [5, 3]], 1, 1, 0], [0, 0, 2, 3, 'W+1.0']], [[['.....BW', '.....BW', '.....BW', '.W...BW', '.....BW'], [[3, 5], [1, 5], [3, 6], [3, 5]], 0, 3, 5], [0, 0, 1, 5, 'W+4.5']]], [[[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']], [[['.BW.', '.BW.', '.BW.', '.BW.', '.BWB', '.BWB', 'WBW.'], [[4, 1], [4, 1]], 0, 2, 0], [0, 0, 0, 3, 'W+3.0']], [[['W.BW...', '.WBW...', '..BW..B', '..BW...', '.WBWB..', '..BW...'], [[4, 4], [4, 0]], 3, 1, 55], [0, 0, 3, 2, 'W+4.5']], [[['WBW.B..', '.BW.B..', '.BWBB..', 'WBW....', '.BW.B..', '.BW.B..', 'WBW....'], [[2, 2], [6, 2], [2, 2]], 0, 1, 5], [0, 0, 2, 1, 'B+0.5']], [[['..BW', '.WBW', '..BW', '..BW', '..BW', '..BW'], [[1, 3], [3, 3], [1, 3]], 4, 1, 55], [0, 0, 6, 1, 'W+0.5']], [[['.....BW', '.....BW', '.....BW', '.W...BW', '.....BW'], [[3, 5], [1, 5], [3, 6], [3, 5]], 0, 3, 5], [0, 0, 1, 5, 'W+4.5']], [[['..BW..', '..BW.B', '..BW..', '..BW.B', 'W.BW..', '..BW..', '..BW..'], [[2, 2], [2, 2]], 2, 1, 0], [0, 0, 2, 2, 'Jigo']], [[['.B.', 'B.B', '.B.'], [[0, 1], [2, 1], [0, 1]], 0, 1, 5], [7, 0, 0, 3, 'B+3.5']]], [[[['..BW', '..BW', '..BW', '..BW', '..BW', '..BW', '..BW'], [[0, 2], [6, 2], [5, 3]], 1, 1, 0], [0, 0, 2, 3, 'W+1.0']], [[['W...BW', '....BW', '....BW', '....BW', '....BW'], [[0, 0], [0, 4]], 0, 0, 5], [0, 0, 1, 1, 'W+0.5']], [[['..BWB', '..BWB', 'W.BW.', '..BW.', '..BW.'], [], 2, 4, 55], [0, 0, 2, 4, 'W+7.5']], [[['.BW..', 'WBWB.', '.BW..', 'WBW..', '.BW..'], [[2, 1], [3, 1]], 2, 2, 0], [0, 0, 2, 4, 'W+2.0']], [[['..BW...', '..BWB..', '.WBW...', '..BW.B.', 'W.BW...', '..BW...', '..BWBB.'], [[6, 2]], 2, 0, 65], [0, 0, 2, 1, 'W+5.5']], [[['.BW..', '.BW..', '.BW..', '.BW..', '.BWB.', '.BW..', 'WBW..'], [[0, 2], [0, 2]], 0, 2, 0], [0, 0, 1, 2, 'W+1.0']], [[['W..BW', '...BW', '...BW', '...BW', '...BW', '...BW', '...BW'], [], 2, 1, 65], [0, 0, 2, 1, 'W+5.5']], [[['WWW', 'W.W', 'WWW'], [[0, 1], [2, 2]], 1, 3, 65], [0, 3, 3, 3, 'W+9.5']]], [[[['..BW', '.WBW', '..BW', '..BW', '..BW', '..BW'], [[1, 3], [3, 3], [1, 3]], 4, 1, 55], [0, 0, 6, 1, 'W+0.5']], [[['...BWBB', 'W..BW..', '..WBW..', '...BW..', '...BW.B', '...BWB.'], [[3, 4]], 2, 4, 5], [1, 0, 3, 4, 'W+0.5']], [[['.BW...', '.BWB..', '.BW...', '.BW...', '.BW...', '.BW...', '.BW.BB'], [[1, 1], [1, 1], [2, 4]], 4, 1, 60], [0, 0, 4, 2, 'W+4.0']], [[['...BW', '...BW', 'W..BW', '...BW', '.W.BW', '...BW', 'W..BW'], [], 1, 1, 0], [0, 0, 1, 1, 'Jigo']], [[['....BW.', 'W..WBW.', 'W...BW.', '..W.BW.', '....BW.', '....BW.'], [[3, 4], [4, 4], [1, 0], [2, 3]], 1, 3, 65], [0, 6, 2, 5, 'W+15.5']], [[['....', '....', '....', '....'], [], 4, 0, 60], [0, 0, 4, 0, 'W+2.0']], [[['...', '...', '...'], [], 3, 2, 65], [0, 0, 3, 2, 'W+5.5']], [[['...B', 'BW.B', 'BB.B', 'B...', '..B.', '.BBB'], [[2, 0], [2, 0]], 1, 2, 0], [1, 0, 1, 3, 'W+1.0']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("territory 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 |
|---|---|---|---|
| territory score case 0 | [0, 0, 1, 2, 'W+6.5'] | [0, 0, 1, 1, 'W+5.5'] | Failed |
| territory score case 1 | [0, 0, 5, 1, 'W+2.5'] | [0, 0, 5, 1, 'W+2.5'] | Passed |
| territory score case 2 | [12, 0, 1, 3, 'B+10.0'] | [0, 0, 1, 2, 'W+1.0'] | Failed |
| territory score case 3 | [7, 0, 4, 2, 'B+9.0'] | [0, 0, 4, 2, 'B+2.0'] | Failed |
| territory score case 4 | [0, 0, 0, 1, 'W+7.5'] | [0, 0, 0, 1, 'W+7.5'] | Passed |
| territory score case 5 | [0, 6, 3, 3, 'W+6.5'] | [0, 0, 3, 3, 'W+0.5'] | Failed |
| territory score case 6 | [0, 14, 3, 4, 'W+15.0'] | [0, 14, 3, 4, 'W+15.0'] | Passed |
| territory score case 7 | [15, 0, 0, 3, 'B+11.5'] | [0, 0, 0, 2, 'W+2.5'] | Failed |
SHA-256 / a0b552cc82659a1f0ee600e226e049b05295e1677adef9154d5f69e22a7f59d3
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
board, dead, capb, capw, komi = x
g = [list(row) for row in board]
pb = capb
pw = capw
for r, c in dead:
if g[r][c] == 'B':
pw += 1
elif g[r][c] == 'W':
pb += 1
g[r][c] = 'W' if g[r][c] == 'B' else 'B'
n = len(g)
m = len(g[0])
tb = 0
tw = 0
seen = set()
for r in range(n):
for c in range(m):
if g[r][c] != '.' or (r, c) in seen:
continue
stack = [(r, c)]
seen.add((r, c))
size = 0
owners = set()
while stack:
i, j = stack.pop()
size += 1
for p, q in ((i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)):
if 0 <= p < n and 0 <= q < m:
if g[p][q] == '.':
if (p, q) not in seen:
seen.add((p, q))
stack.append((p, q))
else:
owners.add(g[p][q])
if owners == {'B'}:
tb += size
elif owners == {'W'}:
tw += size
sb = (tb + pb) * 10
sw = (tw + pw) * 10 + komi
if sb > sw:
res = 'B+%d.%d' % ((sb - sw) // 10, (sb - sw) % 10)
elif sw > sb:
res = 'W+%d.%d' % ((sw - sb) // 10, (sw - sb) % 10)
else:
res = 'Jigo'
return [tb, tw, pb, pw, res]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['W...BW', '....BW', '....BW', '....BW'], [[1, 4], [1, 4]], 1, 0, 55], [0, 0, 1, 1, 'W+5.5']], [[['..WBW', '...BW', '...BW', 'W..BW'], [[0, 3], [3, 4], [3, 0]], 3, 0, 65], [0, 0, 5, 1, 'W+2.5']], [[['..BW.', '..BW.', '..BW.', '..BWB', '..BW.', '..BW.'], [[3, 2], [3, 2]], 1, 1, 0], [0, 0, 1, 2, 'W+1.0']], [[['.BW.B..', '.BW....', '.BW....', '.BW.B..', '.BW....', '.BW.B..', '.BW....'], [[4, 2], [2, 1], [6, 1]], 3, 0, 0], [0, 0, 4, 2, 'B+2.0']], [[['.....BW', '....WBW', '.W...BW', '..W..BW', '...W.BW'], [[4, 5]], 0, 0, 65], [0, 0, 0, 1, 'W+7.5']], [[['W..BW.', '..WBW.', 'W..BW.', '...BW.', '...BW.', '..WBW.'], [[1, 2], [5, 2], [0, 4]], 0, 3, 5], [0, 0, 3, 3, 'W+0.5']], [[['W.BW..', 'W.BW..', '..BW..', '.WBW..', '..BW..', '..BW..', '..BW..'], [[3, 2]], 3, 3, 0], [0, 14, 3, 4, 'W+15.0']], [[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']]], [[[['..BW.', '..BW.', '..BW.', '..BWB', '..BW.', '..BW.'], [[3, 2], [3, 2]], 1, 1, 0], [0, 0, 1, 2, 'W+1.0']], [[['....BW.', '....BW.', '.W..BW.', '...WBW.', '...WBWB', '....BW.'], [[5, 1]], 4, 3, 55], [0, 0, 4, 3, 'W+4.5']], [[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']], [[['..BW', '.WBW', '..BW', '..BW'], [[3, 2], [0, 3], [3, 2]], 0, 4, 60], [0, 0, 1, 5, 'W+10.0']], [[['....BWB', '....BW.', '....BW.', '....BWB'], [[2, 5]], 4, 1, 0], [16, 0, 5, 1, 'B+20.0']], [[['.BW.', '.BW.', '.BW.', '.BW.'], [[3, 1]], 1, 1, 60], [0, 4, 1, 2, 'W+11.0']], [[['..BW', '..BW', '..BW', '..BW', '..BW', '..BW', '..BW'], [[0, 2], [6, 2], [5, 3]], 1, 1, 0], [0, 0, 2, 3, 'W+1.0']], [[['.....BW', '.....BW', '.....BW', '.W...BW', '.....BW'], [[3, 5], [1, 5], [3, 6], [3, 5]], 0, 3, 5], [0, 0, 1, 5, 'W+4.5']]], [[[['...BW..', '...BWB.', '...BW..', '...BW..', '...BW..'], [[0, 3], [0, 3], [4, 2]], 0, 1, 5], [0, 0, 0, 2, 'W+2.5']], [[['.BW.', '.BW.', '.BW.', '.BW.', '.BWB', '.BWB', 'WBW.'], [[4, 1], [4, 1]], 0, 2, 0], [0, 0, 0, 3, 'W+3.0']], [[['W.BW...', '.WBW...', '..BW..B', '..BW...', '.WBWB..', '..BW...'], [[4, 4], [4, 0]], 3, 1, 55], [0, 0, 3, 2, 'W+4.5']], [[['WBW.B..', '.BW.B..', '.BWBB..', 'WBW....', '.BW.B..', '.BW.B..', 'WBW....'], [[2, 2], [6, 2], [2, 2]], 0, 1, 5], [0, 0, 2, 1, 'B+0.5']], [[['..BW', '.WBW', '..BW', '..BW', '..BW', '..BW'], [[1, 3], [3, 3], [1, 3]], 4, 1, 55], [0, 0, 6, 1, 'W+0.5']], [[['.....BW', '.....BW', '.....BW', '.W...BW', '.....BW'], [[3, 5], [1, 5], [3, 6], [3, 5]], 0, 3, 5], [0, 0, 1, 5, 'W+4.5']], [[['..BW..', '..BW.B', '..BW..', '..BW.B', 'W.BW..', '..BW..', '..BW..'], [[2, 2], [2, 2]], 2, 1, 0], [0, 0, 2, 2, 'Jigo']], [[['.B.', 'B.B', '.B.'], [[0, 1], [2, 1], [0, 1]], 0, 1, 5], [7, 0, 0, 3, 'B+3.5']]], [[[['..BW', '..BW', '..BW', '..BW', '..BW', '..BW', '..BW'], [[0, 2], [6, 2], [5, 3]], 1, 1, 0], [0, 0, 2, 3, 'W+1.0']], [[['W...BW', '....BW', '....BW', '....BW', '....BW'], [[0, 0], [0, 4]], 0, 0, 5], [0, 0, 1, 1, 'W+0.5']], [[['..BWB', '..BWB', 'W.BW.', '..BW.', '..BW.'], [], 2, 4, 55], [0, 0, 2, 4, 'W+7.5']], [[['.BW..', 'WBWB.', '.BW..', 'WBW..', '.BW..'], [[2, 1], [3, 1]], 2, 2, 0], [0, 0, 2, 4, 'W+2.0']], [[['..BW...', '..BWB..', '.WBW...', '..BW.B.', 'W.BW...', '..BW...', '..BWBB.'], [[6, 2]], 2, 0, 65], [0, 0, 2, 1, 'W+5.5']], [[['.BW..', '.BW..', '.BW..', '.BW..', '.BWB.', '.BW..', 'WBW..'], [[0, 2], [0, 2]], 0, 2, 0], [0, 0, 1, 2, 'W+1.0']], [[['W..BW', '...BW', '...BW', '...BW', '...BW', '...BW', '...BW'], [], 2, 1, 65], [0, 0, 2, 1, 'W+5.5']], [[['WWW', 'W.W', 'WWW'], [[0, 1], [2, 2]], 1, 3, 65], [0, 3, 3, 3, 'W+9.5']]], [[[['..BW', '.WBW', '..BW', '..BW', '..BW', '..BW'], [[1, 3], [3, 3], [1, 3]], 4, 1, 55], [0, 0, 6, 1, 'W+0.5']], [[['...BWBB', 'W..BW..', '..WBW..', '...BW..', '...BW.B', '...BWB.'], [[3, 4]], 2, 4, 5], [1, 0, 3, 4, 'W+0.5']], [[['.BW...', '.BWB..', '.BW...', '.BW...', '.BW...', '.BW...', '.BW.BB'], [[1, 1], [1, 1], [2, 4]], 4, 1, 60], [0, 0, 4, 2, 'W+4.0']], [[['...BW', '...BW', 'W..BW', '...BW', '.W.BW', '...BW', 'W..BW'], [], 1, 1, 0], [0, 0, 1, 1, 'Jigo']], [[['....BW.', 'W..WBW.', 'W...BW.', '..W.BW.', '....BW.', '....BW.'], [[3, 4], [4, 4], [1, 0], [2, 3]], 1, 3, 65], [0, 6, 2, 5, 'W+15.5']], [[['....', '....', '....', '....'], [], 4, 0, 60], [0, 0, 4, 0, 'W+2.0']], [[['...', '...', '...'], [], 3, 2, 65], [0, 0, 3, 2, 'W+5.5']], [[['...B', 'BW.B', 'BB.B', 'B...', '..B.', '.BBB'], [[2, 0], [2, 0]], 1, 2, 0], [1, 0, 1, 3, 'W+1.0']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("territory 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 |
|---|---|---|---|
| territory score case 0 | [0, 0, 2, 1, 'W+4.5'] | [0, 0, 1, 1, 'W+5.5'] | Failed |
| territory score case 1 | [0, 0, 5, 1, 'W+2.5'] | [0, 0, 5, 1, 'W+2.5'] | Passed |
| territory score case 2 | [12, 0, 2, 2, 'B+12.0'] | [0, 0, 1, 2, 'W+1.0'] | Failed |
| territory score case 3 | [0, 0, 4, 2, 'B+2.0'] | [0, 0, 4, 2, 'B+2.0'] | Passed |
| territory score case 4 | [0, 0, 0, 1, 'W+7.5'] | [0, 0, 0, 1, 'W+7.5'] | Passed |
| territory score case 5 | [0, 0, 3, 3, 'W+0.5'] | [0, 0, 3, 3, 'W+0.5'] | Passed |
| territory score case 6 | [0, 14, 3, 4, 'W+15.0'] | [0, 14, 3, 4, 'W+15.0'] | Passed |
| territory score case 7 | [14, 0, 1, 2, 'B+12.5'] | [0, 0, 0, 2, 'W+2.5'] | Failed |
SHA-256 / 6858fbdf3244c4607eea601b0044b7032680906bfd3cd6a9d758c86caf371acb
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
Small rectangular toy boards given as strings of B, W and dot; a bounded teaching model of one scoring or bookkeeping rule, not a complete rules engine or server implementation. 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:16.072814+00:00.
Case digest / 6616dc768305f0f66f50ed229239007350a4b8ed6db1ab509c1d3a1913e35491