Created
          March 9, 2021 12:45 
        
      - 
      
 - 
        
Save SparK-Cruz/1db35baaf65546506e04be9ddfe54181 to your computer and use it in GitHub Desktop.  
    Seedable Pseudo-Random Number Generator for TypeScript
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export namespace RNG { | |
| let seq = 1; | |
| export function random(seed ?:number) { | |
| if (typeof seed != 'undefined') { | |
| seq = seed; | |
| } | |
| let x = Math.sin(seq++) * 10000; | |
| return x - Math.floor(x); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment