Skip to content

Instantly share code, notes, and snippets.

@kr9ly
Created November 18, 2013 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kr9ly/7524003 to your computer and use it in GitHub Desktop.
Save kr9ly/7524003 to your computer and use it in GitHub Desktop.
XorShift.js
function XRandom(seed) {
this.x = 123456789;
this.y = 362436069;
this.z = 521288629;
this.w = seed;
}
XRandom.prototype.rand = function () {
var t;
t = this.x ^ (this.x << 11);
this.x = this.y;
this.y = this.z;
this.z = this.w;
this.w = this.w=(this.w^(this.w>>19))^(t^(t>>8))
return this.w;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment