terragen: rock band generator wip

This commit is contained in:
minjaesong
2023-11-15 13:07:40 +09:00
parent 1affb24cae
commit 3707abcb3a
3 changed files with 32 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ internal object ExportMap2 : ConsoleCommand {
private fun Float.toDitherredByte(): Byte {
val byteVal = this.times(255f).roundToInt()
val error = this - byteVal
val errorInt = if (Math.random() < (1 - error.absoluteValue)) 0 else (1 * error.sign).toInt()
val errorInt = if (Math.random() < error.absoluteValue) 0 else error.sign.toInt()
return (byteVal + errorInt).coerceIn(0..255).toByte()
}

View File

@@ -70,7 +70,7 @@ class Treegen(world: GameWorld, seed: Long, val terragenParams: TerragenParams,
private fun Double.toDitherredInt(rng: HQRNG): Int {
val ibase = this.floorToInt()
val thre = this - ibase
return if (rng.nextDouble() < (1.0 - thre)) ibase else ibase + 1
return if (rng.nextDouble() < 1.0 - thre) ibase else ibase + 1
}
private fun tryToPlant(xs: IntProgression, grassMap: Array<List<Int>>, rng: HQRNG) {