triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.35k stars 399 forks source link

2.0.19404: AaCasualtySelector#individuallyFiredAaCasualties:362 - IllegalStateException #6485

Closed tripleabuilderbot closed 4 years ago

tripleabuilderbot commented 4 years ago

User Description

This error was a map crashing one. It happened in round 7 while AI was calculating its CM as far as I could see. //FrostionAAA

Log Message

java.lang.IllegalStateException: Cannot have more hits than number of die rolls

TripleA Version

2.0.19404

Java Version

11.0.6

Operating System

Windows 10

Exception

java.lang.IllegalStateException: java.lang.IllegalStateException: Cannot have more hits than number of die rolls

Stack Trace

java.lang.IllegalStateException: java.lang.IllegalStateException: Cannot have more hits than number of die rolls
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:600)
    at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:678)
    at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:737)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateParallel(ReduceOps.java:919)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at games.strategy.triplea.odds.calculator.ConcurrentBattleCalculator.calculate(ConcurrentBattleCalculator.java:234)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.callBattleCalc(ProOddsCalculator.java:224)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.callBattleCalc(ProOddsCalculator.java:200)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.calculateBattleResults(ProOddsCalculator.java:133)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.calculateBattleResults(ProOddsCalculator.java:116)
    at games.strategy.triplea.ai.pro.ProCombatMoveAi.determineTerritoriesThatCanBeHeld(ProCombatMoveAi.java:502)
    at games.strategy.triplea.ai.pro.ProCombatMoveAi.doCombatMove(ProCombatMoveAi.java:110)
    at games.strategy.triplea.ai.pro.AbstractProAi.move(AbstractProAi.java:139)
    at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:514)
    at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:538)
    at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:408)
    at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:297)
    at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:61)
    at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:34)
    at games.strategy.engine.framework.startup.launcher.AbstractLauncher.lambda$launch$0(AbstractLauncher.java:16)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Cannot have more hits than number of die rolls
    at games.strategy.triplea.delegate.battle.casualty.AaCasualtySelector.individuallyFiredAaCasualties(AaCasualtySelector.java:362)
    at games.strategy.triplea.delegate.battle.casualty.AaCasualtySelector.getAaCasualties(AaCasualtySelector.java:93)
    at games.strategy.triplea.delegate.battle.FireAa.selectCasualties(FireAa.java:191)
    at games.strategy.triplea.delegate.battle.FireAa$2.execute(FireAa.java:146)
    at games.strategy.triplea.delegate.ExecutionStack.execute(ExecutionStack.java:34)
    at games.strategy.triplea.delegate.battle.MustFightBattle.fight(MustFightBattle.java:649)
    at games.strategy.triplea.odds.calculator.BattleCalculator.calculate(BattleCalculator.java:114)
    at games.strategy.triplea.odds.calculator.ConcurrentBattleCalculator.lambda$calculate$4(ConcurrentBattleCalculator.java:222)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
    at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
    at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
    at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
DanVanAtta commented 4 years ago

@FrostionAAA do you recall which map you were playing when this happened?

FrostionAAA commented 4 years ago

it was in Warcraft War Heroes, now available.

asvitkine commented 4 years ago

That condition doesn't seem to make sense to me?

    if (hits > planeHitPoints) {
      throw new IllegalStateException("Cannot have more hits than number of die rolls");
    }

It's not comparing hits to number of die rolls, but to number of hit points of the planes. Seems it's just wrong?

FrostionAAA commented 4 years ago

These two errors are probably the same:: https://github.com/triplea-game/triplea/issues/6745

trevan commented 4 years ago

I can't assign bugs yet, but I'm working on this. It looks like the problem is two variables were flipped during the FireAa refactoring.