Deepgrain Foundry: move from a claude.ai artifact to a local repository
The game as of artifact version 24, ready for local development with coding agents. - Source split from three large files into 52 small ones under src/sim, src/render and src/ui, joined in the order in src/manifest.json by build.py. The joined code is unchanged apart from comments; every headless suite gives the same output, and screenshots in both looks are pixel-identical to before. - Light tidying with no change in behaviour: one movement scan loop, shared hazard-stripe and belt shader helpers, unused code removed, a shared check helper for the test suites. - World files can be exported as an ordinary download outside claude.ai. - Tests: broken old scripts removed, experiments moved to tools/, test/run_all.py added. Tools: shot.py (repeatable screenshots), where.py, map.py. - Docs: AGENTS.md, CLAUDE.md, NOTES.md (the owner's to-do inbox), docs/PROJECT_MAP.md, DESIGN.md, TESTING.md, systems notes, the owner's requests and an agent log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K9kLmYADKSEjuwUN3rFxDA
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// Tool helpers: reach, brushes, and plain digging.
|
||||
// ---------- Tools ----------
|
||||
function inReach(x, y) { const dx = x - (bot.x + bot.w / 2), dy = y - (bot.y + bot.h / 2); return dx * dx + dy * dy <= REACH * REACH; }
|
||||
function forBrush(cx, cy, r, fn) {
|
||||
const r2 = (r + 0.5) * (r + 0.5);
|
||||
for (let dy = -r; dy <= r; dy++) for (let dx = -r; dx <= r; dx++) {
|
||||
if (dx * dx + dy * dy > r2) continue;
|
||||
const x = cx + dx, y = cy + dy;
|
||||
if (x < 0 || y < 0 || x >= W || y >= H) continue;
|
||||
if (!inReach(x, y)) continue;
|
||||
if (fn(x, y, y * W + x) === false) return;
|
||||
}
|
||||
}
|
||||
// Drill: breaks solids loose. Nothing goes into the bag.
|
||||
// how far the drill reaches: set by the bit, and stretched or shortened by the pulse width
|
||||
function drillReach(w = drillWidth) { return Math.round(BIT_TIERS[player.bitTier].reach * (PULSE_W[w] || PULSE_W[1]).reach); }
|
||||
function inDrillReach(x, y, w) { const dx = x - (bot.x + bot.w / 2), dy = y - (bot.y + bot.h / 2), R2 = drillReach(w); return dx * dx + dy * dy <= R2 * R2; }
|
||||
// Plain digging in a circle. The game itself uses the resonance drill (drill.js); the tests use
|
||||
// this to clear rock quickly.
|
||||
function toolDig(cx, cy, r) {
|
||||
const tier = BIT_TIERS[player.bitTier];
|
||||
let dug = 0, tooHard = 0, far = 0;
|
||||
forBrush(cx, cy, r, (x, y, i) => {
|
||||
if (!inDrillReach(x, y)) { far++; return; }
|
||||
const m = mat[i];
|
||||
if (bgm[i] && (m === EMPTY || PH[m] === PH_GAS || PH[m] === PH_LIQUID)) { if (cutTree(i, x, y, tier)) dug++; return; }
|
||||
if (PH[m] !== PH_SOLID) return;
|
||||
if (PARTMAT[m] || part[i] || mach[i]) return;
|
||||
const h = HARD[m];
|
||||
if (h > tier.hard) { tooHard = m; return; }
|
||||
const p = digp[i] + tier.speed * 60 / (1 + h * h * 0.6);
|
||||
if (p >= 255) {
|
||||
const to = YLD[m];
|
||||
const b = blockP[((y / BS) | 0) * BW + ((x / BS) | 0)];
|
||||
setCell(i, to, temp[i], 0);
|
||||
discover(to, x, y, m, 'dig');
|
||||
if (b === BP_WALL && !blockIntegrity(((y / BS) | 0) * BW + ((x / BS) | 0))) blockP[((y / BS) | 0) * BW + ((x / BS) | 0)] = 0;
|
||||
dug++;
|
||||
if ((dug & 3) === 0) emit({ t: 'debris', x, y, m });
|
||||
} else digp[i] = p;
|
||||
});
|
||||
stats.dug += dug;
|
||||
let status = '';
|
||||
void 0;
|
||||
if (far && !dug && !tooHard) status = `Out of reach. Your ${tier.name.toLowerCase()} reaches ${drillReach()} grains from the bot.`;
|
||||
if (tooHard && !dug) {
|
||||
const need = BIT_TIERS.find(b => b.hard >= HARD[tooHard]);
|
||||
const nb = need ? need.name.toLowerCase() : 'better bit';
|
||||
status = HARD[tooHard] > 6 ? `${MD[tooHard].name} cannot be drilled.` : `${MD[tooHard].name} is too hard for your ${tier.name.toLowerCase()}. Needs ${/^[aeiou]/.test(nb) ? 'an' : 'a'} ${nb}.`;
|
||||
}
|
||||
return { dug, status, tooHard };
|
||||
}
|
||||
Reference in New Issue
Block a user