Finally fix those NaN errors!
authorTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 5 Jun 2022 16:20:31 +0000 (12:20 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 5 Jun 2022 16:20:31 +0000 (12:20 -0400)
src/commonMain/kotlin/starshipfights/game/game_ability.kt
src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt

index 3d23d6a32693ca741b26ca2a4e2187ee4b492c93..108c36786434af1f75fc3959625411f34ca024a8 100644 (file)
@@ -249,7 +249,7 @@ sealed class PlayerAbilityType {
                        if (angleDiff - shipInstance.movement.turnAngle > EPSILON) return GameEvent.InvalidAction("Illegal move - turn angle is too big")
                        
                        val maxMoveSpeed = shipInstance.movement.moveSpeed
-                       val minMoveSpeed = maxMoveSpeed * (angleDiff / shipInstance.movement.turnAngle) / 2
+                       val minMoveSpeed = if (maxMoveSpeed < EPSILON) maxMoveSpeed else (maxMoveSpeed * (angleDiff / shipInstance.movement.turnAngle) / 2)
                        
                        val moveFrom = moveOrigin + (newFacingNormal * minMoveSpeed)
                        val moveTo = moveOrigin + (newFacingNormal * maxMoveSpeed)
index bf6287eda4982c07796bfcdb6927837eb4b343f1..625279dda445d85d185c9ee975a1603076cf1135 100644 (file)
@@ -12,7 +12,7 @@ import javax.swing.UIManager
 object AITesting {
        @JvmStatic
        fun main(args: Array<String>) {
-               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
+               UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel")
                
                val instinctVectorCounts = listOf(5, 11, 17)
                val instinctVectorOptions = instinctVectorCounts.map { it.toString() }.toTypedArray()