mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
using proper hashing function
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package net.torvald.terrarum.tests
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.random.XXHash32
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.serialise.toLittle
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -20,7 +24,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
println()
|
||||
|
||||
val rng2 = com.sudoplay.joise.generator.HQRNG()
|
||||
/*val rng2 = com.sudoplay.joise.generator.HQRNG()
|
||||
|
||||
repeat(512) {
|
||||
println(rng2.getRange(0, 10))
|
||||
@@ -29,4 +33,24 @@ fun main(args: Array<String>) {
|
||||
// getTarget: 0..(t-1) (exclusive)
|
||||
// getRange: low..high (inclusive)
|
||||
// get01: 0.0 until 1.0 (exclusive)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
for (tries in 0 until 16) {
|
||||
repeat(BlockCodex.DYNAMIC_RANDOM_CASES + 12) { repeats ->
|
||||
val x = 349 + repeats
|
||||
val y = 9492 + tries
|
||||
|
||||
|
||||
val offset = XXHash32.hash(((x and 0xFFFF).shl(16) or (y and 0xFFFF)).toLittle(), 10000)
|
||||
|
||||
//print("${offset.toString().padStart(2, '0')} ")
|
||||
print("${offset.fmod(BlockCodex.DYNAMIC_RANDOM_CASES).toString().padStart(2, '0')} ")
|
||||
}
|
||||
println()
|
||||
println()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user