diff --git a/gradle.properties b/gradle.properties index 4557ed5..7c3f023 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ kotlin.code.style=official specifyKotlinAsDependency=false projectGroup=ru.dbotthepony.kommons -projectVersion=3.5.0 +projectVersion=3.5.1 guavaDepVersion=33.0.0 gsonDepVersion=2.8.9 diff --git a/src/main/kotlin/ru/dbotthepony/kommons/random/GJRAND64Random.kt b/src/main/kotlin/ru/dbotthepony/kommons/random/GJRAND64Random.kt index b55c7a6..8da65a0 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/random/GJRAND64Random.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/random/GJRAND64Random.kt @@ -21,7 +21,7 @@ open class GJRAND64Random protected constructor( protected var s3: Long, marker: Nothing? ) : RandomGenerator { - constructor(seed0: Long, seed1: Long) : this(seed0, seed1, 2000001L, 0L, null) + constructor(seed0: Long, seed1: Long) : this(seed0, seed1, SEED2_INIT, SEED3_INIT, null) constructor(seed: Long) : this(seed, 0L) final override fun nextLong(): Long { @@ -38,4 +38,9 @@ open class GJRAND64Random protected constructor( s1 += s3 return s0 } + + companion object { + const val SEED2_INIT = 2000001L + const val SEED3_INIT = 0L + } } diff --git a/src/main/kotlin/ru/dbotthepony/kommons/random/JSF32Random.kt b/src/main/kotlin/ru/dbotthepony/kommons/random/JSF32Random.kt index 78f5815..753d936 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/random/JSF32Random.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/random/JSF32Random.kt @@ -28,7 +28,7 @@ open class JSF32Random protected constructor( * see [https://burtleburtle.net/bob/rand/smallprng.html](https://burtleburtle.net/bob/rand/smallprng.html) and * [https://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html](https://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html) */ - constructor(seed: Int) : this(0xf1ea5eed.toInt(), seed, seed, seed, null) { + constructor(seed: Int) : this(SEED0_INIT, seed, seed, seed, null) { for (i in 0 until 20) nextInt() } @@ -47,4 +47,8 @@ open class JSF32Random protected constructor( val b = nextInt().toLong() and 0xFFFFFFFFL return a.shl(32) or b } + + companion object { + const val SEED0_INIT = 0xf1ea5eed.toInt() + } } diff --git a/src/main/kotlin/ru/dbotthepony/kommons/random/JSF64Random.kt b/src/main/kotlin/ru/dbotthepony/kommons/random/JSF64Random.kt index f8d7deb..e0146b3 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/random/JSF64Random.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/random/JSF64Random.kt @@ -33,7 +33,7 @@ open class JSF64Random( * see [https://burtleburtle.net/bob/rand/smallprng.html](https://burtleburtle.net/bob/rand/smallprng.html) and * [https://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html](https://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html) */ - constructor(seed: Long) : this(0xf1ea5eedL, seed, seed, seed, null) { + constructor(seed: Long) : this(SEED0_INIT, seed, seed, seed, null) { for (i in 0 until 20) nextLong() } @@ -46,4 +46,8 @@ open class JSF64Random( s3 = e + s0 return s3 } + + companion object { + const val SEED0_INIT = 0xf1ea5eedL + } }