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

BattleDelegate#setupTerritoriesAbandonedToTheEnemy:671 - java.lang.IllegalStateException #12351

Open tripleabuilderbot opened 9 months ago

tripleabuilderbot commented 9 months ago

Map

crazygs_ww1

Log Message

Should not be possible to have a normal battle in: Macedonia and have abandoned or only bombing there too.

TripleA Version

2.6.14602

Java Version

11.0.19

Operating System

Windows 10

Stack Trace

Exception: java.lang.IllegalStateException Should not be possible to have a normal battle in: Macedonia and have abandoned or only bombing there too.
java.lang.Exception
    at games.strategy.triplea.delegate.battle.BattleDelegate.setupTerritoriesAbandonedToTheEnemy(BattleDelegate.java:671)
    at games.strategy.triplea.delegate.battle.BattleDelegate.doInitialize(BattleDelegate.java:206)
    at games.strategy.triplea.delegate.battle.BattleDelegate.start(BattleDelegate.java:87)
    at games.strategy.engine.framework.ServerGame.startStep(ServerGame.java:575)
    at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:443)
    at games.strategy.engine.framework.ServerGame.runNextStep(ServerGame.java:345)
    at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:312)
    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)
asvitkine commented 8 months ago

This is using "2023-December-05` - 2.6.14602 Pre-release", which is not so old. I'm not sure we had any fixes for something like this since, so this probably still exists.

But I'm not sure what the repro steps are...

WCSumpton commented 6 months ago

@asvitkine

This error happens because land combat rounds have been set to something other then -1. At the end of the combat rounds the defender only has air units left, and the attacker has ground forces. The territory becomes contested. The next player has to be the defender otherwise the air unit might be removed during a subsequent players turn. 2024-5-11-CrazyG's-Giant-World-War-1-v0.2.tsvg.zip In the attached save a United Kingdom Infantry as attacked for Austria 01 to Austria 02 and the lone Austria-Hungary Airship. The battle has ended in a stalemate, and it is now Austria-Hungary's turn. Select "Done" for combat move, and ok because nothing has moved. Because Austria 02 is the only battle, it will try to select it and the ensuing error message will show.

Hope this helps.

Cheers...

asvitkine commented 6 months ago

@WCSumpton

