add mulberry32 for seeded rng

This commit is contained in:
Laetitia (O-01-67) 2023-02-21 16:33:13 -05:00 committed by GitHub
parent 95c392e15f
commit a40ea1c8fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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