Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Srand {
- constructor(seed) {
- if(typeof seed === "undefined" || seed.toString().length == 0) {
- seed = ((Math.random()*0xFFFFFF)).toString(16);
- }
- seed = seed.toString();
- this.seed = seed.length;
- for(var n = 0;n < seed.length;n++) {
- this.seed = (this.seed+(seed[n].charCodeAt(0)*(n*0x13131F)+0x3918FF))%0xFFFFFF;
- }
- this.ram = 0x6F28C3;
- this.rom = 0x29CDFF;
- this.rum = 0x4CC9AB;
- this.iter = 0;
- }
- next() {
- this.ram = (this.ram + this.iter)%0xFFFFFF;
- this.iter++;if(this.iter > 5)this.iter = 0;
- this.rom = (this.rom + this.iter)%0xFFFFFF;
- this.rum = (this.rum + this.iter)%0xFFFFFF;
- return ((this.seed*this.ram*this.rom*this.rum)%0xFFFFFF)/0xFFFFFF;
- }
- bool() {
- this.ram = (this.ram + this.iter)%0xFFFFFF;
- this.iter++;if(this.iter > 5)this.iter = 0;
- this.rom = (this.rom + this.iter)%0xFFFFFF;
- this.rum = (this.rum + this.iter)%0xFFFFFF;
- return ((((this.seed*this.ram*this.rom*this.rum)%0xFFFFFF)/0xFFFFFF)>0.5)?true:false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement