Drill: keep pass-through; restore the original loose-grain nudge, drop dust and push (t92)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
-35
@@ -8,14 +8,14 @@
|
||||
// medium: a cone, the all-rounder
|
||||
// wide: a broad fan that clears a big face close to the bot, but reaches only a short way
|
||||
// Tuned to one material, a pulse passes through everything else and shatters only that, and
|
||||
// loose grains it passes are shaken into short hops, so piles flow and pockets drain.
|
||||
// loose grains it passes are jostled toward the bot, so a shattered vein pours out of the wall.
|
||||
// Built blocks, machines and molds soak pulses up unharmed.
|
||||
// half: half the spread angle; mouth: half the width of the fan where it leaves the bot;
|
||||
// en: energy per ray; damp: energy kept per grain (higher bores deeper); reach: x bit reach
|
||||
// Narrow/medium compensate for rubble now passing pulses; wide keeps its old squared loss.
|
||||
const PULSE_W = [
|
||||
{ name: 'narrow', half: 0.03, mouth: 3.2, rays: 13, en: 1.75, damp: 0.76, reach: 1.45 },
|
||||
{ name: 'medium', half: 0.24, mouth: 3, rays: 23, en: 1.4, damp: 0.69, reach: 1 },
|
||||
{ name: 'narrow', half: 0.03, mouth: 3.2, rays: 13, en: 1.75, damp: 0.75, reach: 1.45 },
|
||||
{ name: 'medium', half: 0.24, mouth: 3, rays: 23, en: 1.4, damp: 0.67, reach: 1 },
|
||||
{ name: 'wide', half: 0.62, mouth: 3.4, rays: 41, en: 1.32, damp: 0.6084, reach: 0.7 },
|
||||
];
|
||||
const PULSE_EVERY = 8, PULSE_SPEED = 2.2, PULSE_K = 240; // ticks between pulses, cells per tick, shake per unit of energy
|
||||
@@ -105,7 +105,6 @@ function pulseTick(step = 0.5) {
|
||||
const loose = 0.97 ** step, liquid = 0.970225 ** step, built = 0.0625 ** step;
|
||||
const skip = 0.986049 ** step, hard = 0.1225 ** step, tuned = 0.9216 ** step;
|
||||
const wood = 0.85 ** step, leaves = 0.97 ** step;
|
||||
let dust = 0;
|
||||
// cells inside the bot's body are not touched (it flies in its own little space)
|
||||
const bx0 = Math.floor(bot.x), by0 = Math.floor(bot.y), bx1 = Math.ceil(bot.x + bot.w) - 1, by1 = Math.ceil(bot.y + bot.h) - 1;
|
||||
for (const p of drillPulses) {
|
||||
@@ -115,37 +114,6 @@ function pulseTick(step = 0.5) {
|
||||
let e = p.en[k];
|
||||
if (e < 0.04) continue;
|
||||
const ray = pulseRay(p.ox, p.oy, p.ang, Wd, -1 + 2 * (k + p.jit) / p.n), ux = ray.ux, uy = ray.uy;
|
||||
// Keep shaking the travelled path while the wave advances, including the pile interior.
|
||||
let shake = Wd.en, kicks = 0;
|
||||
for (let d = 0.5; d < lim && shake >= 0.04 && kicks < 3; d++) {
|
||||
const x = Math.floor(ray.x + ux * d), y = Math.floor(ray.y + uy * d);
|
||||
if (x < 0 || y < 0 || x >= W || y >= H) break;
|
||||
if (x >= bx0 && x <= bx1 && y >= by0 && y <= by1) continue;
|
||||
const i = y * W + x, m = mat[i], ph = PH[m];
|
||||
if (ph === PH_SOLID) break;
|
||||
if (ph === PH_LIQUID) { shake *= 0.970225; continue; }
|
||||
if (ph !== PH_POWDER) continue;
|
||||
shake *= 0.97;
|
||||
if (stamp[i] !== tickStamp && !occ[i] && !part[i] && rnd() < 0.55 * shake) {
|
||||
// Lead with the reverse ray; blocked grains can lift or spill to either side.
|
||||
const backX = Math.abs(ux) > 0.38 ? -Math.sign(ux) : 0;
|
||||
const backY = Math.abs(uy) > 0.38 ? -Math.sign(uy) : 0;
|
||||
const side = rnd() < 0.5 ? -1 : 1;
|
||||
for (let hop = 0; hop < 5; hop++) {
|
||||
const mx = hop < 2 ? backX : hop < 4 ? side : -side;
|
||||
const my = hop === 0 ? backY : hop === 1 ? -1 : -(hop & 1);
|
||||
const nx = x + mx, ny = y + my;
|
||||
if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
|
||||
const j = ny * W + nx;
|
||||
if (mat[j] !== EMPTY && PH[mat[j]] !== PH_GAS) continue;
|
||||
if (occ[j] || part[j] || stamp[j] === tickStamp || !enter(m, ph, j, mx, my)) continue;
|
||||
if (my && CORNER_SEAL && PH[mat[i + mx]] === PH_SOLID && PH[mat[i + my * W]] === PH_SOLID) continue;
|
||||
move(i, j, x, y, nx, ny); kicks++;
|
||||
if (dust < 4) { emit({ t: 'debris', x, y, m, dust: true }); dust++; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let sd = p.s[k];
|
||||
while (sd < lim && e >= 0.04) {
|
||||
sd += step;
|
||||
@@ -160,7 +128,20 @@ function pulseTick(step = 0.5) {
|
||||
}
|
||||
if (ph === PH_LIQUID) { e *= liquid; continue; }
|
||||
if (ph === PH_POWDER) {
|
||||
// loose grains are jostled back toward the bot, so a shattered pocket drains out of the
|
||||
// wall and a bore clears itself: straight back if there is room, else down or up a step
|
||||
e *= loose;
|
||||
// Preserve the old half-grain chance when the sampling distance changes.
|
||||
if (stamp[i] !== tickStamp && rnd() < 1 - (1 - 0.3 * e) ** (2 * step)) {
|
||||
const sx = Math.abs(ux) > 0.3 ? -Math.sign(ux) : 0, sy = Math.abs(uy) > 0.3 ? -Math.sign(uy) : 0;
|
||||
for (const [mx, my] of [[sx, sy], [sx, 1], [sx, -1], [0, sy]]) {
|
||||
if (!mx && !my) continue;
|
||||
const nx = x + mx, ny = y + my;
|
||||
if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
|
||||
const j = ny * W + nx;
|
||||
if ((mat[j] === EMPTY || PH[mat[j]] === PH_GAS) && !occ[j] && !part[j]) { move(i, j, x, y, nx, ny); break; }
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (builtCell(i, x, y)) { e *= built; continue; }
|
||||
|
||||
Reference in New Issue
Block a user