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.33k stars 393 forks source link

ConcurrentBattleCalculator#calculate:196 - java.lang.IllegalStateException #11851

Closed tripleabuilderbot closed 1 year ago

tripleabuilderbot commented 1 year ago

User Description

Never seen this happening or this game having any crashes with the AI using 2.5.

Map

270bc_wars

Log Message

java.lang.IllegalStateException: Attackers and defenders collections must be distinct with no duplicates. This helps catch logic errors in AI code that would otherwise be hard to debug.

TripleA Version

2.6.14423

Java Version

11.0.19

Operating System

Windows 10

Stack Trace

Exception: java.lang.IllegalStateException java.lang.IllegalStateException: Attackers and defenders collections must be distinct with no duplicates. This helps catch logic errors in AI code that would otherwise be hard to debug.
java.lang.Exception
    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:196)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.callBattleCalc(ProOddsCalculator.java:250)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.callBattleCalc(ProOddsCalculator.java:226)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.calculateBattleResults(ProOddsCalculator.java:159)
    at games.strategy.triplea.ai.pro.util.ProOddsCalculator.calculateBattleResults(ProOddsCalculator.java:143)
    at games.strategy.triplea.ai.pro.ProNonCombatMoveAi.determineIfMoveTerritoriesCanBeHeld(ProNonCombatMoveAi.java:412)
    at games.strategy.triplea.ai.pro.ProNonCombatMoveAi.doNonCombatMove(ProNonCombatMoveAi.java:109)
    at games.strategy.triplea.ai.pro.AbstractProAi.move(AbstractProAi.java:133)
    at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:515)
    at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:594)
    at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:451)
    at games.strategy.engine.framework.ServerGame.runNextStep(ServerGame.java:346)
    at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:313)
    at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:92)
    at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:60)
    at java.base/java.lang.Thread.run(Thread.java:829)

Exception: java.lang.IllegalStateException Attackers and defenders collections must be distinct with no duplicates. This helps catch logic errors in AI code that would otherwise be hard to debug.
java.lang.Exception
    at com.google.common.base.Preconditions.checkState(Preconditions.java:512)
    at games.strategy.triplea.odds.calculator.BattleCalculator.mergeUnitCollections(BattleCalculator.java:142)
    at games.strategy.triplea.odds.calculator.BattleCalculator.calculate(BattleCalculator.java:81)
    at games.strategy.triplea.odds.calculator.ConcurrentBattleCalculator.lambda$calculate$4(ConcurrentBattleCalculator.java:184)
    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:183)
Cernelius commented 1 year ago

My report.

I confirm the save loads fine with 2.5 (I tested right after the reporting), though I'm not sure what save it was now.

I'll label this as regression.

asvitkine commented 1 year ago

@Cernelius Do you have a save that reproduces the error?

Cernelius commented 1 year ago

What I did was either loading a save or starting a new game with all players to Hard AI but "barbarians" on Does Nothing AI.

However, I don't remember which save it was, and I've now tried to reproduce it with a few saves (one of which may be that save), but the error is not happening. Also it does not happen when I start a new game like that.

What should I do?

Cernelius commented 1 year ago

This may not be a regression after all. It may be that I don't remember it ever happened to me just because it happens rarely.

asvitkine commented 1 year ago

Adding "Needs Clarification" label as right now it's not actionable. A save file from before the error occurring would be helpful!