q
This commit is contained in:
parent
810ad6f5cb
commit
de7c6c32bd
123 changed files with 13201 additions and 6213 deletions
|
|
@ -2,36 +2,18 @@ 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";
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition) throw new Error(message);
|
||||
console.log(`OK: ${message}`);
|
||||
}
|
||||
|
||||
function deriveSeed(worldSeed, terrainType, variant) {
|
||||
let hash = (worldSeed >>> 0) ^ 0x9e3779b9;
|
||||
hash = Math.imul(hash ^ (variant >>> 0), 668265263) >>> 0;
|
||||
for (const char of String(terrainType || "auto")) hash = Math.imul(hash ^ char.charCodeAt(0), 16777619) >>> 0;
|
||||
return hash >>> 0;
|
||||
}
|
||||
|
||||
const initial = generateMap(114514);
|
||||
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, 0);
|
||||
const seed = derivePatchSeed(world.seed, terrainType, 0);
|
||||
const worker = new Worker(new URL("./browser-worker-node-shim.mjs", import.meta.url), { type: "module" });
|
||||
let terminalMessage = null;
|
||||
let cancelStartedAt = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue