Files
deepgrain-foundry/tools/experiments/worldgen.js
T
44r0n7andClaude Opus 5.5 3f971a94c2 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
2026-10-23 16:05:31 -04:00

26 lines
1.3 KiB
JavaScript

// World generation report: time to generate, how many cells of each material, where the bot
// starts, and what idle ticks and ticks after digging cost.
const { load, ticks } = require('../../test/harness');
const { run } = load();
const t0 = Date.now();
run(`generateWorld(12345, 1024, 640)`);
console.log('worldgen ms', Date.now() - t0);
const names = run(`MD.map(d=>d.name)`);
const counts = run(`(()=>{const c=new Array(NMAT).fill(0); for(let i=0;i<N;i++) c[mat[i]]++; return c;})()`);
counts.forEach((c, i) => { if (c) console.log(String(i).padStart(2), names[i].padEnd(16), c); });
console.log('bot', run(`JSON.stringify(bot)`), 'surf at spawn', run(`surfY[W>>1]`));
// settle cost: run 600 ticks idle
let t1 = Date.now();
ticks(run, 600);
console.log('600 idle ticks ms', Date.now() - t1, 'awake chunks', run(`awake.reduce((a,b)=>a+(b>0),0)`), 'hot', run(`hot.reduce((a,b)=>a+(b>0),0)`));
// dig a big hole near spawn and measure active cost
run(`player.bitTier=3; for (let k=0;k<60;k++) { toolDig(W>>1, surfY[W>>1]+20+k, 6); }`);
t1 = Date.now();
ticks(run, 300);
console.log('300 ticks after digging ms', Date.now() - t1);
// worst case: wake everything
run(`awake.fill(3); hot.fill(6); hotLvl.fill(2)`);
t1 = Date.now();
ticks(run, 60);
console.log('60 ticks all-awake ms', Date.now() - t1);