File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ function hashString(str: string): number {
1111 return hash >>> 0 ; // Ensure unsigned
1212}
1313
14- // Mulberry32 - a simple, fast seeded PRNG
14+ // A simple, fast seeded PRNG
15+ // https://gist.github.com/tommyettinger/46a874533244883189143505d203312c?permalink_comment_id=4854318#gistcomment-4854318
1516function createSeededRandom ( seed : number ) : ( ) => number {
16- return function ( ) {
17- seed |= 0 ;
18- seed = ( seed + 0x6d2b79f5 ) | 0 ;
19- let t = Math . imul ( seed ^ ( seed >>> 15 ) , 1 | seed ) ;
20- t = ( t + Math . imul ( t ^ ( t >>> 7 ) , 61 | t ) ) ^ t ;
21- return ( ( t ^ ( t >>> 14 ) ) >>> 0 ) / 4294967296 ;
17+ return ( ) => {
18+ seed = ( seed + 0x9e3779b9 ) | 0 ;
19+ let t = Math . imul ( seed ^ ( seed >>> 16 ) , 0x21f0aaad ) ;
20+ t = Math . imul ( t ^ ( t >>> 15 ) , 0x735a2d97 ) ;
21+ return ( ( t ^ ( t >>> 15 ) ) >>> 0 ) / 4294967296 ;
2222 } ;
2323}
2424
You can’t perform that action at this time.
0 commit comments