mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
using proper hashing function
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.random.XXHash32
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.serialise.toLittle
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-16.
|
||||
@@ -58,8 +60,8 @@ class BlockProp {
|
||||
fun getLumCol(x: Int, y: Int) = if (dynamicLuminosityFunction == 0) {
|
||||
baseLumCol
|
||||
} else {
|
||||
val offset = (x * 214013 + 2531011).ushr(16).fmod(BlockCodex.DYNAMIC_RANDOM_CASES)
|
||||
BlockCodex[BlockCodex.dynamicToVirtualMap[id]!! - offset]._lumCol
|
||||
val offset = XXHash32.hash(((x and 0xFFFF).shl(16) or (y and 0xFFFF)).toLittle(), 10000)
|
||||
BlockCodex[BlockCodex.dynamicToVirtualMap[id]!! - offset.fmod(BlockCodex.DYNAMIC_RANDOM_CASES)]._lumCol
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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