fix(levels): stop rejecting crowded boards for an endgame nobody measured
No level in this project is more than a third pieces — 13% to 28% across the shipping fifty, and the thousand-level set that preceded it peaks at 32% with exactly one level above 30%. Clearing a full board is the satisfying part of a clearing game, and it has never been on offer. It was not a design choice. deadTurnAudit walks the reachable state space with a 20000-state budget, and the endgame gate read its answer. Past about eleven pieces that budget is gone long before the walk reaches any state with three pieces left, so the audit returned `endgameMinOpen: null` — and the gate, written `endgameMinOpen >= 2`, compared null and got false. Every denser level was thrown out for a bad endgame that was never looked at. `exhausted` was right there in the audit's return value and nothing consulted it. Endgames are now enumerated outright rather than walked to: C(26,3) is 2600 subsets, so it finishes on any board this game will ever have. The statistic is the SHARE of endgames that are tight, not the minimum over them, because a minimum over more subsets falls for arithmetic alone — the same confound that made doubleDead look eight times worse for deep levels when the rate was 2% against 5%. By share, crowded boards are the better ones: worst 0.33% against 1.73% for sparse. With the gate measuring something, density inverts. At eight pieces per orientation: 44% density, 18 of 23 candidates passing the whole chain, and not one failing the dead-turn gate. At two: 19% density, 9 of 23, with eleven failing on dead turns. perTurn becomes a swept dial, and the hard piece ceiling that truncated the placement schedule regardless of it is gone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// that only a wide sweep can afford.
|
||||
//
|
||||
// node scripts/build-pool.mjs --in=<dir> [--out=bench/pool.json]
|
||||
// [--endgameMinOpen=3] [--maxDeadTurns=1]
|
||||
// [--maxTightShare=0.005] [--maxDeadTurns=1]
|
||||
//
|
||||
// prototype-d5 gates what a single sweep can pay for. Two more are left to this
|
||||
// step because together they cost nearly 60% of the yield.
|
||||
@@ -27,7 +27,7 @@ import { deadTurnAudit, deepLevelKey } from '../src/deep-lock.js';
|
||||
|
||||
const args = Object.fromEntries(process.argv.slice(2).map(a => { const [k, ...v] = a.replace(/^--/, '').split('='); return [k, v.length ? v.join('=') : true]; }));
|
||||
const OUT = resolve(args.out ?? 'bench/pool.json');
|
||||
const MIN_OPEN = Number(args.endgameMinOpen ?? 3);
|
||||
const MAX_TIGHT = Number(args.maxTightShare ?? 0.005);
|
||||
const MAX_DEAD = Number(args.maxDeadTurns ?? 1);
|
||||
|
||||
// Shards from a sweep, or level files listed directly.
|
||||
@@ -59,18 +59,18 @@ for (const level of unique) {
|
||||
audited++;
|
||||
}
|
||||
|
||||
const open = unique.filter(l => (l.prototype.audit.endgameMinOpen ?? 0) >= MIN_OPEN);
|
||||
const open = unique.filter(l => (l.prototype.audit.endgameTightShare ?? 1) <= MAX_TIGHT);
|
||||
const kept = open.filter(l => (l.prototype.audit.maxDeadTurns ?? Infinity) <= MAX_DEAD);
|
||||
|
||||
const tally = (rows, f) => rows.reduce((m, l) => { const k = f(l); m[k] = (m[k] || 0) + 1; return m; }, {});
|
||||
const rot = l => l.prototype?.stats?.rotations ?? '?';
|
||||
const fam = l => l.prototype?.family ?? (String(l.id).startsWith('trail-') ? 'v05' : '?');
|
||||
console.log(`${files.length} 个来源合计 ${all.length} → 去重 ${unique.length}${audited ? `(其中 ${audited} 关现场补算了 audit)` : ''}`);
|
||||
console.log(` 终局可放行朝向 ≥${MIN_OPEN} → ${open.length}(${Math.round(100 * open.length / unique.length)}%)`);
|
||||
console.log(` 终局紧局 ≤${(MAX_TIGHT*100).toFixed(1)}% → ${open.length}(${Math.round(100 * open.length / unique.length)}%)`);
|
||||
console.log(` 连续空转 ≤${MAX_DEAD} → ${kept.length}(${Math.round(100 * kept.length / unique.length)}%)`);
|
||||
console.log(`旋转深度 ${JSON.stringify(tally(kept, rot))}`);
|
||||
console.log(`家族 ${JSON.stringify(tally(kept, fam))}`);
|
||||
|
||||
writeFileSync(OUT, JSON.stringify({ generated: 'build-pool', sources: files.length, swept: all.length, count: kept.length,
|
||||
gates: { endgameMinOpen: MIN_OPEN, maxDeadTurns: MAX_DEAD }, levels: kept }, null, 1));
|
||||
gates: { maxTightShare: MAX_TIGHT, maxDeadTurns: MAX_DEAD }, levels: kept }, null, 1));
|
||||
console.log(`已写入 ${OUT}`);
|
||||
|
||||
+25
-12
@@ -17,7 +17,12 @@ const OUT = resolve(args.out ?? 'levels/prototypes/d5.json');
|
||||
const RADII = String(args.radii ?? '3,4').split(',').map(Number);
|
||||
const MIN_PIECES = Number(args.minPieces ?? 8);
|
||||
const DEPTHS = String(args.depths ?? '3,4,5,6').split(',').map(Number);
|
||||
const PER_TURN = Number(args.perTurn ?? 2);
|
||||
// How many pieces each orientation may hold. It is the density dial: the
|
||||
// schedule is depth × perTurn placements, so perTurn 2 could never build a board
|
||||
// more than a fifth pieces no matter what `target` said. Swept, so the pool
|
||||
// carries both sparse and crowded boards to choose between.
|
||||
const PER_TURNS = String(args.perTurns ?? args.perTurn ?? '2,5,8').split(',').map(Number);
|
||||
const CAP = args.cap === undefined ? null : Number(args.cap);
|
||||
const SHOWCASE = Number(args.showcase ?? 2);
|
||||
// How leftover ports are paired. 'straight' was the only behaviour and it is
|
||||
// what made boards read as a grid of long lines crossing everywhere.
|
||||
@@ -53,8 +58,11 @@ for (const { id: family } of ROUTE_FAMILIES) for (const radius of RADII) {
|
||||
yieldTable[cellKey].locks++;
|
||||
// Sweep depth: each extra orientation populated is one more turn the
|
||||
// player must take, and each of those turns has pieces waiting.
|
||||
for (const depth of DEPTHS) {
|
||||
const cap = { 3: 11, 4: 16, 5: 18 }[radius];
|
||||
for (const depth of DEPTHS) for (const PER_TURN of PER_TURNS) {
|
||||
// A hard piece ceiling, from when crowded boards could not pass the endgame
|
||||
// gate anyway. It truncated the placement schedule, so raising perTurn did
|
||||
// nothing while it stood. Density is now a dial (perTurn), not a limit.
|
||||
const cap = CAP;
|
||||
const grown = growDeepLevel(base, lock, { seed, depth, perTurn: PER_TURN, target: cap, showcase: SHOWCASE });
|
||||
const level = grown.level;
|
||||
if (grown.solution.rotations < 3) continue;
|
||||
@@ -68,8 +76,8 @@ for (const { id: family } of ROUTE_FAMILIES) for (const radius of RADII) {
|
||||
const show = showStats(level);
|
||||
if (!show) continue;
|
||||
const apt = monkeyActionsPerPiece(level);
|
||||
level.prototype = { family, radius, seed, depth, cap, lock: { hero: lock.hero.id, heroBends: lock.heroRoute.bends, search: lock.search }, placements: grown.placements, rejected: grown.rejected, stats, audit, contrast, show, monkeyActionsPerPiece: apt };
|
||||
level.id = `proto-d5-${family}-r${radius}-s${seed}-d${depth}`;
|
||||
level.prototype = { family, radius, seed, depth, perTurn: PER_TURN, cap, lock: { hero: lock.hero.id, heroBends: lock.heroRoute.bends, search: lock.search }, placements: grown.placements, rejected: grown.rejected, stats, audit, contrast, show, monkeyActionsPerPiece: apt };
|
||||
level.id = `proto-d5-${family}-r${radius}-s${seed}-d${depth}-p${PER_TURN}`;
|
||||
rows.push({ level, stats, audit, contrast, show, apt, family, radius, seed, depth });
|
||||
}
|
||||
}
|
||||
@@ -81,10 +89,15 @@ for (const { id: family } of ROUTE_FAMILIES) for (const radius of RADII) {
|
||||
// where neither adjacent orientation opens anything.
|
||||
const med = arr => { const s = [...arr].sort((a, b) => a - b); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
|
||||
const grownEnough = rows.filter(r => r.stats.pieces >= MIN_PIECES);
|
||||
// The endgame gate: with three pieces or fewer left, at least two of the six
|
||||
// orientations must release something. One is a 1-in-6 guess with a dead end
|
||||
// behind every other door — solvable, legible, and still the thing that made
|
||||
// an agent give up. It rejects exactly the levels every model stalled on.
|
||||
// The endgame gate. It used to demand a minimum over reachable endgames, read
|
||||
// off the same breadth search that counts dead turns — and on a crowded board
|
||||
// that search never reaches an endgame, so it answered null and the comparison
|
||||
// rejected the level for an endgame nobody had measured. Now the endgames are
|
||||
// enumerated outright and the gate is the SHARE that are tight (one orientation
|
||||
// or none). A minimum over more subsets falls for arithmetic reasons; the share
|
||||
// does not, and by share the crowded boards are the better ones — worst 0.33%
|
||||
// against 1.73% for the sparse.
|
||||
const MAX_TIGHT_SHARE = Number(args.maxTightShare ?? 0.005);
|
||||
const MIN_RELEASE = Number(args.minRelease ?? 2);
|
||||
const MIN_CONTRAST = Number(args.minContrast ?? 12);
|
||||
// Expressed at the speed it was calibrated at (120ms per unit) and scaled to
|
||||
@@ -98,7 +111,7 @@ const MIN_CRUISES = Number(args.minCruises ?? 3);
|
||||
// that no turn is a punishment (endgameMinOpen, firstTurnDirections), and that
|
||||
// pieces actually swing between hopeless and trivial (contrast).
|
||||
const playable = grownEnough.filter(r => r.audit.unsolvable === 0 && r.stats.firstTurnDirections === 2
|
||||
&& r.stats.lockedShare <= .9 && r.audit.endgameMinOpen >= 2
|
||||
&& r.stats.lockedShare <= .9 && r.audit.endgameTightShare <= MAX_TIGHT_SHARE
|
||||
&& r.stats.minRelease >= MIN_RELEASE && r.contrast.contrast >= MIN_CONTRAST
|
||||
// The show is the payout. An opening that offers two rim pieces and a 0.3s
|
||||
// hop gives a casual player nothing to enjoy before the thinking starts.
|
||||
@@ -116,9 +129,9 @@ playable.sort((a, b) => (b.show.openingBestMs - a.show.openingBestMs)
|
||||
const g1 = grownEnough.filter(r => r.stats.firstTurnDirections === 2);
|
||||
const g2 = g1.filter(r => r.stats.lockedShare <= .9);
|
||||
const g3 = g2.filter(r => r.audit.unsolvable === 0);
|
||||
const g4 = g3.filter(r => r.audit.endgameMinOpen >= 2);
|
||||
const g4 = g3.filter(r => r.audit.endgameTightShare <= MAX_TIGHT_SHARE);
|
||||
const g5 = g4.filter(r => r.stats.minRelease >= MIN_RELEASE);
|
||||
console.log(`\n【门槛】长成 ${grownEnough.length} → 首转双向 ${g1.length} → 锁住≤90% ${g2.length} → 无不可解态 ${g3.length} → 终局朝向≥2 ${g4.length} → 每转释放≥${MIN_RELEASE} ${g5.length} → 反差≥${MIN_CONTRAST} ${playable.length}`);
|
||||
console.log(`\n【门槛】长成 ${grownEnough.length} → 首转双向 ${g1.length} → 锁住≤90% ${g2.length} → 无不可解态 ${g3.length} → 终局紧局≤${(MAX_TIGHT_SHARE*100).toFixed(1)}% ${g4.length} → 每转释放≥${MIN_RELEASE} ${g5.length} → 反差≥${MIN_CONTRAST} ${playable.length}`);
|
||||
const g6 = g5.filter(r => r.contrast.contrast >= MIN_CONTRAST);
|
||||
const g7 = g6.filter(r => r.show.openingChoices >= MIN_OPENING_CHOICES);
|
||||
const g8 = g7.filter(r => r.show.openingBestMs >= MIN_OPENING_SHOW);
|
||||
|
||||
Reference in New Issue
Block a user