From a40ea1c8fa174f33f90ed2356e53f64f22d5bf14 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Tue, 21 Feb 2023 16:33:13 -0500 Subject: [PATCH] add mulberry32 for seeded rng --- mods/code_library.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mods/code_library.js b/mods/code_library.js index 83da7ecd..031942ac 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -40,6 +40,15 @@ return Math.floor(Math.random() * (max - min + 1)) + min }; + function mulberry32(a) { //Mulberry32 implemented in JS from StackOverflow, https://gist.github.com/tommyettinger/46a874533244883189143505d203312c + return function() { + var t = a += 0x6D2B79F5; + t = Math.imul(t ^ t >>> 15, t | 1); + t ^= t + Math.imul(t ^ t >>> 7, t | 61); + return ((t ^ t >>> 14) >>> 0) / 4294967296; + } + } //returns random function seeded with a + //Arrays //Shallow array comparer by SO Tim Down: https://stackoverflow.com/a/10260204