Joins follow the travel direction: the next piece goes right after the end (t67 phase 2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 14:09:28 -04:00
co-authored by Claude Opus 5.5
parent fd35bf334f
commit 45538cc18e
16 changed files with 363 additions and 236 deletions
+18 -8
View File
@@ -93,13 +93,6 @@ function entScrewTick(e, p) {
const frontX = e.ix + (dx > 0 ? BAR_W - 1 : 0), frontY = e.iy + (dy > 0 ? BAR_H - 1 : 0);
const front = frontY * W + frontX, dest = straightScrewNext(front, p);
if (dest < 0) return;
if (dest !== front + dx + dy * W) {
const q = part[dest];
if (!screwAccepts(q, dx, dy)) return;
const x = (dest % W) & ~3, y = entScrewLane((dest / W) | 0, e.iy);
if (entScrewMove(e, x, y, true)) stats.moved++;
return;
}
let x = e.ix + dx, y = e.iy + dy, next = 0, ax = 0, ay = 0;
for (let k = 0; k < (dx ? BAR_H : BAR_W); k++) {
const i = entScrewEdge(e, dx, dy, k);
@@ -149,6 +142,23 @@ function entDiagonalScrewTick(e, p) {
for (let yy = y; yy < y + BAR_H; yy++) for (let xx = x; xx < x + BAR_W; xx++) if (part[yy * W + xx]) return;
if (entScrewMove(e, x, y, false, dy < 0)) { e.vx = dx * 0.5; e.vy = dy * 0.6; stats.moved++; }
}
// A same-row flat belt drops its bar into a joined screw, just as grains fall off its face.
function entBeltScrewEnter(e) {
if (e.ix & 3) return false;
const y = e.iy + BAR_H;
if (y >= H || (y & 3)) return false;
const b = (y >> 2) * BW + (e.ix >> 2), c = blockP[b], v = blockV[b];
if (c !== BP_BELT && c !== BP_FILTER) return false;
if (c === BP_FILTER && filterPassAt(e.m, y * W + e.ix)) return false;
if (netSat(y * W + e.ix) <= 0) return false;
const d = c === BP_FILTER ? (v & 128 ? 1 : -1) : (v & 1 ? 1 : -1);
const join = endJoin(b % BW, (b / BW) | 0, d > 0 ? 1 : 0);
if (join < 0 || blockP[join >> 1] !== BP_SCREW) return false;
e.x = e.ix; e.y = e.iy; e.vx = e.vy = 0;
const nb = join >> 1;
if (!(tick & 1) && entScrewMove(e, nb % BW * BS, ((nb / BW) | 0) * BS, true, true)) stats.moved++;
return true;
}
// Bars stay level; their highest contact follows the face one grain per belt beat.
function entSlopeBeltTick(e) {
const bottom = e.iy + BAR_H;
@@ -188,7 +198,7 @@ function entTick() {
let ix = e.ix; const iy = e.iy;
const screw = entScrewAt(ix, iy);
if (screw) entScrewTick(e, screw);
else if (!entSlopeBeltTick(e)) {
else if (!entBeltScrewEnter(e) && !entSlopeBeltTick(e)) {
// what is underneath?
let belt = 0, bsat = 0, transport = false, support = iy + BAR_H >= H;
if (!support) {