TripleA Logo TripleA Forum
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags
    • Register
    • Login

    Unit-strength function

    Scheduled Pinned Locked Moved Feature Requests & Ideas
    31 Posts 8 Posters 8.9k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CrazyGC Offline
      CrazyG Moderators
      last edited by

      In actual game play, the Army A defeats Army B, and B defeats C, but A loses to C is virtually unheard of, so I wouldn't focus on this. It basically only happens if there are huge mismatches of power and fodder. A good player would be actively building to avoid this situation.

      There isn't a great mystery on how to predict battle outcomes, especially if you are doing low luck only. Probability trees do it, most battles don't see more than 4 or 5 rounds of combat so they aren't difficult to use.

      A few extremely common battles have been done out with a probability tree on the axis and allies forums (dice and low luck).

      1 Reply Last reply Reply Quote 1
      • alkexrA Offline
        alkexr @VictorIn_Pacific
        last edited by

        @VictorIn_Pacific The solution to the linear equations when all units have the same power gives the remarkably simple and elegant solution of sqrt(A^2 - B^2) for the expected number of units surviving, where A is the total initial strength of the stronger side, B is that of the weaker one. Despite being a continuous approximation, it seems to have an error margin of only around 5% for larger stacks (relative to A), and is invariably an upper estimate. This result is absolutely anticlimactic, by the way.

        "For the world is changing: I feel it in the water, I feel it in the earth, and I smell it in the air."

        1 Reply Last reply Reply Quote 0
        • RoiEXR Offline
          RoiEX Admin
          last edited by

          @prastle Not sure about the downvotes. I can see them No Problem. (On a phone btw)

          About the topic: Not an expert on maths, but I don't think there's a way to calculate some sort of strength of an army without knowing the opponents, there are just too many factors involved.
          Because of this the hard AI at least simply uses the BattleCalculator to determine whether or not it's a good idea to attack a certain territory.
          Also the reason the AI is relatively CPU-Heavy.

          1 Reply Last reply Reply Quote 0
          • Captain CrunchC Offline
            Captain Crunch Banned
            last edited by Captain Crunch

            I'm still trying to figure out whether he's opened up a can of worms or not yet (I'm guessing no because CrazyG said this doesn't involve the game engine)

            this thread is typically why I still read this forum though ... math, ai , strategy etc. etc! so interesting!

            1 Reply Last reply Reply Quote 0
            • redrumR Offline
              redrum Admin
              last edited by redrum

              So to add to this, even if you came up with some function that could handle strength and HP to say 99% of the time. Most of the newer maps actually have things like targeted rolls, multi-HP units, positive/negative support, suicide units, etc. These make things much more complex to the point that its very difficult to even find the optimal casualties to select each round let alone have some function of the armies strength that predicts the winner. They also make it so A > B > C > A will always exist because I can have an AT gun army, a tank army, and an infantry army which form counters to each other with targeted attacks (AA like rolls).

              Given all that, this is why the battle calc is very important and that we generally just use a strength estimate of 2*HP+power to give a very high level estimate of army strength as that is a fairly good yet simple formula.

              The biggest issue with the A&A combat system tends to be that 1 or 2 additional units changes a battle from 50/50 to 95% win chance (especially true for LL). The ways to address this drawback is:

              • Have more of a ranged suicide unit type map where armies are mostly firing units at each other rather than entire stack vs stack
              • Have limited combat rounds so that you can only inflict so many casualties per turn to avoid the first round of battle deciding the fate of the entire stack of units. This allows more tactics around retreating, counterattacking, reinforcing, etc.

              TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

              1 Reply Last reply Reply Quote 2
              • CrazyGC Offline
                CrazyG Moderators
                last edited by

                2*HP + power was something I used before (when playing on a board game, when you have to do all the math on your own!)
                Even then, you really need to factor what units die, if one side is losing more power than the other (a, its a big deal. Occasionally on World War 2 Revised, Germany attacking Russia looks like an even fight, but its heavily German favored (Germany loses low value 1 attack units, while Russia is losing 2 defense units).

                If you want another interesting case, look at TWW. Its not uncommon for a heavily fortified Russian city to have fewer hitpoints and lower defense than an attacking German army, but still win the battle 90 to 100% of the time., due to a combination of targeted attacks and 'Skewness'. Even without targeted attacks, less complex abilities such as units supporting each other or having two hitpoints make a big difference.

                1 Reply Last reply Reply Quote 0
                • V Offline
                  VictorIn_Pacific
                  last edited by VictorIn_Pacific

                  A lot of good points above. I have incorporated as much of that as possible in my next post. Riders: this applies to the basic combat system, LL. The following may be old hat, or not.

                  How many knives should you bring to a gunfight? Obviously, if your army has exactly the same characteristics as the enemy army, then they have the same combat power. But in general, having more weaker units can compensate for a deficit of stronger units, and vice-versa.

                  The old hands know that there is an Army Power Function 2*U+C that works quite well, where U is the number of hit points and C is the total combat strength. Of course, this must be an approximation, because the combat strength is applied in each combat round, while the hit points count only once, so there must be at least one more factor in the function. However, if the combat lasts 3 rounds or less, then you should be able to calculate the result exactly, while hardly any combat lasts longer than, say, 6 rounds. The function may be analytical (based on analysis) or empirical (based on observations), but it turns out that it is exactly equal to a good, simple analytical function, up to a scaling factor, provided that there are 6 rounds of combat.

                  Initial considerations indicate that we should look for an Army Power Function that has the form
                  P = P(U,C,N) ,
                  where U is the number of hit points, C is the total combat strength, and N is the number of rounds of combat. We try
                  P = U + N*(f*C/6) ,
                  noting that it takes a combat strength of 6 to inflict each hit point.

                  N = U'/(f*C/6), where U' is the number of units in the enemy army, and f is a factor to be determined.

                  It quickly becomes apparent that there are unexpected and undesirable features to this trial function. According to this function, the power of your army increases when attacking stronger armies, because the number of rounds of combat increases! Indeed, the power is equal to the total number of units in both armies! In general, the Army Power Function depends on the exact nature of the enemy army. Therefore, we abandon the attempt to find a general function that calculates the power of an army, and instead seek only a function that calculates the power of an army at balance, that is, when your army is as good as the enemy army. Having that, then we can add a couple of units or make a couple of units stronger, because it is known from experience that that increases the probability of winning a battle from 50% to about 95%. (That applies to Low Luck conditions.)

                  It should be clear that the factor f cannot be unity, because the total combat strength of an army drops each round, unless it is padded with 0-strength units. The rate at which the combat strength drops is nonlinear, because the rate at which the enemy army inflicts casualties decreases each round, unless it is padded.

                  In order to keep the solution simple but general, we linearize the problem by assuming that the combat strength of each army at balance drops linearly from its maximum value to zero. The expression f*C is equal to the average combat strength of the army, and for this linear decrease, it is equal to half the maximum strength. Thus f = 1/2.

                  The practical problem at hand is what we need to have in order to equal a specific army, i.e. how many knives do we need to bring to this gunfight. Thus in general, U' and C' will be known, and the average combat strength of your units C/U will be roughly known, so the problem reduces to determining U.
                  N = U'/(C/12) = U/(C'/12) , so
                  U/U' = C'/C = (U'C'/U')/(UC/U) , so
                  (U/U')^2 = (C'/U')/(C/U) , so
                  U/U' = SQRT(c'/c) ,
                  where c and c' are the average unit strengths of the respective armies.

                  Let's look at one example to see how this works. The enemy has 10x4. How many 1s do you need to equal this? U/U' = SQRT(4/1) = 2 . Bring 20 units for balance, and 2 more for the win. The power of these armies is P = U + U' = 30.

                  The number of combat rounds is N = 12x10/20 = 12x20/40 = 6. This is an approximation. Direct calculation shows that each army kills exactly 1/3 of the opposing army in the first combat round and 2/3 of that in the second combat round, for a total of 5/9 in the first 2 rounds. Thus 10 units are reduced to 4.4 in 2 rounds and 2 in 4 rounds and .9 in 6 rounds, so the true number of rounds is about 8.

                  The army power can also be expressed as P = U + 6xC/12 = (2*U + C)/2 , which is the same as the legacy function, except for the constant scaling factor. Although the legacy function is less accurate, it is easier to use, and does not involve fractions.

                  Let's see how well the legacy function predicts the number of units you need for balance. The legacy function has 2U+C = 2U'+C' , so U*(2+c) = U'*(2+c') , so U/U' = (2+c')/(2+c) . The reader can verify that, for the smallest quality mismatch c=c', U=U' for both functions. Also, for the largest likely mismatch c=1 and c'=4, U/U' = 2 for both functions. For some other cases such as c=1.5 and c'=3, the results are almost identical. Otherwise, the legacy function gives a slightly inaccurate result.

                  Captain CrunchC CrazyGC 2 Replies Last reply Reply Quote 0
                  • Captain CrunchC Offline
                    Captain Crunch Banned @VictorIn_Pacific
                    last edited by Captain Crunch

                    @VictorIn_Pacific alright good stuff but I will wait for more replies to see if anyone thinks your newer equation is a better function for predicting battle outcomes!

                    Funny also, this reminds me of when I was in highschool I drew a chart showing a man 6 feet tall who could jump 3 feet high and next to him was a man 12 feet tall who could jump 6 feet high and I drew a line straight from the 6 foot tall guys head directly to the 12 foot guys head and I said "a guy twice the height of another person will have twice that person's ability to jump" ... and my smarter friends told me my chart was impossible BECAUSE OF GRAVITY ...

                    so my point is math and physics can be peculiar and so I'm expecting some "unknown factor" to not allow Victorin_Pacific to achieve his objective but again I will wait for more responses!

                    1 Reply Last reply Reply Quote 0
                    • CrazyGC Offline
                      CrazyG Moderators @VictorIn_Pacific
                      last edited by CrazyG

                      @VictorIn_Pacific said in Unit-strength function:

                      seek only a function that calculates the power of an army at balance, that is, when your army is as good as the enemy army

                      I don't quite understand what you are saying. My goal is to calculate army power, but I can only calculate if my opponents army is about equal to my army. Don't I need to be able to calculate army power in order to do affirm if the two armies balanced?

                      Also, the number of combat rounds would be a function of my power, enemy power, my HP, and enemy HP. So you should be able to build a function that just calls those four instead of adding a new variable.

                      As a teacher, I'm interested in seeing if something can be done, but I'm not optimistic to be honest.

                      1 Reply Last reply Reply Quote 0
                      • Captain CrunchC Offline
                        Captain Crunch Banned
                        last edited by

                        this topic is just another example where I find it interesting the difference between "mathematics" and its counterpart "applied mathematics"

                        1 Reply Last reply Reply Quote 1

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post
                        Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums