Screw conveyors join by the shared rule: low ends and verticals join in the corner block (t67 phase 2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+28
-9
@@ -90,16 +90,32 @@ function entScrewTick(e, p) {
|
||||
if ((tick & 1) || netSat(ci) <= 0 || rnd() > netSat(ci)) return;
|
||||
const dx = SCREW_DX[p], dy = SCREW_DY[p];
|
||||
if (dx && dy) { entDiagonalScrewTick(e, p); return; }
|
||||
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);
|
||||
if (i < 0) return;
|
||||
const xx = i % W, yy = (i / W) | 0;
|
||||
const q = part[i];
|
||||
if (IS_SCREW[q] && q !== p) { next = q; ax = xx; ay = yy; break; }
|
||||
if (IS_SCREW[q] && q !== p) {
|
||||
if (SCREW_DX[q] && SCREW_DY[q]) {
|
||||
const join = endJoin(frontX >> 2, frontY >> 2, dx + dy > 0 ? 1 : 0);
|
||||
if (join < 0 || (join >> 1) !== (yy >> 2) * BW + (xx >> 2)) return;
|
||||
}
|
||||
next = q; ax = xx; ay = yy; break;
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
if (SCREW_DX[next] === -dx && SCREW_DY[next] === -dy) return;
|
||||
if (!screwAccepts(next, dx, dy)) return;
|
||||
x = ax & ~3; y = entScrewLane(ay, e.iy);
|
||||
if (entScrewMove(e, x, y, true)) stats.moved++;
|
||||
return;
|
||||
@@ -115,17 +131,20 @@ function entScrewTick(e, p) {
|
||||
function entDiagonalScrewTick(e, p) {
|
||||
if (tick & 7) return;
|
||||
const dx = SCREW_DX[p], dy = SCREW_DY[p], bx = e.ix & ~3, by = e.iy & ~3, lane = e.iy & 3;
|
||||
for (const [ox, oy] of [[dx, dy], [dx, 0], [0, dy]]) {
|
||||
const x = bx + ox * BS, y = by + oy * BS + lane, q = entScrewAt(x, y);
|
||||
if (!q || (ox && oy && (q < P_SCREW_UR || q > P_SCREW_UL || SCREW_DX[q] !== dx || SCREW_DY[q] !== dy))) continue;
|
||||
const edge = (by + lane) * W + bx + (dx > 0 ? BS - 1 : 0);
|
||||
const dest = diagonalScrewNext(edge, p);
|
||||
if (dest < 0) return;
|
||||
const x = (dest % W) & ~3;
|
||||
let y = (dest / W) | 0;
|
||||
const q = part[dest];
|
||||
if (IS_SCREW[q]) {
|
||||
if (SCREW_DX[q] * dx + SCREW_DY[q] * dy < 0) return;
|
||||
y = Math.min((y & ~3) + BS - BAR_H, y);
|
||||
if (entScrewMove(e, x, y, true)) stats.moved++;
|
||||
return;
|
||||
}
|
||||
const x = bx + dx * BS;
|
||||
let y = by + dy * BS + lane;
|
||||
const belt = y >= 0 && y < H ? mat[y * W + x] : EMPTY;
|
||||
if (dy > 0 && (belt === BELTL || belt === BELTR)) y = (y & ~3) - BAR_H;
|
||||
const join = endJoin(bx >> 2, by >> 2, dx > 0 ? 1 : 0);
|
||||
if (join >= 0 && (blockP[join >> 1] === BP_BELT || blockP[join >> 1] === BP_FILTER)) y -= BAR_H - 1;
|
||||
if (!entScrewFree(x, y)) return;
|
||||
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++; }
|
||||
|
||||
Reference in New Issue
Block a user