Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property



  • In a battle, the method CheckForUnitsThatCanRollLeft is called in two places.

    1. Before the subs and standard units roll (so, after aa and naval bombardment)
    2. At the end of a round when a defender either has no more units or only infrastructure units.

    The method checks if the attacker only has units that cannot roll and if the defender has at least one unit that can roll. If that is the case, the attacker units are removed. It also does the same check with the attacker and defender reversed.

    What I'm trying to understand is why the first check (before standard attack rolls) only occurs if "Transport Casualties Restricted" is enabled and the second check doesn't care if "Transport Casualties Restricted".

    Is there a rule scenario where if the defender only has units with no rolls, the attacker must continue to try and hit them?

    Also, what exactly does "Transport Casualties Restricted" supposed to mean?


  • Admin

    @Trevan said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    Transport Casualties Restricted

    IIRC "Transport Casualties Restricted" set to true means you cannot select transports as casualties (v3 rules).

    Is there a rule scenario where if the defender only has units with no rolls, the attacker must continue to try and hit them?

    If the attacker has attack power (assuming v3 rules), then likely it should then be an auto-win for the attacker and no choice for retreat. IE: a destroyer vs transport in v3, the destroyer automatically wins at that point. If the attacker does not have any attack power, then we get into the stalemate rules.



  • @LaFayette said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    If the attacker has attack power (assuming v3 rules), then likely it should then be an auto-win for the attacker and no choice for retreat. IE: a destroyer vs transport in v3, the destroyer automatically wins at that point. If the attacker does not have any attack power, then we get into the stalemate rules.

    What about non v3 rules?


  • Admin

    @Trevan Somewhat undefined but also an unexpected state. Pre-V3 transports have defensive power (AFAIK, all pre-V3 units have defensive power).



  • @LaFayette said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    @Trevan Somewhat undefined but also an unexpected state. Pre-V3 transports have defensive power (AFAIK, all pre-V3 units have defensive power).

    In that case, they would have rolls left, correct? So this code would ignore them.

    What about other units or other rules that would cause my scenario to happen: Is there a rule scenario where if the defender only has units with no rolls, the attacker must continue to try and hit them?


  • Admin

    @Trevan AFAIK that situation is an 'auto-kill' and the attacker should just win and be given no option to retreat (assuming the attacker has any firepower remaining). In such cases we are almost automatically referring to V3+ (implicitly).


  • Moderators

    @Trevan said in

    What about other units or other rules that would cause my scenario to happen: Is there a rule scenario where if the defender only has units with no rolls, the attacker must continue to try and hit them?

    The only thing I can think of is if there were limited combat rounds. Idk of any situations like that happening. Be better to auto kill for sure. Maybe a check for combat rounds being limited ?

    Idk just a thought 🙂


  • Moderators Admin

    The behaviour relative to these things is subjected to problems. I think it would be more productive for you first to check out such reported problems, so to have a better idea about what is wrong or right in the code (and avoid just maybe improving something wrong). I also think this is going to be, at least in part, a duplicate of issues already opened and possibly clear enough.

    Regardless, quickly to summarize the main point, in v3 and following the combat ends immediately if offenceful units are against defenceless only units, while this doesn't happen in v1 and v2. However, in the basic v1 and v2 games there are no defence 0 units, so you never have this situation. Applying v1 and v2 rules to the aforementioned case (offenceful units are against defenceless only units, assuming a custom map with v1 or v2 rules and defenceless units), what I believe it should happen is that you keep potentially eliminating the defenceless units, in the course of normal combat rounds, until either you decide to retreat (if you can) or all defending units are eliminated (so you can decide to retreat or to make more combat rounds, either to eliminate all defending units or possibly to retreat at a later time, after having eliminated some more of them). The only automatism that can be implemented, based on the rules, is to destroy all defending units if you cannot retreat (since, in this case only, the rules would force you keeping fighting until eliminating all defending units, anyway).

    On this regard, I suggest the defenceless defending units mandatory destruction before retreat to be made an optional rule with its own property. I think the trick of taking out your defenceful units, to leave only the defenceless ones, thereby making the offender unable to retreat, is nonsensical. I would, however, suggest automatically to destroy all defending units if they are all defenceless and you cannot retreat or choose not to retreat (basically, the property would determine if this step happens before the retreat step or immediately after).

    https://github.com/triplea-game/triplea/issues/4688

    I'll use D1914NML, with Low Luck enabled and no Tech, to make an example of what I mean.

    6 infantry and 6 field_gun attack 1 territory defended by 2 trench and 1 infantry. During the first round of combat, the defender takes out 1 infantry and 1 trench, while only 1 damaged trench remains in the battle, on the defensive side.

    CURRENT BEHAVIOUR: The attacker can retreat.

    CORRECT BEHAVIOUR: The attacker cannot retreat and it is forced to kill the remaining trench and take the territory.

    The consequence of that is that, under the correct behaviour, you can never strafe such a territory safely, as the defender can always pull the trick of taking out the infantry (thus, even if you score only 1 hit, the defender can take out the infantry and leave 4 hitpoints of trenches that you will be obliged to kill).

    I personally prefer the current wrong behaviour, so I was suggesting leaving it as an option (property) for mapmakers. I also guess the players of D1914NML are currently playing by the (wrong) engine behaviour, since I'm under the impression either almost no one reads any rulebooks or most people just prefer going with the engine anyway, or both.



  • Those are all good points but they are talking about what happens at the end of the round (my number 2 in the first post). I'm asking about the scenario before the standard/regular units fire.

    Let's say you have a battle that at the beginning of the round, the defender only has units that can't roll. The option "Transport Casualties Restricted" is false. With the current code base, the attacker will have to make a roll. Afterwards, the remaining units will be auto-killed.

    Is there a reason for why the attacker needs to make that extra roll?


  • Moderators Admin

    @Trevan said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    Those are all good points but they are talking about what happens at the end of the round (my number 2 in the first post). I'm asking about the scenario before the standard/regular units fire.

    Let's say you have a battle that at the beginning of the round, the defender only has units that can't roll. The option "Transport Casualties Restricted" is false. With the current code base, the attacker will have to make a roll. Afterwards, the remaining units will be auto-killed.

    Is there a reason for why the attacker needs to make that extra roll?

    Assuming that "Transport Casualties Restricted" false is meant to detect that the game is following a v1 or v2 rules set, I believe there should be no autodestruction, as I said. So the check before the regular fire is acting correctly (if it is supposed to act only if the game is detected as being a v3 rules set).


    As I said, I believe you should consider first all related problems. By testing it in the past, I believe how it works, currently, is that the remaining units are removed only after having given you the option to retreat.

    To answer your question directly:

    Is there a reason for why the attacker needs to make that extra roll?

    Yes, because, this way, they are able to retreat, if one or more defending units remain (except that this is an incorrect behaviour for v3 and following, which I suggest to be kept as optional), since the step after the rolls is also (incorrectly) after the retreat step (am I right that it is?).



  • I'm looking at the second place where the auto-kill is happening. And I think I misread the code. I think the auto-kill rarely ever happens there. It first checks that CollectionUtils.getMatches(defendingUnits, Matches.unitIsNotInfrastructure()).size() == 0. So, it will only do the auto kill IF there are only infrastructure units available. And only those infrastructure units will be auto-killed.

    So the main auto-kill only happens before standard attack.

    Another question. In this auto-kill location after the standard attack, it will only remove undefended transports IF "Transport Casualties Restricted" is true. But it will always remove units with no rolls. But the auto-kill location before the standard attack, it will only kill undefended transports AND units with no rolls IF "Transport Casualties Restricted". Any ideas why the two locations treat units with no rolls differently? Should they be treated the same? And if so, which way should it be treated?


  • Moderators Admin

    If I understand and recall correctly, this is how it works:

    • There is an autodestruction step before the fire steps that checks "Transport Casualties Restricted" being true.
    • There is an autodestruction step after the retreat steps that doesn't checks "Transport Casualties Restricted" being true.

    Correct?


    If this is correct, this causes the following problems, for which several issues have bee opened (and possibly are already open):

    • You have autodestruction steps only at some points, while, by rules, v3+ should have it anytime only defenceless remain against one or more offenceful (so the step should be at the start of the first combat round and after every step that may eliminate one or more defending units), while v1 and v2 should never have it (but it is good having it at least if the attacker cannot retreat, to skip usuless clicks).
    • The autodestruction step after the retreat step is wrongly placed and pointless if everything else would be correctly placed, as, if that would act, it would have already acted during an identical step before the retreat step (the retreat step is not a step that may eliminate one or more defending units).

    However, as I said, I personally like the current (wrong) behaviour of causing autodestruction only after having the option to retreat (that is destroying the defenceless defending units only if you choose not to retreat), so I encourage the developers to keep the current behaviour as an option (a property that allows retreating against defenceless only units, as you currently can).


    I hope now everything is clear. I think I've summarized at least a number of issues reported over the years, here. Once the defenceless case is fixed, the next step would be expanding it the same way to the case in which the defending units cannot target any offending units, while the offending units can (which is even more problematic and less supported, I believe).


  • Moderators Admin

    @Trevan said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    I'm looking at the second place where the auto-kill is happening. And I think I misread the code. I think the auto-kill rarely ever happens there. It first checks that CollectionUtils.getMatches(defendingUnits, Matches.unitIsNotInfrastructure()).size() == 0. So, it will only do the auto kill IF there are only infrastructure units available. And only those infrastructure units will be auto-killed.

    So the main auto-kill only happens before standard attack.

    You are probably right if you are looking at something before the retreat step. However, I believe you should find an "auto-kill" step for defenceless (not only infrastructures) after the retreat step.

    Another question. In this auto-kill location after the standard attack, it will only remove undefended transports IF "Transport Casualties Restricted" is true. But it will always remove units with no rolls. But the auto-kill location before the standard attack, it will only kill undefended transports AND units with no rolls IF "Transport Casualties Restricted". Any ideas why the two locations treat units with no rolls differently? Should they be treated the same? And if so, which way should it be treated?

    As I said, there are problems related to mass destruction of units, that is generally wrongly implemented. I at least need to know if what you are talking about is immediately after the defensive fire or also after the step in which you may be able to retreat. Also you should clarify what you mean with "no rolls" (does that refer only to units that actually have 0 rolls (and maybe defence 1 or more) or also to units that have positive rolls (normally 1) but defence 0?).



  • @Cernel said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    If I understand and recall correctly, this is how it works:

    • There is an autodestruction step before the fire steps that checks "Transport Casualties Restricted" being true.
    • There is an autodestruction step after the retreat steps that doesn't checks "Transport Casualties Restricted" being true.

    Correct?

    Partially.

    There are two types of auto-destruction: 1) unescorted transports 2) units with no rolls. #1 is always controlled by "Transport Casualties Restricted". #2 is only controlled by "Transport Casualties Restricted" before the standard fire step. After the standard fire step, it doesn't care about that property.

    The auto destruction also never happens after the retreat steps. It is either before the standard attack or after the standard attack but before the retreat step. Now, technically, after the retreat step, it will start a new round and will then run the auto destruction step that occurs before the standard attack, so in a way it does happen after the retreat step 🙂 But that is technically in a new round.

    @Cernel said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    As I said, there are problems related to mass destruction of units, that is generally wrongly implemented. I at least need to know if what you are talking about is immediately after the defensive fire or also after the step in which you may be able to retreat. Also you should clarify what you mean with "no rolls" (does that refer only to units that actually have 0 rolls (and maybe defence 1 or more) or also to units that have positive rolls (normally 1) but defence 0?).

    After the defensive fire. As I mentioned above, there is technically no auto-kill after the retreat step.

    If a unit has attack/defense power > 0 or has a unit support attachment is considered to have rolls left. So the opposite of that is a unit with "no rolls".


  • Moderators Admin

    @Cernel said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    As I said, there are problems related to mass destruction of units, that is generally wrongly implemented. I at least need to know if what you are talking about is immediately after the defensive fire or also after the step in which you may be able to retreat. Also you should clarify what you mean with "no rolls" (does that refer only to units that actually have 0 rolls (and maybe defence 1 or more) or also to units that have positive rolls (normally 1) but defence 0?).

    After the defensive fire. As I mentioned above, there is technically no auto-kill after the retreat step.

    If a unit has attack/defense power > 0 or has a unit support attachment is considered to have rolls left. So the opposite of that is a unit with "no rolls".

    That is not answering my question. From a mapmaker perspective, when you give "attack" and "defense" values, that is not defining the rolls that the unit has. Also I'm not sure if by power you mean the multiplication of strength and rolls (that is 0 as long as at least one of the two is 0). I'll make it easier to be answered. Which ones of the following two is what you define units having "no rolls":

    1. A unit with defence 1 or more and defensive rolls 0.
    2. A unit with defence 0 and defensive rolls 1 or more.

    And is that after all supports have been applied?


    A mapmaker can make a unit defenceless in one or both of two ways: By setting it's defence to 0 or by setting its defensive rolls to 0. I just want to be sure that you are considering both cases. Additionally, you could also make the unit unable to target any units, that would be substantially the same as having power 0, and should be actually treated the same way.



  • @Cernel said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    That is not answering my question. From a mapmaker perspective, when you give "attack" and "defense" values, that is not defining the rolls that the unit has. Also I'm not sure if by power you mean the multiplication of strength and rolls (that is 0 as long as at least one of the two is 0). I'll make it easier to be answered. Which ones of the following two is what you define units having "no rolls":

    1. A unit with defence 1 or more and defensive rolls 0.
    2. A unit with defence 0 and defensive rolls 1 or more.

    And is that after all supports have been applied?


    A mapmaker can make a unit defenceless in one or two ways, or both: By setting it's defence to 0 or by setting its defensive rolls to 0. I just want to be sure that you are considering both cases.

    Here's the code that defines whether a unit has "rolls". This is existing code, by the way.

          // if unit has attack or defense, return true
          final UnitAttachment ua = UnitAttachment.get(ut);
          if (attack && ua.getAttack(player) > 0) {
            return true;
          }
          if (!attack && ua.getDefense(player) > 0) {
            return true;
          }
          // if unit can support other units, return true
          return !UnitSupportAttachment.get(ut).isEmpty();
    

    So, I think #2 would be considered to have no rolls, unless it also has a unit support attachment.


  • Moderators Admin

    @Trevan You can paste that, and I appreciate the effort, but I'm not understanding it. That looks like something that checks if the unit has no attack or no defence, which would make no sense. The defending units should only be checked for defence (they must be all defenceless, but it doesn't matter if they are offenceful or not). The offending units should only be checked for offence (at least one of them must be offenceful, but it doesn't matter if it is defenceful or not).

    On top of this, as I said, a unit able to targe no units currently in the battle should be treated exactly the same way as a powerless unit.



  • @Cernel said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    @Trevan You can paste that, and I appreciate the effort, but I'm not understanding it. That looks like something that checks if the unit has no attack or no defence, which would make no sense. The defending units should only be checked for defence (they must be all defenceless, but it doesn't matter if they are offenceful or not). The offending units should only be checked for offence (at least one of them must be offenceful, but it doesn't matter if it is defenceful or not).

    On top of this, as I said, a unit able to targe no units currently in the battle should be treated exactly the same way as a powerless unit.

    I don't know how to explain it any better than. A unit that has an attack (in the attack case) or a unit that has a defense (in the defense case) is considered to be "useful" (for lack of a better term). In addition, units that have a support attachment are also considered to be "useful". If all of the units are not "useful" and the opposing player has non-infrastructure unit, then all of the units are auto-killed.

    This only happens if "Transport Casualties Restricted" is true or if it is false and the defender only has infrastructure units left.

    I feel like the second case is a rare situation and probably never reached by most players. I'm not sure how to replicate that situation in a game, so if anyone has an idea on how to replicate it, I'd appreciate it.


  • Admin

    @Trevan said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    This only happens if "Transport Casualties Restricted" is true or if it is false and the defender only has infrastructure units left.
    I feel like the second case is a rare situation and probably never reached by most players. I'm not sure how to replicate that situation in a game, so if anyone has an idea on how to replicate it, I'd appreciate it.

    Indeed, you'd have to build a map specifically with those settings.

    The lack of support attachments is to ensure that the defender power won't change. There can be enemy negative buffs, in which case you would not want an auto-kill. For example say there was a suicide unit that lasted one round and gave -1 to all defenders for one round. If there is one attacker and the negative buff unit, they could potentially auto-kill the whole defensive stack.

    Generally the rule is, if the defender has no power left, and the attacker would just need to sit there and keep rolling dice, then it's an auto-kill situation.

    @Cernel the attack/defense properties referenced in code come straight from the XML unit properties. It could be debatable that those should be multiplied by the number of rolls and then checked if zero. The check for support attachment is notable as units with non-zero power but zero rolls could perhaps be eligible for support buffs that could change as the battle progresses.


  • Moderators

    @LaFayette said in Question on MustFightBattle#checkForUnitsThatCanRollLeft and "Transport Casualties Restricted" property:

    Generally the rule is, if the defender has no power left, and the attacker would just need to sit there and keep rolling dice, then it's an auto-kill situation.

    👍


Log in to reply