diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt index d37b80c50..bad5a002d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt @@ -22,8 +22,6 @@ class CMWCRandom(seed: Long = System.nanoTime()) : RandomGenerator, RandomSource override fun setSeed(seed: Long) { this.seed = seed - carry = Integer.remainderUnsigned(seed.toInt(), CMWC_CARRY_MAX) - var lcg = seed // init state with regular LCG produced values @@ -32,6 +30,11 @@ class CMWCRandom(seed: Long = System.nanoTime()) : RandomGenerator, RandomSource state[i] = lcg.ushr(32).toInt() } + do { + lcg = lcg * 6364136223846793005 + 1442695040888963407 + carry = lcg.ushr(32).toInt() + } while(carry !in 0 until CMWC_CARRY_MAX) + stateIndex = state.size - 1 gaussian.reset() }