Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Javascript random number generator, that allows to be seeded
- //quite high quality numbers even for its simplicity.
- //Suitable for simple random number generation (not crypto).
- //Since it allows seeding, it also allows the user to run this in sync with others.
- myrand=
- {
- z:1,
- w:2,
- next:function(i)
- {
- myrand.z=36969*(myrand.z & 65535)+(myrand.z>>16);
- myrand.w=18000*(myrand.w & 65535)+(myrand.w>>16);
- var res=Math.abs(myrand.z<<16)+myrand.w;
- return i?res%i:res;
- },
- seed:function(a,b)
- {
- myrand.z=Math.abs(a||1);
- myrand.w=Math.abs(b||1);
- if(a===undefined || b===undefined)
- {
- myrand.seed(myrand.next(),myrand.next());
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement