Provide initialization magics as constants
This commit is contained in:
parent
5c42f4eba1
commit
4681ce8a13
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=3.5.0
|
projectVersion=3.5.1
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -21,7 +21,7 @@ open class GJRAND64Random protected constructor(
|
|||||||
protected var s3: Long,
|
protected var s3: Long,
|
||||||
marker: Nothing?
|
marker: Nothing?
|
||||||
) : RandomGenerator {
|
) : 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)
|
constructor(seed: Long) : this(seed, 0L)
|
||||||
|
|
||||||
final override fun nextLong(): Long {
|
final override fun nextLong(): Long {
|
||||||
@ -38,4 +38,9 @@ open class GJRAND64Random protected constructor(
|
|||||||
s1 += s3
|
s1 += s3
|
||||||
return s0
|
return s0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SEED2_INIT = 2000001L
|
||||||
|
const val SEED3_INIT = 0L
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
* 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)
|
* [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)
|
for (i in 0 until 20)
|
||||||
nextInt()
|
nextInt()
|
||||||
}
|
}
|
||||||
@ -47,4 +47,8 @@ open class JSF32Random protected constructor(
|
|||||||
val b = nextInt().toLong() and 0xFFFFFFFFL
|
val b = nextInt().toLong() and 0xFFFFFFFFL
|
||||||
return a.shl(32) or b
|
return a.shl(32) or b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SEED0_INIT = 0xf1ea5eed.toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ open class JSF64Random(
|
|||||||
* see [https://burtleburtle.net/bob/rand/smallprng.html](https://burtleburtle.net/bob/rand/smallprng.html) and
|
* 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)
|
* [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)
|
for (i in 0 until 20)
|
||||||
nextLong()
|
nextLong()
|
||||||
}
|
}
|
||||||
@ -46,4 +46,8 @@ open class JSF64Random(
|
|||||||
s3 = e + s0
|
s3 = e + s0
|
||||||
return s3
|
return s3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SEED0_INIT = 0xf1ea5eedL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user