Seed Test
<html> <head> <script type="text/javascript" src="https://1119s.wdfiles.com/local--code/seed-test/2"></script> </head> </html>
const original = ["poison", "poison", "poison", "magic", "toxic", "toxic", "toxic"]; function getSeed() { const params = new URLSearchParams(window.location.search); const pz = params.get("pz"); if (pz && /^\d{4}$/.test(pz)) { return parseInt(pz, 10); } else { return null; } } function mulberry32(seed) { return function() { let t = seed += 0x6D2B79F5; t = Math.imul(t ^ t >>> 15, t | 1); t ^= t + Math.imul(t ^ t >>> 7, t | 61); return frac(((t ^ t >>> 14) >>> 0), 4294967296); }; } function shuffleWithSeed(array, seed) { const rng = mulberry32(seed); const arr = array.slice(); // コピー for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(rng() * (i + 1)); [arr[i], arr[j]] = [arr[j], arr[i]]; } return arr; } document.addEventListener("DOMContentLoaded", () => { let seed = getSeed(); if (seed == null) { seed = Math.floor(Math.random() * 1000); } const shuffled = shuffleWithSeed(original, seed); console.log(seed, shuffled); }); function frac(dividend, divisor) { return dividend / divisor; }
ページリビジョン: 8, 最終更新: 10 Jul 2025 02:26





