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.32k stars 392 forks source link

MustFightBattle#execute:1344 - java.lang.IllegalStateException #11966

Closed tripleabuilderbot closed 4 months ago

tripleabuilderbot commented 12 months ago

Map

ww2_path_to_victory

Log Message

Round 10,000 reached in a battle. Something must be wrong. Please report this to TripleA. Territory: Northern Manchuria Attacker: Germans Attacking unit types: tactical_bomber,mech_infantry,fighter,infantry,artillery,armour, Defending unit types: bomber,infantry,armour

TripleA Version

2.6.14477

Java Version

11.0.19

Operating System

Windows 11

Stack Trace

Exception: java.lang.IllegalStateException Round 10,000 reached in a battle. Something must be wrong. Please report this to TripleA.
 Territory: Northern Manchuria Attacker: Germans Attacking unit types: tactical_bomber,mech_infantry,fighter,infantry,artillery,armour, Defending unit types: bomber,infantry,armour
java.lang.Exception
    at games.strategy.triplea.delegate.battle.MustFightBattle$29.execute(MustFightBattle.java:1344)
    at games.strategy.triplea.delegate.ExecutionStack.execute(ExecutionStack.java:34)
    at games.strategy.triplea.delegate.battle.MustFightBattle.fight(MustFightBattle.java:714)
    at games.strategy.triplea.odds.calculator.BattleCalculator.calculate(BattleCalculator.java:115)
    at games.strategy.triplea.odds.calculator.ConcurrentBattleCalculator.lambda$calculate$4(ConcurrentBattleCalculator.java:188)
    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.ForkJoinTask.doInvoke(ForkJoinTask.java:408)
    at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:736)
    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:200)
    at games.strategy.triplea.odds.calculator.BattleCalculatorPanel.lambda$updateStats$13(BattleCalculatorPanel.java:1173)
    at java.base/java.lang.Thread.run(Thread.java:829)
asvitkine commented 11 months ago

This one's bizarre. The lists of units seem like they should be able to hit each other...

I also tried running the map with all-AIs and didn't see any issue.

Theoretically, if we're very unlikely, it could be that the battle couldn't finish in 10k rounds if all the units rolled poorly... But that seems very unlikely.

Cernelius commented 11 months ago

@asvitkine This is a well known problem which happens when you have edit mode enabled when you open the battle-calculator. This is due to the fact that, with edit mode enabled, nothing gets hit in battle. You can reproduce it by simply enabling edit mode and thereafter opening the battle-calculator and using it.

In the past, having edit mode enabled during battle allowed you to ignore hits if you so wanted. This had no effects on the battle-calculator, as the default auto-selection did not change (you just had the option to take less hits than you should have had). At some point this changed to edit mode enabled forcing all hits being ignored. I guess this was an unwanted change.

My suggestion would be being impossible to enable edit mode during battle phases, having edit mode being automatically disabled, if currently enabled, as soon as any battle phase starts, and edit mode having no effects on casualties selection or anything else battle-related (so that opening the battle-calculator when edit mode is enabled is no different than otherwise).


About this, I've tested what I said, and it made me make this error report (whereas I was expecting it would link me to this issue): https://github.com/triplea-game/triplea/issues/11975

Cernelius commented 11 months ago

On a second thought, I'm now thinking that this error has been obtained by actually making the battle for that many combat rounds while Edit Mode was already enabled (and most likely the AI was in control of both sides or at least of the attacking one or the battle offered no retreat or anything else that would not require you to stay actively at your keyboard or mouse for 10,000 rounds of combat), as that forces all hits being ignored.

In order to reproduce it, assign Germans to yourself and assign every other player to Fast (AI). During the Germans turn, enable edit mode and skip the turn (leaving Edit Mode enabled) (and wait for a very long time). If you want to be sure to reproduce, set Japanese at War with all Allies with Edit Mode, but it seems that Japanese will actually declare war and attack the Allies on their first turn, eventually causing this issue (so my steps should be just as good).

If you use Hard (AI) instead of Fast (AI), it will cause the other error (https://github.com/triplea-game/triplea/issues/11975) instead (because the AI uses the battle-calculator).

asvitkine commented 4 months ago

Closing in favor of https://github.com/triplea-game/triplea/issues/12488