FAILURE MAP
← Case archive

FA-87481 / Collision detection broadphase / Open access

Quadtree splits when a node reaches capacity rather than exceeding it · case 01

Nodes split one object early, creating extra nodes.

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

ROOT CAUSE

The split test is len >= cap.

VERIFIED REPAIR

Split only when the count exceeds cap.

Unsuccessful approach: Waiting until cap+2 objects splits too late.

Case contract

solve(objs, cap, max_depth, q): quadtree over [0,16]^2. Insert [id,minx,miny,maxx,maxy] in order. A node splits when it holds more than cap objects and depth<max_depth; children are ordered cy*2+cx. An object goes to a child only if it fits entirely: maxx<mid -> left, minx>=mid -> right (same for y); straddlers stay. On split all node objects are re-inserted. Query returns [sorted ids of objects in nodes whose closed bounds overlap q, total node count, max depth].

Why this case matters

Broadphase stages decide which object pairs ever reach narrowphase; a wrong boundary, ordering or bookkeeping rule silently drops real contacts or floods the solver with false candidates.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(objs, cap, max_depth, q):
    def make(x, y, s, d):
        return {'x': x, 'y': y, 's': s, 'd': d, 'objs': [], 'kids': None}
    def child_index(n, o):
        h = n['s'] / 2
        mx, my = n['x'] + h, n['y'] + h
        if o[3] < mx:
            cx = 0
        elif o[1] >= mx:
            cx = 1
        else:
            return -1
        if o[4] < my:
            cy = 0
        elif o[2] >= my:
            cy = 1
        else:
            return -1
        return cy * 2 + cx
    def split(n):
        h = n['s'] / 2
        n['kids'] = [make(n['x'] + (k % 2) * h, n['y'] + (k // 2) * h, h, n['d'] + 1) for k in range(4)]
        old, n['objs'] = n['objs'], []
        for o in old:
            insert(n, o)
    def insert(n, o):
        if n['kids'] is not None:
            k = child_index(n, o)
            if k >= 0:
                insert(n['kids'][k], o)
                return
        n['objs'].append(o)
        if n['kids'] is None and len(n['objs']) >= cap and n['d'] < max_depth:
            split(n)
    root = make(0, 0, 16, 0)
    for o in objs:
        insert(root, o)
    found, count, deep = [], 0, 0
    stack = [root]
    while stack:
        n = stack.pop()
        count += 1
        deep = max(deep, n['d'])
        if n['kids']:
            stack.extend(n['kids'])
        if n['x'] <= q[2] and q[0] <= n['x'] + n['s'] and n['y'] <= q[3] and q[1] <= n['y'] + n['s']:
            found.extend(o[0] for o in n['objs'])
    return [sorted(found), count, deep]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[33, 5, 0, 5, 0], [11, 7, 11, 9, 13], [5, 15, 13, 16, 15], [6, 11, 8, 13, 11], [22, 14, 12, 16, 15], [34, 2, 8, 4, 8], [3, 2, 7, 3, 8], [31, 11, 2, 14, 5]], 1, 2, [8, 14, 9, 18]], [[3, 6, 11, 34], 9, 2]], [[[[14, 3, 6, 3, 7], [33, 13, 2, 16, 5], [4, 9, 15, 9, 15], [13, 7, 4, 9, 6], [45, 8, 14, 11, 16], [29, 11, 3, 11, 4], [43, 0, 2, 0, 5]], 1, 2, [12, 1, 17, 3]], [[13, 29, 33], 17, 2]], [[[[30, 11, 15, 14, 16], [41, 3, 15, 3, 16], [11, 3, 1, 3, 4], [17, 2, 13, 2, 14], [42, 14, 6, 16, 7], [2, 10, 9, 13, 9]], 2, 1, [7, 6, 9, 8]], [[2, 11, 17, 30, 41, 42], 5, 1]], [[[[7, 15, 7, 16, 9], [25, 3, 3, 6, 4], [9, 0, 4, 3, 6], [15, 11, 10, 14, 10]], 3, 2, [9, 10, 13, 13]], [[7, 15], 5, 1]], [[[[25, 10, 12, 13, 13], [34, 12, 13, 15, 15], [8, 9, 2, 10, 2]], 2, 2, [12, 11, 14, 13]], [[25, 34], 5, 1]], [[[[29, 1, 10, 1, 12], [19, 5, 10, 6, 11]], 2, 3, [3, 1, 8, 2]], [[19, 29], 1, 0]], [[[[31, 11, 9, 12, 9], [29, 6, 3, 7, 5], [11, 14, 7, 14, 7], [16, 0, 7, 0, 9], [33, 15, 11, 16, 11], [4, 12, 0, 13, 3], [20, 12, 14, 13, 16], [49, 7, 6, 8, 7]], 1, 3, [12, 4, 14, 6]], [[4, 11, 16, 49], 13, 2]], [[[[49, 7, 3, 10, 3], [38, 8, 0, 8, 2], [11, 12, 4, 12, 4], [5, 4, 10, 4, 11], [3, 12, 6, 15, 7], [21, 0, 13, 1, 14], [35, 10, 7, 10, 10], [9, 9, 10, 12, 12]], 2, 2, [9, 2, 10, 7]], [[35, 38, 49], 9, 2]]], [[[[[46, 11, 12, 13, 13], [4, 4, 11, 4, 14], [41, 4, 13, 4, 13], [2, 0, 8, 1, 11], [45, 5, 5, 8, 5], [3, 2, 4, 4, 5], [39, 15, 12, 16, 13], [25, 12, 8, 14, 11]], 1, 2, [0, 0, 5, 1]], [[3, 45], 13, 2]], [[[[28, 9, 14, 12, 16], [29, 2, 3, 2, 6], [23, 8, 0, 8, 2], [17, 2, 9, 5, 11], [33, 15, 5, 16, 7], [46, 14, 15, 16, 16], [14, 13, 0, 16, 3]], 2, 2, [0, 14, 1, 18]], [[17], 9, 2]], [[[[43, 15, 9, 16, 9], [33, 11, 1, 11, 2], [32, 13, 12, 14, 14], [49, 8, 4, 9, 4]], 1, 2, [4, 4, 5, 7]], [[], 13, 2]], [[[[49, 11, 0, 11, 3], [23, 7, 12, 8, 15], [14, 0, 5, 3, 6], [30, 1, 4, 3, 6], [37, 2, 5, 4, 6], [28, 9, 9, 11, 11]], 1, 3, [6, 1, 7, 3]], [[23, 37], 13, 3]], [[[[40, 2, 4, 4, 4], [39, 7, 9, 7, 12], [24, 5, 11, 5, 14], [34, 3, 14, 5, 16], [13, 2, 0, 3, 0], [37, 8, 1, 9, 4], [45, 10, 5, 13, 8], [27, 3, 14, 3, 16], [22, 14, 0, 14, 3]], 3, 2, [14, 3, 16, 4]], [[22, 37, 45], 9, 2]], [[[[28, 8, 5, 10, 8], [39, 4, 12, 4, 12], [10, 4, 1, 4, 4], [29, 14, 11, 16, 13], [4, 6, 14, 6, 14], [22, 1, 0, 3, 0]], 1, 1, [11, 11, 15, 15]], [[28, 29], 5, 1]], [[[[1, 4, 0, 5, 3], [17, 10, 15, 12, 16]], 2, 2, [13, 9, 14, 14]], [[1, 17], 1, 0]], [[[[10, 6, 9, 7, 12], [1, 4, 1, 6, 1], [47, 2, 4, 2, 4], [34, 5, 5, 6, 8], [37, 5, 5, 7, 5], [39, 5, 10, 5, 12], [42, 9, 1, 10, 2], [46, 0, 1, 2, 3], [16, 15, 9, 16, 10]], 1, 1, [3, 10, 3, 14]], [[10, 34, 39], 5, 1]]], [[[[[42, 9, 3, 10, 5], [26, 12, 6, 14, 7], [12, 15, 5, 16, 7], [28, 0, 7, 0, 8], [3, 1, 10, 3, 13], [22, 0, 11, 0, 14], [13, 5, 1, 8, 2], [45, 5, 7, 6, 10], [40, 13, 2, 14, 5]], 3, 3, [12, 11, 15, 11]], [[13, 28, 45], 9, 2]], [[[[25, 9, 7, 10, 8], [29, 11, 3, 11, 6], [9, 14, 6, 16, 7], [44, 4, 5, 4, 8], [35, 2, 15, 4, 15], [12, 9, 10, 10, 10], [10, 8, 7, 11, 8], [43, 15, 0, 16, 3], [22, 14, 0, 16, 0], [16, 15, 6, 16, 8]], 1, 3, [2, 8, 4, 13]], [[10, 16, 25, 35, 44], 13, 3]], [[[[18, 11, 11, 13, 11], [5, 13, 2, 16, 5], [20, 4, 15, 4, 15], [32, 7, 4, 10, 4]], 3, 2, [11, 3, 16, 7]], [[5, 32], 5, 1]], [[[[45, 6, 7, 8, 9], [29, 7, 0, 8, 1], [8, 2, 4, 3, 5], [39, 6, 9, 6, 10], [31, 7, 13, 7, 14], [47, 1, 2, 3, 4]], 3, 2, [1, 0, 1, 0]], [[8, 29, 45, 47], 5, 1]], [[[[35, 12, 4, 14, 4], [20, 10, 12, 10, 14], [9, 4, 13, 6, 13], [44, 12, 10, 14, 11], [12, 10, 6, 12, 8]], 1, 2, [5, 6, 7, 8]], [[9, 12], 9, 2]], [[[[45, 14, 6, 15, 9], [39, 2, 8, 3, 8], [34, 8, 1, 9, 1], [32, 14, 13, 16, 16], [46, 0, 14, 2, 14], [8, 4, 14, 7, 16], [16, 15, 13, 15, 14]], 2, 3, [5, 11, 8, 15]], [[8, 16, 32, 45], 9, 2]], [[[[31, 9, 1, 11, 1], [18, 6, 9, 9, 9], [28, 4, 7, 5, 8]], 2, 3, [14, 6, 16, 10]], [[18, 28, 31], 5, 1]], [[[[38, 4, 9, 7, 11], [44, 15, 10, 16, 12], [13, 13, 12, 13, 13]], 2, 3, [10, 5, 12, 6]], [[], 5, 1]]], [[[[[17, 6, 9, 8, 12], [37, 8, 2, 10, 2], [42, 11, 14, 12, 14], [39, 9, 8, 10, 9], [34, 7, 2, 7, 5], [32, 13, 4, 16, 7], [23, 2, 9, 2, 10], [1, 4, 10, 7, 13], [40, 4, 2, 4, 3], [29, 4, 11, 6, 14]], 2, 2, [0, 9, 3, 13]], [[1, 17, 23, 29], 9, 2]], [[[[34, 14, 5, 16, 8], [30, 14, 15, 16, 16], [19, 2, 8, 2, 10], [43, 14, 5, 16, 5], [47, 5, 8, 8, 8], [9, 8, 10, 8, 12], [8, 1, 14, 2, 16]], 3, 2, [4, 12, 4, 16]], [[8, 19, 34, 47], 5, 1]], [[[[42, 15, 0, 16, 0], [34, 2, 5, 2, 6], [30, 0, 9, 0, 11], [32, 12, 9, 13, 11], [24, 9, 2, 11, 2], [2, 7, 9, 7, 9], [20, 13, 13, 16, 14], [22, 3, 14, 5, 14]], 3, 2, [1, 11, 4, 15]], [[2, 22, 30], 5, 1]], [[[[3, 10, 6, 12, 7], [4, 10, 14, 11, 15], [29, 6, 7, 6, 10], [26, 10, 15, 11, 16]], 2, 3, [12, 12, 13, 13]], [[4, 26, 29], 5, 1]], [[[[12, 6, 1, 9, 3], [29, 14, 6, 16, 9]], 1, 2, [11, 9, 12, 9]], [[12, 29], 5, 1]], [[[[6, 4, 7, 6, 9], [39, 15, 0, 15, 2], [13, 11, 7, 12, 8], [7, 14, 1, 14, 1], [8, 14, 3, 14, 4], [5, 6, 13, 7, 15], [15, 1, 8, 2, 8]], 1, 3, [1, 7, 3, 10]], [[6, 13, 15], 17, 3]], [[[[41, 6, 5, 8, 5], [26, 7, 5, 10, 6], [45, 5, 12, 5, 12], [1, 3, 10, 4, 13], [44, 7, 14, 9, 14]], 1, 1, [8, 9, 8, 14]], [[1, 26, 41, 44, 45], 5, 1]], [[[[7, 13, 7, 14, 10], [49, 6, 5, 9, 6], [35, 8, 9, 10, 9]], 2, 3, [0, 10, 0, 13]], [[7, 49], 5, 1]]], [[[[[7, 10, 4, 10, 7], [28, 8, 10, 10, 13], [21, 14, 13, 16, 15], [9, 13, 6, 16, 7], [11, 11, 4, 11, 7], [27, 14, 5, 16, 8], [1, 0, 8, 3, 9], [19, 0, 7, 0, 8], [29, 0, 11, 1, 14]], 2, 2, [7, 6, 10, 6]], [[7, 11, 19, 27], 9, 2]], [[[[14, 6, 14, 7, 14], [42, 7, 2, 7, 5]], 1, 2, [5, 9, 7, 13]], [[14], 5, 1]], [[[[16, 13, 12, 14, 13], [6, 9, 12, 9, 14], [4, 5, 11, 7, 11], [22, 12, 2, 14, 4], [38, 1, 9, 1, 9], [19, 7, 11, 10, 14]], 2, 2, [13, 4, 18, 9]], [[6, 16, 19, 22], 5, 1]], [[[[29, 6, 0, 8, 3], [20, 11, 15, 11, 16], [27, 6, 12, 9, 15], [38, 0, 9, 2, 11], [30, 10, 9, 10, 10], [7, 2, 9, 3, 11], [48, 8, 11, 11, 14], [9, 2, 7, 2, 10]], 1, 2, [1, 4, 2, 6]], [[9, 27, 29], 13, 2]], [[[[30, 3, 7, 4, 8], [17, 13, 13, 13, 16], [36, 12, 0, 15, 1], [22, 12, 10, 15, 11]], 2, 1, [7, 4, 10, 7]], [[30, 36], 5, 1]], [[[[12, 0, 0, 1, 1], [5, 3, 7, 4, 10], [3, 10, 14, 13, 15]], 1, 1, [11, 9, 15, 10]], [[3, 5], 5, 1]], [[[[22, 10, 13, 12, 14], [17, 15, 1, 16, 4], [5, 11, 3, 12, 3], [49, 12, 0, 15, 0], [31, 2, 6, 2, 7], [18, 2, 12, 2, 14], [34, 2, 15, 2, 16], [28, 13, 14, 15, 16], [39, 0, 5, 3, 7], [30, 12, 1, 15, 1], [40, 0, 3, 1, 4], [45, 3, 6, 3, 9]], 2, 1, [0, 6, 2, 11]], [[18, 31, 34, 39, 40, 45], 5, 1]], [[[[34, 13, 8, 16, 9], [35, 0, 9, 2, 12], [8, 11, 12, 13, 13], [43, 12, 9, 15, 9], [42, 12, 3, 15, 5], [21, 13, 3, 13, 3], [27, 12, 0, 12, 3], [37, 6, 2, 8, 5], [25, 0, 9, 2, 12]], 2, 3, [10, 6, 10, 11]], [[8, 37, 42], 13, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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 fixtureActualExpectedOutcome
case 0[[3, 6, 11, 34], 21, 2][[3, 6, 11, 34], 9, 2]Failed
case 1[[13, 29, 33], 17, 2][[13, 29, 33], 17, 2]Passed
case 2[[2, 11, 17, 30, 41, 42], 5, 1][[2, 11, 17, 30, 41, 42], 5, 1]Passed
case 3[[7, 15], 5, 1][[7, 15], 5, 1]Passed
case 4[[25, 34], 9, 2][[25, 34], 5, 1]Failed
case 5[[], 9, 2][[19, 29], 1, 0]Failed
case 6[[4, 11, 16, 49], 33, 3][[4, 11, 16, 49], 13, 2]Failed
case 7[[35, 38, 49], 13, 2][[35, 38, 49], 9, 2]Failed

SHA-256 / b3e82f5848b451660c86a68e82e60a11cc7993f0aacf2f44561a266cce524ca4

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(objs, cap, max_depth, q):
    def make(x, y, s, d):
        return {'x': x, 'y': y, 's': s, 'd': d, 'objs': [], 'kids': None}
    def child_index(n, o):
        h = n['s'] / 2
        mx, my = n['x'] + h, n['y'] + h
        if o[3] < mx:
            cx = 0
        elif o[1] >= mx:
            cx = 1
        else:
            return -1
        if o[4] < my:
            cy = 0
        elif o[2] >= my:
            cy = 1
        else:
            return -1
        return cy * 2 + cx
    def split(n):
        h = n['s'] / 2
        n['kids'] = [make(n['x'] + (k % 2) * h, n['y'] + (k // 2) * h, h, n['d'] + 1) for k in range(4)]
        old, n['objs'] = n['objs'], []
        for o in old:
            insert(n, o)
    def insert(n, o):
        if n['kids'] is not None:
            k = child_index(n, o)
            if k >= 0:
                insert(n['kids'][k], o)
                return
        n['objs'].append(o)
        if n['kids'] is None and len(n['objs']) > cap + 1 and n['d'] < max_depth:
            split(n)
    root = make(0, 0, 16, 0)
    for o in objs:
        insert(root, o)
    found, count, deep = [], 0, 0
    stack = [root]
    while stack:
        n = stack.pop()
        count += 1
        deep = max(deep, n['d'])
        if n['kids']:
            stack.extend(n['kids'])
        if n['x'] <= q[2] and q[0] <= n['x'] + n['s'] and n['y'] <= q[3] and q[1] <= n['y'] + n['s']:
            found.extend(o[0] for o in n['objs'])
    return [sorted(found), count, deep]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[33, 5, 0, 5, 0], [11, 7, 11, 9, 13], [5, 15, 13, 16, 15], [6, 11, 8, 13, 11], [22, 14, 12, 16, 15], [34, 2, 8, 4, 8], [3, 2, 7, 3, 8], [31, 11, 2, 14, 5]], 1, 2, [8, 14, 9, 18]], [[3, 6, 11, 34], 9, 2]], [[[[14, 3, 6, 3, 7], [33, 13, 2, 16, 5], [4, 9, 15, 9, 15], [13, 7, 4, 9, 6], [45, 8, 14, 11, 16], [29, 11, 3, 11, 4], [43, 0, 2, 0, 5]], 1, 2, [12, 1, 17, 3]], [[13, 29, 33], 17, 2]], [[[[30, 11, 15, 14, 16], [41, 3, 15, 3, 16], [11, 3, 1, 3, 4], [17, 2, 13, 2, 14], [42, 14, 6, 16, 7], [2, 10, 9, 13, 9]], 2, 1, [7, 6, 9, 8]], [[2, 11, 17, 30, 41, 42], 5, 1]], [[[[7, 15, 7, 16, 9], [25, 3, 3, 6, 4], [9, 0, 4, 3, 6], [15, 11, 10, 14, 10]], 3, 2, [9, 10, 13, 13]], [[7, 15], 5, 1]], [[[[25, 10, 12, 13, 13], [34, 12, 13, 15, 15], [8, 9, 2, 10, 2]], 2, 2, [12, 11, 14, 13]], [[25, 34], 5, 1]], [[[[29, 1, 10, 1, 12], [19, 5, 10, 6, 11]], 2, 3, [3, 1, 8, 2]], [[19, 29], 1, 0]], [[[[31, 11, 9, 12, 9], [29, 6, 3, 7, 5], [11, 14, 7, 14, 7], [16, 0, 7, 0, 9], [33, 15, 11, 16, 11], [4, 12, 0, 13, 3], [20, 12, 14, 13, 16], [49, 7, 6, 8, 7]], 1, 3, [12, 4, 14, 6]], [[4, 11, 16, 49], 13, 2]], [[[[49, 7, 3, 10, 3], [38, 8, 0, 8, 2], [11, 12, 4, 12, 4], [5, 4, 10, 4, 11], [3, 12, 6, 15, 7], [21, 0, 13, 1, 14], [35, 10, 7, 10, 10], [9, 9, 10, 12, 12]], 2, 2, [9, 2, 10, 7]], [[35, 38, 49], 9, 2]]], [[[[[46, 11, 12, 13, 13], [4, 4, 11, 4, 14], [41, 4, 13, 4, 13], [2, 0, 8, 1, 11], [45, 5, 5, 8, 5], [3, 2, 4, 4, 5], [39, 15, 12, 16, 13], [25, 12, 8, 14, 11]], 1, 2, [0, 0, 5, 1]], [[3, 45], 13, 2]], [[[[28, 9, 14, 12, 16], [29, 2, 3, 2, 6], [23, 8, 0, 8, 2], [17, 2, 9, 5, 11], [33, 15, 5, 16, 7], [46, 14, 15, 16, 16], [14, 13, 0, 16, 3]], 2, 2, [0, 14, 1, 18]], [[17], 9, 2]], [[[[43, 15, 9, 16, 9], [33, 11, 1, 11, 2], [32, 13, 12, 14, 14], [49, 8, 4, 9, 4]], 1, 2, [4, 4, 5, 7]], [[], 13, 2]], [[[[49, 11, 0, 11, 3], [23, 7, 12, 8, 15], [14, 0, 5, 3, 6], [30, 1, 4, 3, 6], [37, 2, 5, 4, 6], [28, 9, 9, 11, 11]], 1, 3, [6, 1, 7, 3]], [[23, 37], 13, 3]], [[[[40, 2, 4, 4, 4], [39, 7, 9, 7, 12], [24, 5, 11, 5, 14], [34, 3, 14, 5, 16], [13, 2, 0, 3, 0], [37, 8, 1, 9, 4], [45, 10, 5, 13, 8], [27, 3, 14, 3, 16], [22, 14, 0, 14, 3]], 3, 2, [14, 3, 16, 4]], [[22, 37, 45], 9, 2]], [[[[28, 8, 5, 10, 8], [39, 4, 12, 4, 12], [10, 4, 1, 4, 4], [29, 14, 11, 16, 13], [4, 6, 14, 6, 14], [22, 1, 0, 3, 0]], 1, 1, [11, 11, 15, 15]], [[28, 29], 5, 1]], [[[[1, 4, 0, 5, 3], [17, 10, 15, 12, 16]], 2, 2, [13, 9, 14, 14]], [[1, 17], 1, 0]], [[[[10, 6, 9, 7, 12], [1, 4, 1, 6, 1], [47, 2, 4, 2, 4], [34, 5, 5, 6, 8], [37, 5, 5, 7, 5], [39, 5, 10, 5, 12], [42, 9, 1, 10, 2], [46, 0, 1, 2, 3], [16, 15, 9, 16, 10]], 1, 1, [3, 10, 3, 14]], [[10, 34, 39], 5, 1]]], [[[[[42, 9, 3, 10, 5], [26, 12, 6, 14, 7], [12, 15, 5, 16, 7], [28, 0, 7, 0, 8], [3, 1, 10, 3, 13], [22, 0, 11, 0, 14], [13, 5, 1, 8, 2], [45, 5, 7, 6, 10], [40, 13, 2, 14, 5]], 3, 3, [12, 11, 15, 11]], [[13, 28, 45], 9, 2]], [[[[25, 9, 7, 10, 8], [29, 11, 3, 11, 6], [9, 14, 6, 16, 7], [44, 4, 5, 4, 8], [35, 2, 15, 4, 15], [12, 9, 10, 10, 10], [10, 8, 7, 11, 8], [43, 15, 0, 16, 3], [22, 14, 0, 16, 0], [16, 15, 6, 16, 8]], 1, 3, [2, 8, 4, 13]], [[10, 16, 25, 35, 44], 13, 3]], [[[[18, 11, 11, 13, 11], [5, 13, 2, 16, 5], [20, 4, 15, 4, 15], [32, 7, 4, 10, 4]], 3, 2, [11, 3, 16, 7]], [[5, 32], 5, 1]], [[[[45, 6, 7, 8, 9], [29, 7, 0, 8, 1], [8, 2, 4, 3, 5], [39, 6, 9, 6, 10], [31, 7, 13, 7, 14], [47, 1, 2, 3, 4]], 3, 2, [1, 0, 1, 0]], [[8, 29, 45, 47], 5, 1]], [[[[35, 12, 4, 14, 4], [20, 10, 12, 10, 14], [9, 4, 13, 6, 13], [44, 12, 10, 14, 11], [12, 10, 6, 12, 8]], 1, 2, [5, 6, 7, 8]], [[9, 12], 9, 2]], [[[[45, 14, 6, 15, 9], [39, 2, 8, 3, 8], [34, 8, 1, 9, 1], [32, 14, 13, 16, 16], [46, 0, 14, 2, 14], [8, 4, 14, 7, 16], [16, 15, 13, 15, 14]], 2, 3, [5, 11, 8, 15]], [[8, 16, 32, 45], 9, 2]], [[[[31, 9, 1, 11, 1], [18, 6, 9, 9, 9], [28, 4, 7, 5, 8]], 2, 3, [14, 6, 16, 10]], [[18, 28, 31], 5, 1]], [[[[38, 4, 9, 7, 11], [44, 15, 10, 16, 12], [13, 13, 12, 13, 13]], 2, 3, [10, 5, 12, 6]], [[], 5, 1]]], [[[[[17, 6, 9, 8, 12], [37, 8, 2, 10, 2], [42, 11, 14, 12, 14], [39, 9, 8, 10, 9], [34, 7, 2, 7, 5], [32, 13, 4, 16, 7], [23, 2, 9, 2, 10], [1, 4, 10, 7, 13], [40, 4, 2, 4, 3], [29, 4, 11, 6, 14]], 2, 2, [0, 9, 3, 13]], [[1, 17, 23, 29], 9, 2]], [[[[34, 14, 5, 16, 8], [30, 14, 15, 16, 16], [19, 2, 8, 2, 10], [43, 14, 5, 16, 5], [47, 5, 8, 8, 8], [9, 8, 10, 8, 12], [8, 1, 14, 2, 16]], 3, 2, [4, 12, 4, 16]], [[8, 19, 34, 47], 5, 1]], [[[[42, 15, 0, 16, 0], [34, 2, 5, 2, 6], [30, 0, 9, 0, 11], [32, 12, 9, 13, 11], [24, 9, 2, 11, 2], [2, 7, 9, 7, 9], [20, 13, 13, 16, 14], [22, 3, 14, 5, 14]], 3, 2, [1, 11, 4, 15]], [[2, 22, 30], 5, 1]], [[[[3, 10, 6, 12, 7], [4, 10, 14, 11, 15], [29, 6, 7, 6, 10], [26, 10, 15, 11, 16]], 2, 3, [12, 12, 13, 13]], [[4, 26, 29], 5, 1]], [[[[12, 6, 1, 9, 3], [29, 14, 6, 16, 9]], 1, 2, [11, 9, 12, 9]], [[12, 29], 5, 1]], [[[[6, 4, 7, 6, 9], [39, 15, 0, 15, 2], [13, 11, 7, 12, 8], [7, 14, 1, 14, 1], [8, 14, 3, 14, 4], [5, 6, 13, 7, 15], [15, 1, 8, 2, 8]], 1, 3, [1, 7, 3, 10]], [[6, 13, 15], 17, 3]], [[[[41, 6, 5, 8, 5], [26, 7, 5, 10, 6], [45, 5, 12, 5, 12], [1, 3, 10, 4, 13], [44, 7, 14, 9, 14]], 1, 1, [8, 9, 8, 14]], [[1, 26, 41, 44, 45], 5, 1]], [[[[7, 13, 7, 14, 10], [49, 6, 5, 9, 6], [35, 8, 9, 10, 9]], 2, 3, [0, 10, 0, 13]], [[7, 49], 5, 1]]], [[[[[7, 10, 4, 10, 7], [28, 8, 10, 10, 13], [21, 14, 13, 16, 15], [9, 13, 6, 16, 7], [11, 11, 4, 11, 7], [27, 14, 5, 16, 8], [1, 0, 8, 3, 9], [19, 0, 7, 0, 8], [29, 0, 11, 1, 14]], 2, 2, [7, 6, 10, 6]], [[7, 11, 19, 27], 9, 2]], [[[[14, 6, 14, 7, 14], [42, 7, 2, 7, 5]], 1, 2, [5, 9, 7, 13]], [[14], 5, 1]], [[[[16, 13, 12, 14, 13], [6, 9, 12, 9, 14], [4, 5, 11, 7, 11], [22, 12, 2, 14, 4], [38, 1, 9, 1, 9], [19, 7, 11, 10, 14]], 2, 2, [13, 4, 18, 9]], [[6, 16, 19, 22], 5, 1]], [[[[29, 6, 0, 8, 3], [20, 11, 15, 11, 16], [27, 6, 12, 9, 15], [38, 0, 9, 2, 11], [30, 10, 9, 10, 10], [7, 2, 9, 3, 11], [48, 8, 11, 11, 14], [9, 2, 7, 2, 10]], 1, 2, [1, 4, 2, 6]], [[9, 27, 29], 13, 2]], [[[[30, 3, 7, 4, 8], [17, 13, 13, 13, 16], [36, 12, 0, 15, 1], [22, 12, 10, 15, 11]], 2, 1, [7, 4, 10, 7]], [[30, 36], 5, 1]], [[[[12, 0, 0, 1, 1], [5, 3, 7, 4, 10], [3, 10, 14, 13, 15]], 1, 1, [11, 9, 15, 10]], [[3, 5], 5, 1]], [[[[22, 10, 13, 12, 14], [17, 15, 1, 16, 4], [5, 11, 3, 12, 3], [49, 12, 0, 15, 0], [31, 2, 6, 2, 7], [18, 2, 12, 2, 14], [34, 2, 15, 2, 16], [28, 13, 14, 15, 16], [39, 0, 5, 3, 7], [30, 12, 1, 15, 1], [40, 0, 3, 1, 4], [45, 3, 6, 3, 9]], 2, 1, [0, 6, 2, 11]], [[18, 31, 34, 39, 40, 45], 5, 1]], [[[[34, 13, 8, 16, 9], [35, 0, 9, 2, 12], [8, 11, 12, 13, 13], [43, 12, 9, 15, 9], [42, 12, 3, 15, 5], [21, 13, 3, 13, 3], [27, 12, 0, 12, 3], [37, 6, 2, 8, 5], [25, 0, 9, 2, 12]], 2, 3, [10, 6, 10, 11]], [[8, 37, 42], 13, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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 fixtureActualExpectedOutcome
case 0[[3, 6, 11, 34], 9, 2][[3, 6, 11, 34], 9, 2]Passed
case 1[[13, 29, 33], 5, 1][[13, 29, 33], 17, 2]Failed
case 2[[2, 11, 17, 30, 41, 42], 5, 1][[2, 11, 17, 30, 41, 42], 5, 1]Passed
case 3[[7, 9, 15, 25], 1, 0][[7, 15], 5, 1]Failed
case 4[[8, 25, 34], 1, 0][[25, 34], 5, 1]Failed
case 5[[19, 29], 1, 0][[19, 29], 1, 0]Passed
case 6[[4, 11, 16, 49], 9, 2][[4, 11, 16, 49], 13, 2]Failed
case 7[[3, 11, 35, 38, 49], 5, 1][[35, 38, 49], 9, 2]Failed

SHA-256 / 9af79c7030faefea5c00d8e4bc9047d8eb5218955e6d284b3947aa35b5177025

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(objs, cap, max_depth, q):
    def make(x, y, s, d):
        return {'x': x, 'y': y, 's': s, 'd': d, 'objs': [], 'kids': None}
    def child_index(n, o):
        h = n['s'] / 2
        mx, my = n['x'] + h, n['y'] + h
        if o[3] < mx:
            cx = 0
        elif o[1] >= mx:
            cx = 1
        else:
            return -1
        if o[4] < my:
            cy = 0
        elif o[2] >= my:
            cy = 1
        else:
            return -1
        return cy * 2 + cx
    def split(n):
        h = n['s'] / 2
        n['kids'] = [make(n['x'] + (k % 2) * h, n['y'] + (k // 2) * h, h, n['d'] + 1) for k in range(4)]
        old, n['objs'] = n['objs'], []
        for o in old:
            insert(n, o)
    def insert(n, o):
        if n['kids'] is not None:
            k = child_index(n, o)
            if k >= 0:
                insert(n['kids'][k], o)
                return
        n['objs'].append(o)
        if n['kids'] is None and len(n['objs']) > cap and n['d'] < max_depth:
            split(n)
    root = make(0, 0, 16, 0)
    for o in objs:
        insert(root, o)
    found, count, deep = [], 0, 0
    stack = [root]
    while stack:
        n = stack.pop()
        count += 1
        deep = max(deep, n['d'])
        if n['kids']:
            stack.extend(n['kids'])
        if n['x'] <= q[2] and q[0] <= n['x'] + n['s'] and n['y'] <= q[3] and q[1] <= n['y'] + n['s']:
            found.extend(o[0] for o in n['objs'])
    return [sorted(found), count, deep]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[33, 5, 0, 5, 0], [11, 7, 11, 9, 13], [5, 15, 13, 16, 15], [6, 11, 8, 13, 11], [22, 14, 12, 16, 15], [34, 2, 8, 4, 8], [3, 2, 7, 3, 8], [31, 11, 2, 14, 5]], 1, 2, [8, 14, 9, 18]], [[3, 6, 11, 34], 9, 2]], [[[[14, 3, 6, 3, 7], [33, 13, 2, 16, 5], [4, 9, 15, 9, 15], [13, 7, 4, 9, 6], [45, 8, 14, 11, 16], [29, 11, 3, 11, 4], [43, 0, 2, 0, 5]], 1, 2, [12, 1, 17, 3]], [[13, 29, 33], 17, 2]], [[[[30, 11, 15, 14, 16], [41, 3, 15, 3, 16], [11, 3, 1, 3, 4], [17, 2, 13, 2, 14], [42, 14, 6, 16, 7], [2, 10, 9, 13, 9]], 2, 1, [7, 6, 9, 8]], [[2, 11, 17, 30, 41, 42], 5, 1]], [[[[7, 15, 7, 16, 9], [25, 3, 3, 6, 4], [9, 0, 4, 3, 6], [15, 11, 10, 14, 10]], 3, 2, [9, 10, 13, 13]], [[7, 15], 5, 1]], [[[[25, 10, 12, 13, 13], [34, 12, 13, 15, 15], [8, 9, 2, 10, 2]], 2, 2, [12, 11, 14, 13]], [[25, 34], 5, 1]], [[[[29, 1, 10, 1, 12], [19, 5, 10, 6, 11]], 2, 3, [3, 1, 8, 2]], [[19, 29], 1, 0]], [[[[31, 11, 9, 12, 9], [29, 6, 3, 7, 5], [11, 14, 7, 14, 7], [16, 0, 7, 0, 9], [33, 15, 11, 16, 11], [4, 12, 0, 13, 3], [20, 12, 14, 13, 16], [49, 7, 6, 8, 7]], 1, 3, [12, 4, 14, 6]], [[4, 11, 16, 49], 13, 2]], [[[[49, 7, 3, 10, 3], [38, 8, 0, 8, 2], [11, 12, 4, 12, 4], [5, 4, 10, 4, 11], [3, 12, 6, 15, 7], [21, 0, 13, 1, 14], [35, 10, 7, 10, 10], [9, 9, 10, 12, 12]], 2, 2, [9, 2, 10, 7]], [[35, 38, 49], 9, 2]]], [[[[[46, 11, 12, 13, 13], [4, 4, 11, 4, 14], [41, 4, 13, 4, 13], [2, 0, 8, 1, 11], [45, 5, 5, 8, 5], [3, 2, 4, 4, 5], [39, 15, 12, 16, 13], [25, 12, 8, 14, 11]], 1, 2, [0, 0, 5, 1]], [[3, 45], 13, 2]], [[[[28, 9, 14, 12, 16], [29, 2, 3, 2, 6], [23, 8, 0, 8, 2], [17, 2, 9, 5, 11], [33, 15, 5, 16, 7], [46, 14, 15, 16, 16], [14, 13, 0, 16, 3]], 2, 2, [0, 14, 1, 18]], [[17], 9, 2]], [[[[43, 15, 9, 16, 9], [33, 11, 1, 11, 2], [32, 13, 12, 14, 14], [49, 8, 4, 9, 4]], 1, 2, [4, 4, 5, 7]], [[], 13, 2]], [[[[49, 11, 0, 11, 3], [23, 7, 12, 8, 15], [14, 0, 5, 3, 6], [30, 1, 4, 3, 6], [37, 2, 5, 4, 6], [28, 9, 9, 11, 11]], 1, 3, [6, 1, 7, 3]], [[23, 37], 13, 3]], [[[[40, 2, 4, 4, 4], [39, 7, 9, 7, 12], [24, 5, 11, 5, 14], [34, 3, 14, 5, 16], [13, 2, 0, 3, 0], [37, 8, 1, 9, 4], [45, 10, 5, 13, 8], [27, 3, 14, 3, 16], [22, 14, 0, 14, 3]], 3, 2, [14, 3, 16, 4]], [[22, 37, 45], 9, 2]], [[[[28, 8, 5, 10, 8], [39, 4, 12, 4, 12], [10, 4, 1, 4, 4], [29, 14, 11, 16, 13], [4, 6, 14, 6, 14], [22, 1, 0, 3, 0]], 1, 1, [11, 11, 15, 15]], [[28, 29], 5, 1]], [[[[1, 4, 0, 5, 3], [17, 10, 15, 12, 16]], 2, 2, [13, 9, 14, 14]], [[1, 17], 1, 0]], [[[[10, 6, 9, 7, 12], [1, 4, 1, 6, 1], [47, 2, 4, 2, 4], [34, 5, 5, 6, 8], [37, 5, 5, 7, 5], [39, 5, 10, 5, 12], [42, 9, 1, 10, 2], [46, 0, 1, 2, 3], [16, 15, 9, 16, 10]], 1, 1, [3, 10, 3, 14]], [[10, 34, 39], 5, 1]]], [[[[[42, 9, 3, 10, 5], [26, 12, 6, 14, 7], [12, 15, 5, 16, 7], [28, 0, 7, 0, 8], [3, 1, 10, 3, 13], [22, 0, 11, 0, 14], [13, 5, 1, 8, 2], [45, 5, 7, 6, 10], [40, 13, 2, 14, 5]], 3, 3, [12, 11, 15, 11]], [[13, 28, 45], 9, 2]], [[[[25, 9, 7, 10, 8], [29, 11, 3, 11, 6], [9, 14, 6, 16, 7], [44, 4, 5, 4, 8], [35, 2, 15, 4, 15], [12, 9, 10, 10, 10], [10, 8, 7, 11, 8], [43, 15, 0, 16, 3], [22, 14, 0, 16, 0], [16, 15, 6, 16, 8]], 1, 3, [2, 8, 4, 13]], [[10, 16, 25, 35, 44], 13, 3]], [[[[18, 11, 11, 13, 11], [5, 13, 2, 16, 5], [20, 4, 15, 4, 15], [32, 7, 4, 10, 4]], 3, 2, [11, 3, 16, 7]], [[5, 32], 5, 1]], [[[[45, 6, 7, 8, 9], [29, 7, 0, 8, 1], [8, 2, 4, 3, 5], [39, 6, 9, 6, 10], [31, 7, 13, 7, 14], [47, 1, 2, 3, 4]], 3, 2, [1, 0, 1, 0]], [[8, 29, 45, 47], 5, 1]], [[[[35, 12, 4, 14, 4], [20, 10, 12, 10, 14], [9, 4, 13, 6, 13], [44, 12, 10, 14, 11], [12, 10, 6, 12, 8]], 1, 2, [5, 6, 7, 8]], [[9, 12], 9, 2]], [[[[45, 14, 6, 15, 9], [39, 2, 8, 3, 8], [34, 8, 1, 9, 1], [32, 14, 13, 16, 16], [46, 0, 14, 2, 14], [8, 4, 14, 7, 16], [16, 15, 13, 15, 14]], 2, 3, [5, 11, 8, 15]], [[8, 16, 32, 45], 9, 2]], [[[[31, 9, 1, 11, 1], [18, 6, 9, 9, 9], [28, 4, 7, 5, 8]], 2, 3, [14, 6, 16, 10]], [[18, 28, 31], 5, 1]], [[[[38, 4, 9, 7, 11], [44, 15, 10, 16, 12], [13, 13, 12, 13, 13]], 2, 3, [10, 5, 12, 6]], [[], 5, 1]]], [[[[[17, 6, 9, 8, 12], [37, 8, 2, 10, 2], [42, 11, 14, 12, 14], [39, 9, 8, 10, 9], [34, 7, 2, 7, 5], [32, 13, 4, 16, 7], [23, 2, 9, 2, 10], [1, 4, 10, 7, 13], [40, 4, 2, 4, 3], [29, 4, 11, 6, 14]], 2, 2, [0, 9, 3, 13]], [[1, 17, 23, 29], 9, 2]], [[[[34, 14, 5, 16, 8], [30, 14, 15, 16, 16], [19, 2, 8, 2, 10], [43, 14, 5, 16, 5], [47, 5, 8, 8, 8], [9, 8, 10, 8, 12], [8, 1, 14, 2, 16]], 3, 2, [4, 12, 4, 16]], [[8, 19, 34, 47], 5, 1]], [[[[42, 15, 0, 16, 0], [34, 2, 5, 2, 6], [30, 0, 9, 0, 11], [32, 12, 9, 13, 11], [24, 9, 2, 11, 2], [2, 7, 9, 7, 9], [20, 13, 13, 16, 14], [22, 3, 14, 5, 14]], 3, 2, [1, 11, 4, 15]], [[2, 22, 30], 5, 1]], [[[[3, 10, 6, 12, 7], [4, 10, 14, 11, 15], [29, 6, 7, 6, 10], [26, 10, 15, 11, 16]], 2, 3, [12, 12, 13, 13]], [[4, 26, 29], 5, 1]], [[[[12, 6, 1, 9, 3], [29, 14, 6, 16, 9]], 1, 2, [11, 9, 12, 9]], [[12, 29], 5, 1]], [[[[6, 4, 7, 6, 9], [39, 15, 0, 15, 2], [13, 11, 7, 12, 8], [7, 14, 1, 14, 1], [8, 14, 3, 14, 4], [5, 6, 13, 7, 15], [15, 1, 8, 2, 8]], 1, 3, [1, 7, 3, 10]], [[6, 13, 15], 17, 3]], [[[[41, 6, 5, 8, 5], [26, 7, 5, 10, 6], [45, 5, 12, 5, 12], [1, 3, 10, 4, 13], [44, 7, 14, 9, 14]], 1, 1, [8, 9, 8, 14]], [[1, 26, 41, 44, 45], 5, 1]], [[[[7, 13, 7, 14, 10], [49, 6, 5, 9, 6], [35, 8, 9, 10, 9]], 2, 3, [0, 10, 0, 13]], [[7, 49], 5, 1]]], [[[[[7, 10, 4, 10, 7], [28, 8, 10, 10, 13], [21, 14, 13, 16, 15], [9, 13, 6, 16, 7], [11, 11, 4, 11, 7], [27, 14, 5, 16, 8], [1, 0, 8, 3, 9], [19, 0, 7, 0, 8], [29, 0, 11, 1, 14]], 2, 2, [7, 6, 10, 6]], [[7, 11, 19, 27], 9, 2]], [[[[14, 6, 14, 7, 14], [42, 7, 2, 7, 5]], 1, 2, [5, 9, 7, 13]], [[14], 5, 1]], [[[[16, 13, 12, 14, 13], [6, 9, 12, 9, 14], [4, 5, 11, 7, 11], [22, 12, 2, 14, 4], [38, 1, 9, 1, 9], [19, 7, 11, 10, 14]], 2, 2, [13, 4, 18, 9]], [[6, 16, 19, 22], 5, 1]], [[[[29, 6, 0, 8, 3], [20, 11, 15, 11, 16], [27, 6, 12, 9, 15], [38, 0, 9, 2, 11], [30, 10, 9, 10, 10], [7, 2, 9, 3, 11], [48, 8, 11, 11, 14], [9, 2, 7, 2, 10]], 1, 2, [1, 4, 2, 6]], [[9, 27, 29], 13, 2]], [[[[30, 3, 7, 4, 8], [17, 13, 13, 13, 16], [36, 12, 0, 15, 1], [22, 12, 10, 15, 11]], 2, 1, [7, 4, 10, 7]], [[30, 36], 5, 1]], [[[[12, 0, 0, 1, 1], [5, 3, 7, 4, 10], [3, 10, 14, 13, 15]], 1, 1, [11, 9, 15, 10]], [[3, 5], 5, 1]], [[[[22, 10, 13, 12, 14], [17, 15, 1, 16, 4], [5, 11, 3, 12, 3], [49, 12, 0, 15, 0], [31, 2, 6, 2, 7], [18, 2, 12, 2, 14], [34, 2, 15, 2, 16], [28, 13, 14, 15, 16], [39, 0, 5, 3, 7], [30, 12, 1, 15, 1], [40, 0, 3, 1, 4], [45, 3, 6, 3, 9]], 2, 1, [0, 6, 2, 11]], [[18, 31, 34, 39, 40, 45], 5, 1]], [[[[34, 13, 8, 16, 9], [35, 0, 9, 2, 12], [8, 11, 12, 13, 13], [43, 12, 9, 15, 9], [42, 12, 3, 15, 5], [21, 13, 3, 13, 3], [27, 12, 0, 12, 3], [37, 6, 2, 8, 5], [25, 0, 9, 2, 12]], 2, 3, [10, 6, 10, 11]], [[8, 37, 42], 13, 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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 fixtureActualExpectedOutcome
case 0[[3, 6, 11, 34], 9, 2][[3, 6, 11, 34], 9, 2]Passed
case 1[[13, 29, 33], 17, 2][[13, 29, 33], 17, 2]Passed
case 2[[2, 11, 17, 30, 41, 42], 5, 1][[2, 11, 17, 30, 41, 42], 5, 1]Passed
case 3[[7, 15], 5, 1][[7, 15], 5, 1]Passed
case 4[[25, 34], 5, 1][[25, 34], 5, 1]Passed
case 5[[19, 29], 1, 0][[19, 29], 1, 0]Passed
case 6[[4, 11, 16, 49], 13, 2][[4, 11, 16, 49], 13, 2]Passed
case 7[[35, 38, 49], 9, 2][[35, 38, 49], 9, 2]Passed

SHA-256 / c597fe0ae6c81b64126cb8aa6a8bcc8910c539a838d1917ad7f894ed54627eff

Verification & scope

A deterministic bounded teaching model with stipulated toy conventions; not a production physics engine or spatial index. 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:59.180985+00:00.

Case digest / 4d953f3f6aafd06e031c7871f917c7b178fcf4755561de6a7f1ae6e9e6b88138