summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rng.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/rng.go b/lib/rng.go
index 94cbd6c..c39b83a 100644
--- a/lib/rng.go
+++ b/lib/rng.go
@@ -71,3 +71,24 @@ func (r *MTRand) twist() {
}
r.index = 0
}
+
+func (r *MTRand) UnTemper(y uint32) uint32 {
+ y = y ^ (y >> mtCoefL)
+
+ y0 := y
+ y = y0 ^ ((y0 << mtCoefT) & mtCoefC)
+ y = y0 ^ ((y << mtCoefT) & mtCoefC)
+
+ y0 = y
+ y = y0 ^ ((y0 << mtCoefS) & mtCoefB)
+ y = y0 ^ ((y << mtCoefS) & mtCoefB)
+ y = y0 ^ ((y << mtCoefS) & mtCoefB)
+ y = y0 ^ ((y << mtCoefS) & mtCoefB)
+
+ y0 = y
+ y = y0 ^ (y0 >> mtCoefU)
+ y = y0 ^ (y >> mtCoefU)
+
+ y = 0xFFFFFFFF & y
+ return y
+}