Announcement

Collapse
No announcement yet.

Combat Results Math...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Combat Results Math...

    Ok, I went to the trouble of looking up how Civ3's combat probability works (to the best of anyone's knowledge online) and then used my handy-dandy probability spreadsheet (which I have used for other games where probabilities of this sort are required) and worked out the actual chances of stuff.

    It turns out the the civulator created by a guy on CivFanatics (which I tested against my model) works exactly the same way and spits out the same result. By contrast, the equation Shriber was using is *not* accurate.

    The reality is that you have to use either Pascal's triangle as a data set for a series of fairly complex calculations (my formula for each cell in the spreadsheet is below) or you have to use a series of factorials and other stuff like that (which is what the "Civulator" uses), essentially the same calculation.

    First of all, the chance of the attacker winning any individual round of combat is the same as Civ1:

    a = attacker's modified attack rating
    d = defender's modified defense rating

    % = a/(a+d)

    To determine the result of an entire combat for two units with given hitpoints as well as modified attack/defense ratings is a hellishly complicated thing to do.

    Just to give you a glimpse of how I set up my spreadsheet, here's the fomula for individual cells (each cell representing the chance that a certain number of hits will be scored by the attacker in a given number of rounds):

    c = % chance of attacker winning a single round
    r = maximum # of possible rounds for this combat
    h = # of rounds won by attacker (of maximum # of rounds)
    k = appropriate number from Pascal's triangle

    % = [(c)^(h)]*[(1-c)^(r-h)]*k

    ------------

    To give you an example... I'll use the combat we were debating about during the turnchat earlier today...

    An Elite (5/5) Apolytonian Pikeman (1/3/1) attacks a Regular (3/3) Persian Archer (2/1/1) on a jungle tile. The jungle tile gives the Persian Archer a 25% bonus to defense, so its modified defense rating is 1.25, where the Apolytonian Pikeman's modified attack rating is 1, the same as its base attack rating.

    a = 1
    d = 1.25

    c = a/(a+d) = .4444 (rounding)
    c = .4444

    The value of r is defender's hp + attacker's hp - 1
    so r = (3)+(5)-1 = 7
    r = 7

    The values for h and k are determined case-by-case as we determine the chance for a specific number of attacker wins (h) -vs- the total number of possible rounds (r).

    In this case, we have 8 different cases to examine, one each for values of h from 0 through 7. Now, It is not possible for the attacker to even *make* anything more than 3 hits, but for purposes of determining the probability of a "win" for the attacker, 3+ hits are a "win" since the extra "hits" simply represent that the combat might have ended more quickly than maximum possible 7 rounds.

    Here's the calculation for each individual case:

    c = % chance of attacker winning a single round
    r = maximum # of possible rounds for this combat
    h = # of rounds won by attacker (of maximum # of rounds)
    k = appropriate number from Pascal's triangle

    % = [(c)^(h)]*[(1-c)^(r-h)]*k

    ****0/7 attacker wins (defender victory)****
    k = 1
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*1
    % = 1.63%

    ****1/7 attacker wins (defender victory)****
    k = 7
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*7
    % = 9.15%

    ****2/7 attacker wins (defender victory)****
    k = 21
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*21
    % = 21.96%

    ****3/7 attacker wins (attacker victory)****
    k = 35
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*35
    % = 29.27%

    ****4/7 attacker wins (attacker victory)****
    k = 35
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*35
    % = 23.41%

    ****5/7 attacker wins (attacker victory)****
    k = 21
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*21
    % = 11.24%

    ****6/7 attacker wins (attacker victory)****
    k = 7
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*7
    % = 3.00%

    ****7/7 attacker wins (attacker victory)****
    k = 1
    % = [(.4444%)^(0)]*[(1-.4444)^(7-0)]*1
    % = 0.34%

    Now, adding up the cases of defender victory and attacker victory seperately:

    attacker victory: 67.26%
    defender victory: 32.74%

    ----------------------------------

    Now, the good news is that you don't have to do all that math on your own . The civulator that someone on CivFanatics created actually does these calculations for you (though in a different way than I have) and just spits out the results of each of those cases (you still have to tally the cases of attacker victory -vs- defender victory yourself). My spreadsheet is much the same, but it's significantly less user friendly (I designed it for my own use...).

    The reason why Shriber's calculations didn't work was that his system for determining the victor of a full combat was too simple (he multiplied the modified attack rating by the attacker's hp and the modified defense rating by the defender's hp). The reality is that the multiple rounds of combat caused by having multiple hitpoints make the situation many times more complex.

    I strongly suggest that at least one person who will be around for turnchats go take a visit to CivFanatics or somewhere else to pick up a copy of the Civulator spreadsheet (I think OPD apparently already has one). Conversely, if I'm around, I'll just use my spreadsheet (I like mine better, though it spits out the exact same results :-) ).

    That's all for now. Sorry for the obsessively long post with all the mathy stuff...
    Long-time poster on Apolyton and WePlayCiv
    Consul of Apolyton from the 1st Civ3 Inter-Site Democracy Game (ISDG)
    7th President of Apolyton in the 1st Civ3 Democracy Game

  • #2
    It's great, Arnelos. Useful spreadsheet!
    Btw, some of us like Mathy stuff...
    RIAA sucks
    The Optimistas
    I'm a political cartoonist

    Comment


    • #3
      as long as integration by parts is involved....
      :-p

      Comment


      • #4
        What, no separation of variables? Dirac delta functions? Hilbert spaces?

        NO FOURIER SERIES?!?!?!

        Very interesting, though. I have read and at one time downloaded the Combat Calculator, but somehow you make it seem so much less boring to read, Arnelos.

        Excellent thread.
        Consul.

        Back to the ROOTS of addiction. My first missed poll!

        Comment


        • #5
          I have the impression that, during a fight, if you start losing individual rounds of battle, the probability of losing the next is higher (put in other words: the battle victories are clustered somehow).

          Anyone can confirm this observation?
          Greatest moments in cat:
          __________________
          "Miaooow..!"

          Comment


          • #6
            I confirm this impression, but I believe it is only an impression (psychology : Ah ! bad start ...).

            Others impressions :
            - a unit alone loose frequently battles against weaker units.
            - elite units behave worse than veteran units.
            But that is certainly due to psychology : we forget the percent of possible loss, and we expect too much of elite.
            Statistical anomaly.
            The only thing necessary for the triumph of evil is for good men to do nothing.

            Comment


            • #7
              Bah, I figured all along that my equation is inaccurate and I knew why, I just didn't know how to factor those elements of combat in. I'm still as far advanced as highschool math.
              Anyway, thanks for providing us with a much more accurate system to predict combat results!
              "Close your eyes, for your eyes will only tell the truth,
              And the truth isn't what you want to see,
              Close your eyes, and let music set you free..."
              - Phantom of the Opera

              Comment


              • #8
                Originally posted by BigFurryMonster
                I have the impression that, during a fight, if you start losing individual rounds of battle, the probability of losing the next is higher (put in other words: the battle victories are clustered somehow).

                Anyone can confirm this observation?
                it does seem like that, but it isnt true. neither is the 'hot hands' myth in basketball.

                Comment


                • #9
                  Actually, I understand that some long-abandoned algorithms for generating random numbers did often spit out clusters of close numbers, but that's not what Civ III uses.
                  AFAIK Civ III's battles are fed by Windows' randomizer, which gives fairly spread results.
                  "Close your eyes, for your eyes will only tell the truth,
                  And the truth isn't what you want to see,
                  Close your eyes, and let music set you free..."
                  - Phantom of the Opera

                  Comment


                  • #10
                    Originally posted by MrWhereItsAt
                    What, no separation of variables? Dirac delta functions? Hilbert spaces?

                    NO FOURIER SERIES?!?!?!

                    Very interesting, though. I have read and at one time downloaded the Combat Calculator, but somehow you make it seem so much less boring to read, Arnelos.

                    Excellent thread.
                    Well, you are using Fourier series (not exactly you, but the numeric processor of your computer... ). Unfortunately, no complex variables. Some topology, maybe.
                    About Dirac... try some impulse functions... One integral here, another there...
                    Are you complaining about Hilbert? What about Riemann?

                    Here’s a little poem about my beloved zeta function:
                    Where are the zeros of zeta of s?
                    G.F.B. Riemann has made a good guess;
                    They're all on the critical line, saith he,
                    And their density's one over 2 pi log t.
                    This statement of Riemann's has been like a trigger,
                    And many good men, with vim and with vigour,
                    Have attempted to find, with mathematical rigour,
                    What happens to zeta as mod t gets bigger.
                    The efforts of Landau and Bohr and Cramer,
                    Littlewood, Hardy and Titchmarsh are there,
                    In spite of their effort and skill and finesse,
                    In locating the zeros there's been little success.
                    In 1914 G.H. Hardy did find,
                    An infinite number do lay on the line,
                    His theorem, however, won't rule out the case,
                    There might be a zero at some other place.
                    Oh, where are the zeros of zeta of s?
                    We must know exactly, we cannot just guess.
                    In order to strengthen the prime number theorem,
                    The integral's contour must never go near 'em.
                    Let P be the function  minus Li,
                    The order of P is not known for x high,
                    If square root of x times log x we could show,
                    Then Riemann's conjecture would surely be so.
                    Related to this is another enigma,
                    Concerning the Lindelöf function mu sigma.
                    Which measures the growth in the critical strip,
                    On the number of zeros it gives us a grip.
                    But nobody knows how this function behaves,
                    Convexity tells us it can have no waves,
                    Lindelöf said that the shape of its graph,
                    Is constant when sigma is more than one-half.
                    There's a moral to draw from this sad tale of woe,
                    which every young genius among you should know:
                    If you tackle a problem and seem to get stuck,
                    Use R.M.T., and you'll have better luck.


                    Words by Tom Apostol (revised cph


                    They don't do math nowadays like they did yesterday...
                    Note: Math could be extremely literary…
                    Btw, excellent thread.
                    Note 2: Delicious nonsense....
                    Note 3: Tech spam is fun!
                    RIAA sucks
                    The Optimistas
                    I'm a political cartoonist

                    Comment


                    • #11
                      Originally posted by BigFurryMonster
                      I have the impression that, during a fight, if you start losing individual rounds of battle, the probability of losing the next is higher (put in other words: the battle victories are clustered somehow).

                      Anyone can confirm this observation?

                      It's just an impression, BFM. However, this is the fun about statistics: one result don't depends of the other...
                      RIAA sucks
                      The Optimistas
                      I'm a political cartoonist

                      Comment


                      • #12
                        Yes. Unless the random generator is somehow 'biased' towards clustered outcomes. In Computer Science, a lot of discussion has been going on on the 'randomness' of random generators.
                        Greatest moments in cat:
                        __________________
                        "Miaooow..!"

                        Comment


                        • #13
                          I don't really believe in an unbiased Universe. God not only plays dices with the universe, He cheats! See how the quantum mechanics works...
                          RIAA sucks
                          The Optimistas
                          I'm a political cartoonist

                          Comment


                          • #14
                            I have to wonder about that as well.

                            I think some defenders of cities are granted unholy strength (or maybe that would be holy, I dunno, I'm the attacker).

                            I have lost so many tanks / modern armors to fighting a single city with a rifleman before, it just isn't funny. I'll be sweeping a nation, getting every city every time in the first shot, then I'll get to one city, and it will take ten tanks to bring it down even though their defense is no better.


                            Is this a bug in the game, or am I fighting william wallace?

                            Comment


                            • #15
                              Originally posted by Epistax
                              I have to wonder about that as well.

                              I think some defenders of cities are granted unholy strength (or maybe that would be holy, I dunno, I'm the attacker).

                              I have lost so many tanks / modern armors to fighting a single city with a rifleman before, it just isn't funny. I'll be sweeping a nation, getting every city every time in the first shot, then I'll get to one city, and it will take ten tanks to bring it down even though their defense is no better.


                              Is this a bug in the game, or am I fighting william wallace?
                              I don't hear anyone complaining when its their William Wallace.

                              Comment

                              Working...
                              X