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 7ec103ac8..d37b80c50 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 @@ -24,12 +24,12 @@ class CMWCRandom(seed: Long = System.nanoTime()) : RandomGenerator, RandomSource this.seed = seed carry = Integer.remainderUnsigned(seed.toInt(), CMWC_CARRY_MAX) - // init state with regular LCG produced values - state[0] = seed.toInt() - state[1] = seed.shr(32).toInt() + var lcg = seed - for (i in 2 until state.size) { - state[i] = 69069 * state[i - 2] + 362437 + // init state with regular LCG produced values + for (i in 1 until state.size) { + lcg = lcg * 6364136223846793005 + 1442695040888963407 + state[i] = lcg.ushr(32).toInt() } stateIndex = state.size - 1