"""Graph algorithms, SAT and planning as a bar chart (was Table 7), written as an inline for index.html. Written transformers: every test item. Claude Opus 5.5: 50 test items per task in Claude Code with no tools; its bars carry 95% Wilson intervals. The two Claude cartoons are the ones in tools/make_concept.py (copied here). Usage: python3 -I make_algos_bars.py """ import math, random, sys ORANGE, ORANGE_T, DARK, INK, MUTED, GRID = "#eb6834", "#c4471a", "#1d1d1f", "#14213d", "#5b6475", "#e1e0d9" GREY_FILL, GREY_EDGE, GREY_TEXT = "#ecebe7", "#a9a8a1", "#5f5e59" GROUPS = [ ("CLRS-Text", "graph", [("Strongly connected components", 100, 96), ("Minimum spanning tree (Prim)", 99.2, 96), ("Longest common subsequence", 100, 92)]), ("PlanBench", "blocks", [("Blocksworld", 100, 100), ("Mystery Blocksworld", 100, 100), ("Logistics", 100, 100)]), ("SATLIB, random 3-SAT", "sat", [("uf20-91, satisfiable", 100, 96), ("uf50-218, satisfiable", 100, 84), ("uuf50-218, unsatisfiable", 100, 82)]), ] N_CLAUDE = 50 def wilson(p, n, z=1.96): k = p / 100 den = 1 + z * z / n c = (k + z * z / (2 * n)) / den h = z * math.sqrt(k * (1 - k) / n + z * z / (4 * n * n)) / den return 100 * (c - h), 100 * min(1, c + h) def spark(cx, cy, r, seed): rr = random.Random(seed) o = [] for i in range(11): a = math.radians(i * 360 / 11 + rr.uniform(-6, 6) - 90) L = r * rr.uniform(0.82, 1.0) o.append(f'') o.append(f'') return "".join(o) def claude_dumb(cx, cy, s): """The confused Claude from the concept figure, scaled by s (1 = radius 40).""" g = [f'', spark(0, 0, 40, 3)] g.append(f'') g.append(f'') g.append(f'') g.append(f'') g.append('') return "".join(g) def claude_villain(cx, cy, s): """The scheming Claude with a monocle from the concept figure, scaled by s.""" g = [f'', spark(0, 0, 40, 8)] g.append(f'') g.append(f'') for ex in (-9, 9): g.append(f'') g.append(f'') g.append(f'') g.append('') return "".join(g) def pictogram(kind, x, y): """A small sign for each benchmark, in a 26 x 18 box with its left edge at x, centred on y.""" s = f'stroke="{INK}" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round"' if kind == "graph": pts = [(x + 3, y + 5), (x + 13, y - 6), (x + 23, y + 5)] o = [f''] o += [f'' for px, py in pts] return "".join(o) if kind == "blocks": return (f'' f'' f'' f'') return (f'' f'a∨b') def main(out): W = 540 x_lab, x0, x100 = 14, 254, 478 sc = (x100 - x0) / 100 bh, gap, row_gap, head_h = 11, 3, 13, 30 y = 88 o = [] # legend with the two cartoons o.append(claude_villain(30, 30, 0.62)) o.append(f'') o.append(f'Written by Claude') o.append(claude_dumb(300, 30, 0.62)) o.append(f'') o.append(f'Claude Opus 5.5 alone') o.append(f'') for gname, kind, rows in GROUPS: o.append(pictogram(kind, x_lab, y - 6)) o.append(f'{gname}') y += head_h - 14 for label, ours, cl in rows: yc = y + bh + gap / 2 o.append(f'{label}') o.append(f'') o.append(f'{ours:g}%') yb = y + bh + gap o.append(f'') lo, hi = wilson(cl, N_CLAUDE) ym = yb + bh / 2 o.append(f'') o.append(f'{cl:g}%') y += 2 * bh + gap + row_gap y += 16 # axis ya = y - 10 o.append(f'') for v in (0, 50, 100): o.append(f'') o.append(f'{v}') o.append(f'Accuracy (%)') H = ya + 42 defs = (f'' f'') svg = (f'' + defs + "".join(o) + "") open(out, "w", encoding="utf-8").write(svg) print("wrote", out, f"({W}x{H:.0f})") if __name__ == "__main__": main(sys.argv[1])