Last active
December 15, 2015 21:29
-
-
Save hbsnow/5326596 to your computer and use it in GitHub Desktop.
Xorshift による疑似乱数生成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// xor128 class | |
var xor128 = { | |
// member | |
x: 123456789, | |
y: 362436069, | |
z: 521288629, | |
w: 88675123, | |
// method | |
setSeed: function(seed){ | |
this.w = seed; | |
}, | |
generate: function(){ | |
var t = this.x ^ (this.x << 11); | |
this.x = this.y; | |
this.y = this.z; | |
this.z = this.w; | |
this.w = (this.w ^ (this.w >>> 19) ^ (t ^ (t >>> 8))) >>> 0; | |
return this.w; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment