mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-02-27 15:46:01 +01:00
Move unit tests and add main methods with special tests
This commit is contained in:
parent
276df76979
commit
e9077c680f
src
system/src/main/java/chylex/hee/game/loot/rng
test/java/chylex/hee/test
main
unit
mechanics
system
@ -10,24 +10,6 @@ class RandomBiasedValueRange(range: ClosedFloatingPointRange<Float>, private val
|
||||
require(highestChanceValue in min..max) { "highestChanceValue must be between min and max" }
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
import java.util.Random
|
||||
import chylex.hee.system.random.nextBiasedFloat
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
val rand = Random()
|
||||
|
||||
(1..100000).map {
|
||||
val min = 3F
|
||||
val max = 10F
|
||||
val highestChanceValue = 6.5F
|
||||
val biasSoftener = 3F
|
||||
(highestChanceValue + (rand.nextBiasedFloat(biasSoftener) * (0.5F + max - highestChanceValue)) - (rand.nextBiasedFloat(biasSoftener) * (0.5F + highestChanceValue - min))).roundToInt()
|
||||
}.groupBy { it }.mapValues { it.value.size }.toList().sortedBy { it.first }
|
||||
|
||||
*/
|
||||
|
||||
override fun generateInt(rand: Random): Int {
|
||||
return (highestChanceValue + (rand.nextBiasedFloat(biasSoftener) * (0.5F + max - highestChanceValue)) - (rand.nextBiasedFloat(biasSoftener) * (0.5F + highestChanceValue - min))).roundToInt()
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package chylex.hee.test.main
|
||||
import chylex.hee.game.loot.rng.RandomBiasedValueRange
|
||||
import java.util.Random
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun main() {
|
||||
val min = 3F
|
||||
val max = 10F
|
||||
val highestChanceValue = 6.5F
|
||||
val biasSoftener = 3F
|
||||
|
||||
val rand = Random()
|
||||
val generator = RandomBiasedValueRange(min..max, highestChanceValue, biasSoftener)
|
||||
val reps = 100000
|
||||
|
||||
val results = (1..reps).map { generator.generateInt(rand) }
|
||||
.groupBy { it }
|
||||
.mapValues { it.value.size }
|
||||
.toList()
|
||||
.sortedBy { it.first }
|
||||
|
||||
val pad1 = results.maxOf { it.first.toString().length }
|
||||
val pad2 = results.maxOf { it.second.toString().length }
|
||||
|
||||
println(results.joinToString("\n") {
|
||||
"${it.first.toString().padStart(pad1)} | ${it.second.toString().padStart(pad2)} | ${((it.second * 100.0) / reps).roundToInt().toString().padStart(2)} %"
|
||||
})
|
||||
}
|
29
src/test/java/chylex/hee/test/main/TombDungeonMobCounts.kt
Normal file
29
src/test/java/chylex/hee/test/main/TombDungeonMobCounts.kt
Normal file
@ -0,0 +1,29 @@
|
||||
package chylex.hee.test.main
|
||||
|
||||
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel
|
||||
import chylex.hee.game.world.feature.tombdungeon.TombDungeonLevel.MobAmount
|
||||
import java.util.Random
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
fun main() {
|
||||
val rand = Random()
|
||||
|
||||
for(level in TombDungeonLevel.values()) {
|
||||
val reps = 100000
|
||||
|
||||
println("\n")
|
||||
println("-".repeat(level.name.length))
|
||||
println(level.name)
|
||||
println("-".repeat(level.name.length))
|
||||
println(MobAmount.values().joinToString("\n") { amount ->
|
||||
"\n " + amount.name + "\n\n" + (1..reps)
|
||||
.map { level.pickUndreadAndSpiderlingSpawns(rand, amount) }
|
||||
.groupingBy { it }
|
||||
.eachCount()
|
||||
.entries
|
||||
.map { ((it.value * 100.0) / reps).roundToInt() to it.key }
|
||||
.sortedWith(compareBy({ -it.first }, { -it.second.first }, { -it.second.second }))
|
||||
.joinToString("\n") { " U = ${it.second.first}, S = ${it.second.second} ... ${it.first} %" }
|
||||
})
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package chylex.hee.test.mechanics.damage
|
||||
package chylex.hee.test.unit.mechanics.damage
|
||||
|
||||
import chylex.hee.game.mechanics.damage.DamageProperties
|
||||
import chylex.hee.game.mechanics.damage.DamageType
|
@ -1,4 +1,4 @@
|
||||
package chylex.hee.test.mechanics.energy
|
||||
package chylex.hee.test.unit.mechanics.energy
|
||||
|
||||
import chylex.hee.game.mechanics.energy.IEnergyQuantity.Floating
|
||||
import chylex.hee.game.mechanics.energy.IEnergyQuantity.Internal
|
@ -1,4 +1,4 @@
|
||||
package chylex.hee.test.system.util
|
||||
package chylex.hee.test.unit.system
|
||||
|
||||
import chylex.hee.game.world.Pos
|
||||
import chylex.hee.system.math.Vec
|
@ -1,4 +1,4 @@
|
||||
package chylex.hee.test.system.util
|
||||
package chylex.hee.test.unit.system
|
||||
|
||||
import chylex.hee.game.inventory.cleanupNBT
|
||||
import chylex.hee.game.inventory.heeTag
|
Loading…
Reference in New Issue
Block a user