// Seeded PRNG (mulberry32) + deterministische Hashes fuer Weltgenerierung // mulberry32: erzeugt aus einem 32-bit Seed eine PRNG-Funktion in [0,1) export function mulberry32(seed) { let a = seed >>> 0; return function () { a |= 0; a = (a + 0x6d2b79f5) | 0; let t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } // Hash aus String -> 32-bit unsigned (fuer Seed-Eingabe) export function hashSeed(str) { let h = 2166136261 >>> 0; for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; } // Deterministische 2D-Hash -> [0,1), fuer Baum-Platzierung etc. export function hash2(x, z) { let h = Math.imul(x | 0, 374761393) ^ Math.imul(z | 0, 668265263); h = Math.imul(h ^ (h >>> 13), 1274126177); return ((h ^ (h >>> 16)) >>> 0) / 4294967296; }