You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			22 lines
		
	
	
		
			390 B
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			390 B
		
	
	
	
		
			TypeScript
		
	
| 
											6 years ago
										 | export class RNG { | ||
|  |   private _seed: number; | ||
|  |   constructor(seed: number) { | ||
|  |     this._seed = seed % 2147483647; | ||
|  |     if (this._seed <= 0) { | ||
|  |       this._seed += 2147483646; | ||
|  |     } | ||
|  |   } | ||
|  | 
 | ||
|  |   public next() { | ||
|  |     return (this._seed = (this._seed * 16807) % 2147483647); | ||
|  |   } | ||
|  | 
 | ||
|  |   public nextFloat() { | ||
|  |     return (this.next() - 1) / 2147483646; | ||
|  |   } | ||
|  | 
 | ||
|  |   public random() { | ||
|  |     return this.nextFloat(); | ||
|  |   } | ||
|  | } |