Battle Calculator Question/Feature?



  • Love the battle calculator! Being able to Ctrl + B on a territory is great. However, I'm only able to do that for one side and the opposing side has to be manually added. Is it possible to click on the opposing side's territory and have it automatically populate the battle calculator?

    Additionally, if it's possible for it to be additive that would be even better. For example, if I am Russia and Moscow has the potential to be attacked by enemy units from 3 territories the next turn, I'd like to calculate Moscow's defensive value vs. the potential maximum enemy attack. I can easily calculate the defensive value of Moscow by Ctrl + B on the territory. However, manually adding 3 territories can be necessarily time consuming in complex maps (e.g. TWW) with the potential for multiple unit types combined with large unit counts and multiple territories. Therefore, would it be possible to click on the 3 enemy territories to have their units and attack values automatically populate the attacker/enemy side?


    Additional Ideas


    Implemented Changes

    • Added ability to use CTRL+A and CTRL+D to add attackers and defenders to last active battle calc window
    • Improved default player selection for attacker and defender when opening a new battle calc
    • Allow changing defending player in BC and if any of the current units are owned by the new defending player then units no longer reset
    • When switching players in BC, it only moves over the units of the new attacking player (not any allied units which can't actually attack)
    • BC considers isInfra units in unit counts and TUV (otherwise you could add combat isInfra units and it would appear they would always improve your TUV chance even if they were pretty much always being lost)
    • Can have 0 move and can't combat move units in BC attackers for maps which have limited combat rounds (this is because battles can last more than 1 round so these units can become attackers)
    • Changed action tab hotkey to 'C' and updated help menu
    • Defending units now create separate columns for each player
    • Scales appropriately based on unit list and number of defending players but also has a max window size slightly smaller than TripleA window

    PR: https://github.com/triplea-game/triplea/pull/4576


  • Donators

    @ghostronin if you're attacking you can send your units to your target and it'll do both sides. Then if you don't like the odds just delete your move.

    For the Moscow example only thing I can think of would be to go to local mode and click through to the attackers turn. That would only work by playing by forum not live though. You can hit the space bar to speed up clicking in case you weren't already aware of that.

    Others may have a better way of doing it



  • @beelee Thanks for the feedback. I'm thinking more from the defenders perspective and Moscow example. Going into local mode and clicking thru to the attackers move is an option, but seems time consuming.

    @redrum Thoughts? Is it possible to update the battle calculator to allow for summation of units on click? Thinking thru some of our TWW battles...this would make things much more efficient when calculating force deployments vs. maximum attack as a defender.


  • Admin

    @ghostronin Yeah, I'd like to make adding units from multiple territories as attackers or defenders much easier. This would be especially useful for calculating "potential attacks" against the current nation that you are playing. This is especially true for large maps with many units.

    One of the problems with doing this right now is that you can actually have multiple battle calc windows open at the same time so if you created a hotkey so that you could click to add units from territories as attackers or defenders then you'd have to either ensure that only 1 battle calc window is open, do it to the last one you had selected, or do it to all.

    There are some other technical challenges in that you'd need to potentially add new unit options to the existing battle calc window if you click on territories where the options aren't already available (especially true for multi-nation defenders).

    But this is a good suggestion and I'll add this to the feature list.



  • @redrum One more thought based on the last round from our game. Perhaps simplifying my request with a hotkey to max possible attack, including air. For example, if I had looked at the map more closely I would have realized that you have an advantage with max possible attack in the battle of SZ127 and you brought your air Hupeh, etc. If I had realized I would not have move to SZ127.

    Similar to the hotkey "f" which allows you to see units with movement left, one hotkey could show max possible attack and highlight units that could attack a certain territory. Likely this feature would get more use on complex maps such as we discussed.

    With this being a "perfect information" map I think this feature could simplify the decision making process for the player without a downside as there is no "fog of war" or other unknown variables.


  • Admin

    @ghostronin Yeah, I've thought about this before and go back and forth. The problem is you still need to consider if things change between the current players turn and when their enemy would go. So it could often give a false sense in the case of can-openers and such. The AI actually does use something similar to this when determining where to defend.



  • @redrum Could clarify/provide example of this piece :things change between the current players turn and when their enemy would go." I'm not sure I understand the full breadth of what could change, e.g. tech, multi-nation moves (TWW - Italy then German move against Russia).


  • Admin

    @ghostronin Yeah, imagine you are playing Russia's turn and have 1 unit in an adjacent territory blocking germany tanks from 2 territories away. You think you are safe but then on Italy's turn they attack that one unit to clear the path for Germany's tanks (known as a can opener). So when you checked max attackers, you thought the Russian were safe as they were before Italy went.



  • Ok, I understand and agree in reference to my highlighted units piece.

    However, I think that could potentially be resolved by my request in my original post. A click-add of enemy units within a territory. In the Italian/German/Russian example. The Russian defender could assume that Italy is going to use a "can-opener", then click-add the german units that could potentially blitz thru.

    IMHO the click-add combined with the hotkey function would be especially helpful. To your point, the battle calculator in any form is only a good as the person not only inputting but interpreting the information, GIGO.


  • Admin

    @ghostronin Exactly. I do agree with your original proposal. I think the key is giving players the tools to quickly and easily select the units they want to simulate battles for. Just being able to test a defense and click the adjacent enemy held land territories to select those as the attackers then you can manually add say enemy planes or multi-move land units would save a ton of time.


  • Admin

    So I'm reviving this thread as I've decided to embark on trying to make at least some fixes and improvements to the BC. This is mostly due to a number of the bugs really starting to bother me especially on more complex maps.

    So besides the original request around a way to add attackers/defenders to an already open BC, what else would folks like to see fixed/improved?


  • Admin

    @redrum I've always thought Copy/Paste buttons would be nice to have. A 'copy' button would save a set of units and enable a 'paste' button that would load those same units back. It's easy to launch two battle calc's, so it'd be a reasonably easy way to transfer data between the two. A next feature that would be nice is a side-bar that could save/manage a list of saved unit lists. For example it's pretty common to keep track of a specific stack, saving 2 or 3 stacks into the saved list could save a lot of redundancy.

    The simple click on another territory to load units I like. Getting a good UX there will be a bit tricky but could be very worthwhile. It would also be good to see a way to 'add' units and not just replace units as well. Thinking of a scenario where you want to sum up attackers from 2 or 3 territories.


  • Admin

    @LaFayette Good suggestions. I'd like to move towards a single battle calc window with tabs vs multiple windows. I think that will make a lot of things easier to manage and more clear what your 'active' tab is for adding units with hotkeys while keeping other calcs around. I'm already working on making sure it "adds" and not "replaces" units and that you can change to a different allied nation as the defender and it not clear the units.

    The unit lists idea is an interesting one as well and hadn't thought that far ahead yet.


  • Admin

    Initial PR for some of the changes is up: https://github.com/triplea-game/triplea/pull/4576


  • Admin

    Changes so far:

    • Added ability to use CTRL+A and CTRL+D to add attackers and defenders to last active battle calc window
    • Improved default player selection for attacker and defender when opening a new battle calc
    • Allow changing defending player in BC and if any of the current units are owned by the new defending player then units no longer reset
    • When switching players in BC, it only moves over the units of the new attacking player (not any allied units which can't actually attack)
    • BC considers isInfra units in unit counts and TUV (otherwise you could add combat isInfra units and it would appear they would always improve your TUV chance even if they were pretty much always being lost)
    • Can have 0 move and can't combat move units in BC attackers for maps which have limited combat rounds (this is because battles can last more than 1 round so these units can become attackers)
    • Changed action tab hotkey to 'C' and updated help menu
    • Defending units now create separate columns for each player
    • Scales appropriately based on unit list and number of defending players but also has a max window size slightly smaller than TripleA window

  • Admin

    Here are some examples of the updated BC.

    Global 40 Before
    0d00c57b-5678-4467-b8e0-6f35f14d9a3e-image.png

    Global 40 After
    21683464-727c-4b93-83b1-435b126963bb-image.png

    Dragon War - Using CTRL+D to Add Defenders
    f95583ac-3128-4911-8ff4-8712697e7003-image.png

    Dragon War - BC Includes IsInfra Unit Value in TUV
    0c482f88-7e57-4028-bf2e-0c3e3bd98d32-image.png


  • Admin

    @redrum Very nice improvements. 😃 Would it not be a good idea to add some sort of information and instructions about how to use these features? I could imagine a little help button some where in the window that opened a popup with all shortcut keys and what they did. Button could be a little icon like: alt text


  • Admin

    @Frostion Yeah, that's probably a good idea. I'd like to at least get the changes in the pre-release and have a few folks try it out then we can probably come up with some help text. I also added buttons for adding attackers/defenders in the territory tab under the battle calc one.


  • Moderators

    First advice first, I already made a number of times, is changing the name of the Battle Calculator/Odds Calculator to "Battle Simulator". It doesn't calculate your odds: it simulates battles a number of times and make statistics out of it.


    Probably not the best place to talk about this, as this is a problem rather than a feature request (unless FFA and such are not meant to be supported, which I assume it is not the case), but there is still that long standing problem (bug?) that the battlecalculator doesn't allow you to calculate against Allies.

    Obviously, this is tailored for all those games in which you have two sides committed against one another, that is true even in the case of diplomatically dynamic games like "WW2 Global" (where it can never happen a same other player switching from Allied to War with you, or vice versa), but it breaks down any games in which a player you are currently Allied with may be at War with you in the future, and you want to calculate now for any occurrences (the game may even allow to go directly from Allied to War, at the start of one's turn, so you would really want to calculate your defence, at least, there).

    This is a major problem for games allowing to go Allied to War (directly or indirectly) and vice versa and having player specific frontiers, while it is mostly just an annoyance for games in which all players have the same frontier, which is actually the case for almost all such games, as you can just calculate using one of the players you are not at war with, except that, if you are allied with everyone, the Battlecalculator breaks down completely.

    If you play "Napoleonic Empires: FFA 8 Player" and keep upgrading all relationships you can with France, getting always accepted, after the Politics of Round 3, if you try to open the Battlecalculator with France, you will get a warning:

    "No enemies or non-allies for :Playerld named:France

    And the following in the console:

    java.lang.IllegalStateException: No enemies or non-allies for :PlayerId named:France
    	at games.strategy.triplea.odds.calculator.OddsCalculatorPanel.getEnemy(OddsCalculatorPanel.java:655)
    	at games.strategy.triplea.odds.calculator.OddsCalculatorPanel.lambda$new$0(OddsCalculatorPanel.java:348)
    	at javax.swing.JComboBox.fireActionEvent(Unknown Source)
    	at javax.swing.JComboBox.setSelectedItem(Unknown Source)
    	at games.strategy.triplea.odds.calculator.OddsCalculatorPanel.<init>(OddsCalculatorPanel.java:449)
    	at games.strategy.triplea.odds.calculator.OddsCalculatorDialog.<init>(OddsCalculatorDialog.java:67)
    	at games.strategy.triplea.odds.calculator.OddsCalculatorDialog.show(OddsCalculatorDialog.java:35)
    	at games.strategy.triplea.ui.menubar.GameMenu.lambda$new$1(GameMenu.java:75)
    	at games.strategy.ui.SwingAction$1.actionPerformed(SwingAction.java:65)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.AbstractButton.doClick(Unknown Source)
    	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    	at java.awt.Component.processMouseEvent(Unknown Source)
    	at javax.swing.JComponent.processMouseEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$500(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    

    With this said, I think it has been a few years since I've seen anyone playing any Napoleonic Empires FFA, and that's the most popular (and arguably best) multi-sides politic game TripleA offers. And, on top of that, if, playing a wargame, you end up allied with everyone, there must be a problem with that game, but I can say this indeed happens when you play Napoleonic Empires FFA (I remember of people complaining they were unable to use the battlecalculator, because of this, after they got allied with everyone...).

    Aside from this, I believe the battlecalculator has a number of minor issues and marginal unsupported items. I'll see to try to recall them, if I can remember them all, and make a compilation here, if there is interest in making a general clean up for this utility.


  • Moderators

    Also, bugging myself off by trying to battlecalculate when everyone Allied crashed TripleA leaving it invisible. So I just had to open task manager to kill the process, or I couldn't delete that map's zip.