"Doesn't connect" marks on transport ends that would join one block off (t67 phase 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 15:23:08 -04:00
co-authored by Claude Opus 5.5
parent 99d4889f1e
commit ccca66c0c1
8 changed files with 94 additions and 14 deletions
+20
View File
@@ -103,3 +103,23 @@ function joinSnap(code, v, cells) {
}
return 0;
}
// "Doesn't connect": an end with no join that would join seamlessly, with a diagonal piece
// involved, if its block sat one higher (-1) or lower (+1) in empty space. 0 when no near miss.
// A drop join counts as connected. The moved block is tried through a small override view of
// `planned`, so ghost maps are never copied.
const NO_PIECE = [0, 0];
function nearMiss(bx, by, end, planned = null) {
const b = by * BW + bx, p = planned && planned.get(b), code = p ? p[0] : blockP[b], v = p ? p[1] : blockV[b];
const own = pieceEnds(code, v);
if (!own[end] || endJoin(bx, by, end, planned) >= 0) return 0;
const entry = [code, v];
for (const dy of [-1, 1]) {
const y = by + dy, nb = y * BW + bx;
if (y < 0 || y >= BH || blockP[nb] || (planned && planned.get(nb))) continue;
const view = { get: k => k === b ? NO_PIECE : k === nb ? entry : planned ? planned.get(k) : undefined };
view.has = k => view.get(k) !== undefined;
const j = endJoin(bx, y, end, view);
if (j >= 0 && !joinIsDrop(bx, y, end, j, view) && (own[end].diagonal || endAt(j >> 1, j & 1, view).diagonal)) return dy;
}
return 0;
}