Advertisement
Guest User

Untitled

a guest
Jan 19th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Srand {
  2.     constructor(seed) {
  3.         if(typeof seed === "undefined" || seed.toString().length == 0) {
  4.             seed = ((Math.random()*0xFFFFFF)).toString(16);
  5.         }
  6.         seed = seed.toString();
  7.         this.seed = seed.length;
  8.         for(var n = 0;n < seed.length;n++) {
  9.             this.seed = (this.seed+(seed[n].charCodeAt(0)*(n*0x13131F)+0x3918FF))%0xFFFFFF;
  10.         }
  11.         this.ram = 0x6F28C3;
  12.         this.rom = 0x29CDFF;
  13.         this.rum = 0x4CC9AB;
  14.         this.iter = 0;
  15.     }
  16.     next() {
  17.         this.ram = (this.ram + this.iter)%0xFFFFFF;
  18.         this.iter++;if(this.iter > 5)this.iter = 0;
  19.         this.rom = (this.rom + this.iter)%0xFFFFFF;
  20.         this.rum = (this.rum + this.iter)%0xFFFFFF;
  21.         return ((this.seed*this.ram*this.rom*this.rum)%0xFFFFFF)/0xFFFFFF;
  22.     }
  23.     bool() {
  24.         this.ram = (this.ram + this.iter)%0xFFFFFF;
  25.         this.iter++;if(this.iter > 5)this.iter = 0;
  26.         this.rom = (this.rom + this.iter)%0xFFFFFF;
  27.         this.rum = (this.rum + this.iter)%0xFFFFFF;
  28.         return ((((this.seed*this.ram*this.rom*this.rum)%0xFFFFFF)/0xFFFFFF)>0.5)?true:false;
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement