summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-08-18 22:49:39 -0400
committersiddharth <s@ricketyspace.net>2021-08-18 22:49:39 -0400
commitb21d4cd78a5b8aeb4cefd30e1393432843d6a8cb (patch)
treeb4ab90509c33a38d893fcfe1314172c618d340d8
parent3fa30dc118a9a7fc7285317b3ba6ce5a32aa23e7 (diff)
lib: MTRand.index -> MTRand.Index
-rw-r--r--lib/rng.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/rng.go b/lib/rng.go
index b98dbd7..4c566e0 100644
--- a/lib/rng.go
+++ b/lib/rng.go
@@ -22,7 +22,7 @@ var mtF uint32 = 1812433253
// MT19937 instance struct
type MTRand struct {
GenSt [624]uint32
- index uint32
+ Index uint32
initialized bool
}
@@ -30,7 +30,7 @@ var mtLowerMask uint32 = (1 << mtCoefR) - 1
var mtUpperMask uint32 = 0xFFFFFFFF & (^mtLowerMask)
func (r *MTRand) Seed(s uint32) {
- r.index = mtCoefN
+ r.Index = mtCoefN
r.GenSt[0] = s
for i := uint32(1); i < mtCoefN; i++ {
r.GenSt[i] = (0xFFFFFFFF &
@@ -40,20 +40,21 @@ func (r *MTRand) Seed(s uint32) {
}
func (r *MTRand) Extract() uint32 {
- if !r.initialized || r.index >= mtCoefN {
+ if !r.initialized || r.Index >= mtCoefN {
if !r.initialized {
r.Seed(5489)
}
r.twist()
}
- y := r.GenSt[r.index]
+ y := r.GenSt[r.Index]
+
y = y ^ ((y >> mtCoefU) & mtCoefD)
y = y ^ ((y << mtCoefS) & mtCoefB)
y = y ^ ((y << mtCoefT) & mtCoefC)
y = y ^ (y >> mtCoefL)
- r.index = r.index + 1
+ r.Index = r.Index + 1
y = 0xFFFFFFFF & y
return y
@@ -69,7 +70,7 @@ func (r *MTRand) twist() {
}
r.GenSt[i] = r.GenSt[(i+mtCoefM)%mtCoefN] ^ xA
}
- r.index = 0
+ r.Index = 0
}
func (r *MTRand) UnTemper(y uint32) uint32 {