Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1export function seededRandom(seed: string) {
2 const hashFromSeed = seed.split('').reduce(function (a, b) {
3 a = (a << 5) - a + b.charCodeAt(0);
4 return a & a;
5 }, 0);
6 // Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
7 const x = Math.sin(hashFromSeed) * 10000;
8 return x - Math.floor(x);
9}