export function hashSeed(input) { const value = String(input) let hash = 2166136261 for (let index = 0; index < value.length; index += 1) { hash ^= value.charCodeAt(index) hash = Math.imul(hash, 16777619) } return hash >>> 0 } export function createRng(seed) { let state = typeof seed === 'number' ? seed >>> 0 : hashSeed(seed) return function next() { state += 0x6D2B79F5 let value = state value = Math.imul(value ^ (value >>> 15), value | 1) value ^= value + Math.imul(value ^ (value >>> 7), value | 61) return ((value ^ (value >>> 14)) >>> 0) / 4294967296 } } export function shuffleWithRng(items, rng) { const result = [...items] for (let index = result.length - 1; index > 0; index -= 1) { const swapIndex = Math.floor(rng() * (index + 1)) const temp = result[index] result[index] = result[swapIndex] result[swapIndex] = temp } return result }