text: /**
   * Created by Simon Liu on 2016/5/19.
   * Mersenne Twister算法译为马特赛特旋转演算法
   */
  
  let MyRandom = function (seed, min, max) {
    this.seed = seed;
    this.min = min;
    this.max = max;
  
    this.MT = buildMT(this.seed);
    this.index = 0;
  };
  
  MyRandom.prototype.next = function () {
    return extractNumber(this.MT, this.index) % (this.max - this.min + 1) + this.min;
  };
  
  let buildMT = function (seed) {
    let MT = [];
    MT[0] = seed;
    for (let i = 1; i < 624; i++) {
      MT[i] = 0xffffffff & (0x6c078965 * (MT[i - 1] ^ (MT[i - 1] >> 30)) + i);
    }
  
    return MT;
  };
  
  let generateNumber = function (MT) {
    for (let i = 0; i < 624; i++) {
      let y = (MT[i] & 0x80000000) + (MT[(i + 1) % 624] & 0x7fffffff);
      MT[i] = MT[(i + 397) % 624] ^ (y >> 1);
      if (y % 2 != 0) {
        MT[i] ^= 0x9908b0df;
      }
    }
  };
  
  let extractNumber = function (MT, index) {
    if (index == 0) {
      generateNumber(MT);
    }
    let y = MT[index];
    y ^= (y >> 11);
    y ^= ((y << 7) & 0x9d2c5680);
    y ^= ((y << 15) & 0xefc60000);
    y ^= (y >> 18);
    index = (index + 1) % 624;
    return y;
  };
  
  module.exports = MyRandom;