Files
deepgrain-foundry/test/t_nozzle.js
T
44r0n7andClaude Opus 5.5 5ce44f842e The nozzle blows no further than it sucks (t34)
With the cursor outside the reach circle, blown grains aim at the circle's edge in the cursor's
direction instead of flying all the way to the cursor, and the blow preview stops there too.
New test/t_nozzle.js and a play.py preview check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 16:35:38 -04:00

33 lines
1.6 KiB
JavaScript

// Blowing aims within the nozzle's reach, with room for the brush and settling.
const { load, suite, flatWorld, ticks, count } = require('./harness');
const { run } = load();
const { check, done } = suite();
function blowSand(distance, radius) {
flatWorld(run, 640, 160, 100);
run('RS = 12345; bot.x = 300 - bot.w / 2; bot.y = 80 - bot.h / 2; bag[SAND] = 40; bagTotal = 40;');
run(`for (let k = 0; k < 40 && bag[SAND]; k++) { toolBlow(300 + ${distance}, 99, ${radius}, SAND); simTick(); }`);
ticks(run, 400);
check('all blown sand lands and stays out of the bag', count(run, run('SAND')) === 40 && run('flyers.length === 0 && bag[SAND] === 0'));
return run(`(() => {
let farthest = 0, cursorDistance = 0;
for (let i = 0; i < N; i++) if (mat[i] === SAND) {
const x = i % W + 0.5, y = Math.floor(i / W) + 0.5;
farthest = Math.max(farthest, Math.hypot(x - 300, y - 80));
cursorDistance = Math.max(cursorDistance, Math.hypot(x - (300 + ${distance} + 0.5), y - 99.5));
}
return { farthest, cursorDistance };
})()`);
}
// Widest brush, 40 grains on flat ground: measured 14.95 grains past REACH.
const BRUSH_AND_SETTLING_MARGIN = 16;
for (const distance of [run('3 * REACH'), run('5 * REACH')]) {
const landing = blowSand(distance, 6);
check('aiming far away lands sand within reach plus brush and settling', landing.farthest <= run('REACH') + BRUSH_AND_SETTLING_MARGIN, landing.farthest.toFixed(2));
}
const nearby = blowSand(30, 0);
check('aiming inside reach still lands sand around the cursor', nearby.cursorDistance <= BRUSH_AND_SETTLING_MARGIN, nearby.cursorDistance.toFixed(2));
done();