q
This commit is contained in:
parent
810ad6f5cb
commit
de7c6c32bd
123 changed files with 13201 additions and 6213 deletions
|
|
@ -2,50 +2,30 @@ import { Worker } from "node:worker_threads";
|
|||
import { performance } from "node:perf_hooks";
|
||||
import { generateMap } from "../src/mapPipeline.js";
|
||||
import { createWorldMap } from "../src/worldMap.js";
|
||||
import { buildMaximumProductionLasso, derivePatchSeed } from "./production-fixtures.mjs";
|
||||
|
||||
const budgetMs = Math.max(1, Number(process.env.PATCH_MAX_WORKER_BUDGET_MS) || 60_000);
|
||||
const timeoutMs = Math.max(90_000, budgetMs + 30_000);
|
||||
const worldSeed = Number(process.env.PATCH_TEST_WORLD_SEED ?? 114514) >>> 0;
|
||||
const candidateVariant = Number(process.env.PATCH_TEST_VARIANT ?? 0) >>> 0;
|
||||
|
||||
function deriveSeed(worldSeed, terrainType, variant) {
|
||||
let h = (worldSeed >>> 0) ^ 0x9e3779b9;
|
||||
h = Math.imul(h ^ (variant >>> 0), 668265263) >>> 0;
|
||||
for (const ch of String(terrainType || "auto")) h = Math.imul(h ^ ch.charCodeAt(0), 16777619) >>> 0;
|
||||
return h >>> 0;
|
||||
}
|
||||
|
||||
const initialStartedAt = performance.now();
|
||||
const initial = generateMap(worldSeed);
|
||||
const initialGenerationMs = Math.round(performance.now() - initialStartedAt);
|
||||
const world = createWorldMap(initial);
|
||||
const width = 470;
|
||||
const height = 333;
|
||||
const x0 = Math.max(0, Math.min(world.width - width, world.originX + 238));
|
||||
const y0 = Math.max(0, Math.min(world.height - height, world.originY));
|
||||
const rect = { x0, y0, x1: x0 + width, y1: y0 + height, kind: "lasso" };
|
||||
const insetX = Math.max(4, Math.floor(width * 0.16));
|
||||
const insetY = Math.max(4, Math.floor(height * 0.16));
|
||||
rect.polygon = [
|
||||
{ x: rect.x0 + insetX, y: rect.y0 },
|
||||
{ x: rect.x1 - 1, y: rect.y0 + insetY },
|
||||
{ x: rect.x1 - insetX, y: rect.y1 - 1 },
|
||||
{ x: rect.x0, y: rect.y1 - insetY },
|
||||
];
|
||||
const rect = buildMaximumProductionLasso(world);
|
||||
|
||||
const terrainType = initial.terrainTemplate?.terrainType || initial.terrainDebug?.terrainType || "auto";
|
||||
const seed = deriveSeed(world.seed, terrainType, candidateVariant);
|
||||
const seed = derivePatchSeed(world.seed, terrainType, candidateVariant);
|
||||
const candidatePlan = [{ candidateId: `max-worker:${candidateVariant}`, candidateOrdinal: 1, variant: candidateVariant, seed }];
|
||||
const worker = new Worker(new URL("./browser-worker-node-shim.mjs", import.meta.url), { type: "module" });
|
||||
const startedAt = performance.now();
|
||||
let progressEvents = 0;
|
||||
let maxRssBytes = process.memoryUsage().rss;
|
||||
let maxHeapBytes = process.memoryUsage().heapUsed;
|
||||
let lastLabel = "";
|
||||
const memoryTimer = setInterval(() => {
|
||||
const memory = process.memoryUsage();
|
||||
maxRssBytes = Math.max(maxRssBytes, memory.rss);
|
||||
maxHeapBytes = Math.max(maxHeapBytes, memory.heapUsed);
|
||||
}, 100);
|
||||
|
||||
async function finish(exitCode, payload) {
|
||||
|
|
@ -68,7 +48,6 @@ async function finish(exitCode, payload) {
|
|||
budgetMs,
|
||||
withinBudget,
|
||||
maxRssBytes,
|
||||
maxHeapBytes,
|
||||
progressEvents,
|
||||
lastLabel,
|
||||
searchStatus: payload?.searchStatus || null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue