feat(bench): fit difficulty from a played round, and report when it cannot

refit-weights regresses the weights select-50 scores with against what agents
actually experienced, so a round of play is a flag on the next selection rather
than an edit. Ridge, because seven collinear features on fifty levels otherwise
hand back large coefficients that cancel.

Most of the work here is in refusing to produce a number. The response averages
the difficulty rating with two continuous measures of the same thing, and a
component with no spread is dropped by name instead of being silently averaged
in as zeros — which is what the first version did, reporting R² = 0.75 for a
fit that never saw a rating. When the rating is flat the script now says so and
says what the remaining fit is really measuring, which is board size.

legibility() asks what it costs to know what you may tap: how far the eye must
follow the cheapest free piece, and how many pieces are held by somebody their
line never touches. It was built to explain why ratings came back flat. It does
not — it correlates -0.02 with them — so it stays a measurement, printed on the
review sheet beside the longest route on the board, and gates nothing.

prototype-d5 takes --seedFrom so a wide sweep shards across cores.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
cabinw
2026-09-14 17:03:43 +08:00
co-authored by Claude Opus 5
parent b35ea201db
commit d374c208f0
10 changed files with 3886 additions and 287 deletions
+24
View File
@@ -9,6 +9,7 @@
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { trace, rotateBoard } from '../src/core.js';
import { legibility } from '../src/deep-lock.js';
import { layout } from '../src/geometry.js';
import { metrics } from '../src/bench.js';
@@ -62,6 +63,15 @@ function thumbnail(level, size = 168) {
+ `<g class="cells">${cells}</g><g class="pieces">${pieces}</g></svg>`;
}
// The two things the agent complained about in all 33 reports it filed, and the
// two the text bench is least able to judge for us: how long the longest line
// on the board is, and how many pieces are held by somebody their line never
// touches. Both are perceptual, so they are printed rather than gated on.
const perceptual = Object.fromEntries(levels.map(l => [l.id, {
longest: Math.max(...l.tiles.map(t => trace(l, t, [], true).steps.length)),
...legibility(l),
}]));
const rated = levels.map(l => verdicts[l.id]).filter(Boolean);
const band = (a, b) => levels.slice(a, b).map(l => verdicts[l.id]).filter(Boolean);
const bandRow = (label, a, b) => {
@@ -116,6 +126,7 @@ td.n,th.n{text-align:right;font-family:ui-monospace,monospace;white-space:nowrap
.thumb text{fill:#fff;text-anchor:middle;font-family:system-ui}
.kv{display:grid;grid-template-columns:auto auto;gap:1px 8px;font-size:11.5px;color:var(--ink2)}
.kv b{font-family:ui-monospace,monospace;color:var(--ink);font-weight:600;text-align:right}
.kv b.hot{color:var(--warn)}
.verdict{font-size:11.5px;border-top:1px dashed var(--rule);padding-top:7px;color:var(--ink2)}
.verdict .row{display:flex;gap:9px;flex-wrap:wrap;font-family:ui-monospace,monospace}
.verdict .worst{margin-top:4px;color:var(--ink3);line-height:1.5}
@@ -123,6 +134,9 @@ td.n,th.n{text-align:right;font-family:ui-monospace,monospace;white-space:nowrap
.pill{display:inline-block;font-size:10.5px;padding:1px 7px;border-radius:20px;font-weight:600}
.pill.bad{background:var(--bad);color:#fff}
.pill.warn{background:var(--warn);color:#fff}
.note{background:var(--panel);border:1px solid var(--rule);border-left:3px solid var(--rail);border-radius:10px;padding:4px 18px;margin:12px 0 8px}
.note p{font-size:13.5px;color:var(--ink2);max-width:78ch}
.note b{color:var(--ink)}
footer{margin-top:50px;padding-top:18px;border-top:1px solid var(--rule);color:var(--ink3);font-size:12px}
</style>
</head>
@@ -143,6 +157,14 @@ ${bandRow('后档 L33–L50', 32, 50)}
</table>
<p class="meta">难度 3 = 刚刚好;无解感越低越好。这两项是评分里唯二复测可信的(r = 0.93 / 0.85),其余几项是模型噪声,不列。</p>
<h2>这批数字里,哪些能信</h2>
<div class="note">
<p><b>机械面是干净的,可以信。</b>agent 跑完 ${rated.length} 关:空点 ${f1(mean(rated.map(m => m.deadTaps)))} 次/关、盲转 ${f1(mean(rated.map(m => m.blindRotations)))} 次/关、反向转 ${f1(mean(rated.map(m => m.wrongWayRotations)))} 次/关,${rated.filter(m => m.cleared).length}/${rated.length} 关通关。「动了半天没结果」这类结构缺陷已经被生成期的闸门挡掉了。</p>
<p><b>难度评分不能信,它区分不了这批关卡。</b>${rated.length} 关里有 ${rated.filter(m => Number(m.rating?.difficulty) === 2).length} 关被打成 2 分,而这些关卡机械上差着三倍(决策数 0–8)。原因不在关卡,在 bench:文字盘面会把每颗棋子的路线、挡路者、紧贴者<b>直接列成清单</b>,agent 从来不需要用眼睛顺着线走一遍——而那正是这个游戏的难点所在。agent 自己在报告里写过这句:「挡路名单已经写全,不用顺着格子数」。</p>
<p><b>所以难度顺序是机械假设,等你的判定。</b>L1 到 L50 是按旋转深度、棋子数、互锁程度排的,不是按谁测出来更难。评分唯一能用的是它的<b>总体读数</b>:整批偏易一档(2 分 vs 刚刚好的 3 分)。</p>
<p><b>两件事我没有擅自改,留给你定。</b>agent 的 33 条抱怨里反复出现两个主题:路线太长看不完(「68 格 27 弯」「42 格 42 弯」),以及紧贴容易看漏(「看着能出界却会擦到」)。两项都是感知问题,而<b>已上线的 v0.5 在这两项上更严重</b>(最长路线 88 格 vs 这里 ${Math.max(...Object.values(perceptual).map(p => p.longest))} 格)——它是这个游戏本来的性格,不是这次构造引入的。卡片上「最长路线」超 45 格、「紧贴棋子」超 1 枚会标黄,你试玩时留意。</p>
</div>
<h2>逐关</h2>
<div class="grid">
${levels.map((l, i) => {
@@ -160,6 +182,8 @@ ${levels.map((l, i) => {
<span>开局可点</span><b>${c.openingChoices ?? '?'} 枚</b>
<span>开局演出</span><b>${c.openingBestMs != null ? (c.openingBestMs / 1000).toFixed(1) + 's' : '?'}</b>
<span>长巡游 / 反差</span><b>${c.cruises ?? '?'} · ${c.contrast ?? '?'}</b>
<span>最长路线</span><b class="${perceptual[l.id].longest > 45 ? 'hot' : ''}">${perceptual[l.id].longest} 格</b>
<span>紧贴棋子</span><b class="${perceptual[l.id].grazeTraps > 1 ? 'hot' : ''}">${perceptual[l.id].grazeTraps} 枚</b>
</div>
${v ? `<div class="verdict">
<div class="row"><span>难度 ${v.rating?.difficulty ?? '—'}</span><span>无解感 ${v.rating?.stuck ?? '—'}</span><span>${v.steps} 步</span><span>${v.decisions} 决策</span></div>