mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
terragen: rock band generator wip
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user