Deeper is richer: about 4.7x the ore in a world, shallow layers unchanged (t3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 17:30:51 -04:00
co-authored by Claude Opus 5.5
parent 1da33e3703
commit 26d17c2b1d
3 changed files with 56 additions and 8 deletions
+42
View File
@@ -134,6 +134,48 @@ const shallowOre = run('(()=>{let cu=0,fe=0;for(let x=0;x<W;x++)for(let d=0;d<15
check('copper and iron ore are within reach of the surface', shallowOre[0] > 2000 && shallowOre[1] > 200, shallowOre);
check('the deep layers fill the extra depth', run('depthY(0.905) - surfBase') > 600 && run('Math.abs(depthY(0.28) - surfBase - 131) <= 1'), run('[depthY(0.28), depthY(0.5), depthY(0.905)].map(y => y - surfBase)'));
check('it is still warm a hundred cells above the ground', run('AMB[surfBase - 100]') > 0, run('AMB[surfBase - 100].toFixed(1)'));
// Compare ore density in the generated shallow and deep underground, excluding air.
const oreDepth = run(`(() => {
let shallow = 0, shallowOre = 0, deep = 0, deepOre = 0, deepCu = 0;
const ores = [COALV, CUV, FEV, SNV, ZNV, AGV, AUV];
for (let y = 0; y < H; y++) {
const d = y - surfBase;
const fy = d <= shallowD ? d / shallowD * 0.3 : 0.3 + (d - shallowD) / (underD - shallowD) * 0.7;
for (let x = 0; x < W; x++) {
const m = mat[y * W + x];
if (y < surfY[x] || m === EMPTY) continue;
const ore = ores.includes(m);
if (fy < 0.25) { shallow++; if (ore) shallowOre++; }
if (fy > 0.6) { deep++; if (ore) deepOre++; }
if (fy > 0.5 && m === CUV) deepCu++;
}
}
return [shallowOre / shallow, deepOre / deep, deepCu];
})()`);
check('deep ground has at least three times the shallow ore density', oreDepth[1] >= 3 * oreDepth[0], `shallow ${oreDepth[0]}, deep ${oreDepth[1]}`);
check('copper veins also form below half depth', oreDepth[2] > 0, oreDepth[2]);
// Medium seed 424242: keep each ore's increase within its intended balance.
run('generateWorld(424242, 3072, 1280, null)');
const oreBalance = run(`(() => {
const ids = [COALV, CUV, FEV, ZNV, SNV, AGV, AUV], counts = ids.map(() => 0);
let shallowHash = 2166136261;
for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
const m = mat[y * W + x], j = ids.indexOf(m);
if (j >= 0) counts[j]++;
if (depthU(y) < 0.25) shallowHash = Math.imul(shallowHash ^ (j >= 0 ? m : 0), 16777619) >>> 0;
}
return { counts, shallowHash };
})()`);
const oldOre = [33493, 26508, 77679, 11797, 7723, 3638, 1681];
const oreNames = ['coal', 'copper', 'iron', 'zinc', 'tin', 'silver', 'gold'];
oreNames.forEach((name, j) => {
const ratio = oreBalance.counts[j] / oldOre[j];
const lo = j < 2 ? 4.5 : j < 5 ? 4 : 3, hi = j < 2 ? 5.5 : j < 5 ? 5 : 4;
check(`${name} stays within its intended increase`, ratio >= lo && ratio <= hi, ratio.toFixed(2));
});
const totalOre = oreBalance.counts.reduce((a, b) => a + b, 0);
check('total ore is about 4.5 to 5 times the original', totalOre >= 162519 * 4.5 && totalOre <= 162519 * 5, totalOre);
check('shallow ore matches the original generator', oreBalance.shallowHash === 706875613, oreBalance.shallowHash);
run('generateWorld(99, 4096, 1536, null)');
const marks = run('(()=>{let lakes=0,peaks=0,inLake=false;for(let x=1;x<W-1;x++){const l=mat[(surfY[x]-1)*W+x]===WATER;if(l&&!inLake)lakes++;inLake=l;if(surfY[x]<surfBase-100&&surfY[x]<=surfY[x-1]&&surfY[x]<surfY[x+1])peaks++;}return [lakes,peaks]})()');
check('a large world has several lakes and mountains across it', marks[0] >= 2 && marks[1] >= 2, marks);