Thanks for the explanation. I assume the expected behavior would be for a combat to still happen there, with airship attacking the ground unit? (and if the active player doesn't want that to happen, they should actually abandon and move out the air ship?)

WCSumpton commented 6 months ago

Thanks for the explanation. I assume the expected behavior would be for a combat to still happen there, with airship attacking the ground unit? (and if the active player doesn't want that to happen, they should actually abandon and move out the air ship?)

That would be my thought. This "error" still occurs even when the airship is replaced with a recon-plane. Also, if Austria-Hungary only moves air unit into the territory, the "error" will occur. If Austria-Hungary moves a ground unit into territory Austria 02, then the battle will happen normally. If Austria-Hungary wins the battle, the airship is allowed to remain in territory Austria 02 and other air unit are allowed to land there during the non-combat move.

Cheers...

Cernelius commented 6 months ago

For your information, these rules (limited combat rounds) were made with the intent of replicating the game mechanics of a well known WW1 board-game. However, that project was never ultimated.

In the aforementioned board-game, you were never allowed to have air units anywhere unless the same power owning the air unit also owned at least one land unit in the territory (Yes, you also need 1 land unit in the territory to land your air unit in that territory.), and actually at least one of the land units needed to be an infantry, so you practically needed at least one infantry in every territory in which you had one or more air units (allied units do not count).

To be clear, I'm not saying that these rules should be hard-coded as part of what at this situation (but rather that they should be added to the program under an other property or some-such): I'm just wondering whether this problem may derive by something related to the fact that, in the rules-set which was intended to be supported when the limited combat rounds properties were added, it would just never happen to have air units fighting alone against land units or whatever.

As a side note, in that board-game there are no airships: all air units are fighters.

If @panther2 can check what I said, that would be good.

WCSumpton commented 3 months ago

@Cernelius

If I understand correctly, you're stating that the air unit should not have been left alone of combat. Air Unit cannot conquer territories, only land units. Thus, with the absents of any friendly land unit, the territory should have been conquered by the attacking player. Question would be should the defending air unit be forced to retreat, removed from play because it can't land, or left in the territory, making it still contested but under the attacker's control.

Cheers...

Cernelius commented 3 months ago

@Cernelius

If I understand correctly, you're stating that the air unit should not have been left alone of combat.

Assuming that you mean "alone in combat", no, I am not and did not because this game (for the "crazygs_ww1" map) does not have a property or anything forcing you not to leave air units alone (because such a feature is not available in TripleA as far as I know). That is what the game for which the limited combat rounds properties were made would have had if it would have been actually finalized as a TripleA game.

First of all, it's not "in combat": aircraft cannot be left alone (ever) in that game which I'm referencing beside when moving (flying past zones).

Secondarily, that is the entire rules-set for the intended game. I'm a big fan of atomization and a big opposer of hardcoding blobs of different rules just because they are related.

In the intended game, aircraft being alone would never happen, but this surely should be possibly happening in TripleA as I'm not saying that TripleA should hardcode all the rules which make that impossible to happen in a single bundle beside the fact that it could happen anyway by having aircraft alone in the starting setup.

Please do not overlook the fact that I've said that "I'm not saying that these rules should be hard-coded as part of what at this situation".

Air Unit cannot conquer territories, only land units.

Yes, but in the full rules-set this is due to the fact that they can never be inside a territory with no land units of the same player beside when flying past it, so there is no direct impossibility for land units to conquer territories: if you take that rules-set and add a rule that aircraft can conquer territories like land units, that rule would change absolutely nothing because they are restricted always to be there with at least one land unit (which can conquer the territory, so them being able to do so too would be superfluous as an ability just as much them being unable to do so would be superfluous as a restriction).

Thus, with the absents of any friendly land unit, the territory should have been conquered by the attacking player.

Assuming that you mean "absence of", absolutely not, or at least not at all what I meant.

Question would be should the defending air unit be forced to retreat, removed from play because it can't land, or left in the territory, making it still contested but under the attacker's control.

None of these.

In what I assume to be (quite certainly) the intended rules-set, this situation of having aircraft only either in attack or defence would just never happen, so there is no answer to what should happen when something that should never happen happens. However, it can happen and it is right that it happens in TripleA because in TripleA you do not have to take all the rules of an entire rules-set, so, if you take the rule of limited combat rounds but do not take other rules, this can happen and is fine.

I think that either I have badly expressed myself or you misunderstood what I said. My previous post was just affirming that maybe this problem exists because in the intended game this problem would never present itself. It can, however, present itself in TripleA.

I concur with what assumed by @asvitkine

I assume the expected behavior would be for a combat to still happen there, with airship attacking the ground unit? (and if the active player doesn't want that to happen, they should actually abandon and move out the air ship?)

However, I just wanted to point out that here we are all assuming: we do not have any rules-set where this situation would actually present itself (as far as I know), so nobody can say that this is how it should work.

We are not looking at a rules-set here: we are looking at a hybrid TripleA game taking elements of different rules-set, and one that takes one or more elements of a rules-set the implementation of which in TripleA has been left unfinished to a very considerable extent (although being unfinished would be actually true in every case because no TripleA game is fully compliant).

This is not a situation in which we can ask @panther2 (or anyone else) what should happen, though it would be certainly good if he can tell us what he assumes it makes the most sense that it should happen.

I still defer to @panther2 to check what I said because I'm not an expert of the game in question (and I've actually never played it nor memorized its entire rules-book).


Long story short, I would encourage @asvitkine (or whoever) to fix the issue as described (by him) so long as I'm not missing something.

I'm sorry if I have delayed fixing this problem: I just meant giving context. Please proceed with fixing this problem.

Even better would be finally to complete the actual intended rules-set to which the limited combat rounds properties belong, but that would entail a series of feature requests or some developer who knows that game and knows TripleA and is willingly to add what is missing, but this is true of pretty much every problematic rules-set in Triple A (for example, Revised).

If any developer is interested, we can do it progressively: I can tell what is in my opinion the next most important item to implement and how I would implement it in TripleA. However, I'm not touching the main map (for that rules-set) itself because I'm not clear on copyrights, so I'm not sure if this would make testing impossible or what.

WCSumpton commented 3 months ago

@Cernelius

I'm the one that should apologize. Bringing context to these discussions is very helpful, so thank you.

I understand that the "game" that, for which limiting battle rounds, required infantry to be in every territory in which other land or air units occupy/attacked. And that an infantry unit would have to be the last casualty taken for either offence/defense.

But since this rule was not completed implemented, what steps should be taken to correct the produced error, which does, as of now stop the game. As @asvitkine stated, he assumed that I was asking for allowing the battle to continue, as a corrective measure. Which I agreed. Which I am assuming that as of now so do you.

In the "game" there is only one combat round, but air battles continue until there is only on winner of both attacker and defender are eliminated. So, any unit that are brought into the conflicted territory remain, air or land units.

Without going into the basic game, there are 2 (3) properties that are about contested territories; "Contested Territories Produce No Income", "Abandoned Territories May Be Taken Over Immediately" and then there's the undocumented "All Units Can Attack From Contested Territories". None of which deal with the problem. If the original attacker brings in more air units on latter turns, the must NCM to another territory. The original defender, because they are still listed at the original owner of the territory, may bring in more units, land and/or air, on their combat move, those units that survive, land and/or air, may still remain in the contested territory. But they may not NCM more units, land and/or air, into the contested territories. Also, if there is a factory there the original defender may still produce units inside a contested territory.

Now to look at some basic rules. A player can only produce out of a factory unit that they have owned since the beginning of their turn. Would this allow for contested territories? If "Contested Territories Produce No Income" if false (default), then yes, if you are collecting income for a territory, contested or not, you should be able to produce units there also. A player can only land an air unit on a territory that was either owned or allied that player since the beginning of their turn. Would this allow for landing in contested territories? Again, I would go back to "Contested Territories Produce No Income" and if false then yes. They should also be able to bring in other units during NCM since they still collect income, and thus should be considered owners of the territory. This would also mean that air units, without the presence of ground units, could attack from this territory into this territory. And if they win retain control of the territory. If true, then all surviving air unit, even those from the original attack would need to retreat from this territory.

But these are my thoughts and assumptions on how these rules should interreact with each other.

I'm sorry if I have delayed fixing this problem: I just meant giving context. Please proceed with fixing this problem.

As stated before, context IMHO, is always appreciated. Sometime the quick fix is not always the right answer.

Cheers...