[Vanilla] Hans Lemurson figures out the Combat Formula

Hans Lemurson

Prince
Joined
Jan 2, 2006
Messages
491
Location
Silicon Valley
So, I've been searching a while to see if anybody had figured out the Civ6 combat formula and, finding nothing, I took it upon myself to have fun with spreadsheets so you don't have to.

I have long suspected that the damage formula was Exponential in nature, given that the relative Power of units is based on their difference in strength rather than the ratio. But to actually test this I needed to gather a LOT of combat data from various unit-strength pairings in order get a large enough data set to yield believable answers. I would need to record the data from each and every combat in my game, minimizing after every battle so I could enter the data in a spreadsheet before I forgot what the message said. And do that 100 times. BOOORING!!!!.

Say hello to my little friend here: Documents/My Games/Sid Meier's Civilization VI/Logs/CombatLog.csv

And with that, I was off to the races.
A little bit of spreadsheet manipulation and...

Yep, looks exponential to me.

Also noteworthy is the fairly large variance, but also that it appears to be directly proportional to the amount of damage dealt, flaring out like a trumpet as the damage increases. This suggests that there is a simple random multiplier to the final damage. Judging by eyeball, the upper limit seems to be 125% and the lower limit 75%.

I tried to use clean and easy to understand numbers, and I arrived at this approximate formula for what each unit does to each other in combat:

Damage = 30 * e^(StrengthDifference / 25) * Random(0.75, 1.25)

The base damage is 30, doubles every ~17 strength, and then gets a +/-(0-25)% damage bonus/penalty.
The random factor is applied to each unit independently.

I might be wrong about the magnitude of the Random Factor, and may not have gotten the exponent exactly right (and I wish I could have converted it into more intuitive numbers), but this is probably close enough to get a picture of what's going on.

For the purposes of "rules of thumb" I will make a chart for the expected damage at various intervals.
Code:
 +0  30  30   1.00x
 +1  31  29   1.04x
 +3  34  27   1.13x
 +5  36  25   1.22x
+10  45  20   1.49x
+17  59  15   1.97x
+30  99  10   3.32x
From these bonuses, we can see what we already knew: Combat strength differences are only relevant from 0-30, after that it's all 1-hit kills.
+10 is a good solid bonus where you deal 150% damage and take only 67%.

An easier to use formula might be: 30 * 1.041^StrengthDifference
(since only nerds like me know that e = 2.71828)

I have added the CombatLog.csv file that I used as my source of data.
 

Attachments

  • CombatLog.zip
    2.4 KB · Views: 677
Last edited:
Thanks for this. I wanted to give a try at that myself but I didn't know how to collect enough data.
 
Nice work. My combat log only shows religious units for some reason.
CombatLog.csv seems to just contain the last 128 combats that occurred (fought by anyone), so if there was a religious conflict anywhere in the world, that could certainly fill it up.
Thanks for this. I wanted to give a try at that myself but I didn't know how to collect enough data.
Yeah, if I hadn't found the combat log, there's no way in heck I would have done this. It's not too hard to analyze the data on a spreadsheet, you just gotta do a little math and prune all the 100 damage combats, because those will skew your results since they are clipped off from their true value.

If anybody wants to double-check my results to make sure I didn't make some stupid error, feel free!
Alternately, if anybody figures out a good simple way to phrase the exponential formula that even an idiot can understand, that would also be great.

The best I can come up with is +10 Strength = 150% damage and resistance.
 
Great! Would you mind uploading your version of CombatLog.csv so that I can play with your data too? I turtled for a Science victory last game and hardly fought at all.
 
Great! Would you mind uploading your version of CombatLog.csv so that I can play with your data too? I turtled for a Science victory last game and hardly fought at all.
Even your CombatLog file should contain a variety of combats from Apostle fights to AIs fighting barbarians. However, there's no reason not to make my data public, so I added the file to my original post.

It is not coinciedence that corps add +10 and armies +17 combat strength. That translates well to +50% and +100% damage bonus.
Yes, I'd been expecting that something strange like +17 would turn into a simple multiple.

With an Army dealing 2x damage and receiving 1/2 damage (compared to its base unit), this means that has 4x the combat power, and so it would take 4 normal units to kill it! In a 4v1 fight the army would probably die due to flanking bonuses and the accumulated damage penalty, but it would be a close fight. It would kill 3/4 of them and could definitely win a 3v1 fight. Talk about cost effective!!!
 
Even your CombatLog file should contain a variety of combats from Apostle fights to AIs fighting barbarians. However, there's no reason not to make my data public, so I added the file to my original post.


Yes, I'd been expecting that something strange like +17 would turn into a simple multiple.

With an Army dealing 2x damage and receiving 1/2 damage (compared to its base unit), this means that has 4x the combat power, and so it would take 4 normal units to kill it! In a 4v1 fight the army would probably die due to flanking bonuses and the accumulated damage penalty, but it would be a close fight. It would kill 3/4 of them and could definitely win a 3v1 fight. Talk about cost effective!!!
Shh...
We don't want people to figure out that war academies are OP.
That's our secret. :goodjob:
 
Shh...
We don't want people to figure out that war academies are OP.
That's our secret. :goodjob:
Hehe.

At a minimum, this understanding of the Combat Formula goes a long way towards justifying the massive ramp-up in cost for units as you go through the eras.
 
I am confused.. I do not play domination so am no expert so excuse my ignorance but hopefully you can appreciate that challenging a theory is important.

First off the +50% and +100% are vert strong arguments.

I am interested in the .csv as it is the empirical way to validate it. The one attached seems to have no AttackerDmg DefenderDmg data. EDIT: Oh OK the columns horsehocky 2 to the right.

Off to check .csv file! and if I can fight a 2 player MP and control what is in the file.
 
Last edited:
Math and Civ, two great tastes that taste great together!

Thanks for all the work, especially the +10 and +17 summaries.
 
Thanks, Hans Lemurson for the combat formula and supporting data. Extremely well done analysis!
 
I am confused.. I do not play domination so am no expert so excuse my ignorance but hopefully you can appreciate that challenging a theory is important.

First off the +50% and +100% are vert strong arguments.

I am interested in the .csv as it is the empirical way to validate it. The one attached seems to have no AttackerDmg DefenderDmg data. EDIT: Oh OK the columns **** 2 to the right.

Off to check .csv file! and if I can fight a 2 player MP and control what is in the file.
Yeah, the shifted headings threw me for a bit when I first tried to tackle the data, but you can figure out which number are which based on their behaviors and distribution.

Yup I just ran through for a while and saved 3 CSV's when I have been viotent and checked for player 0 and they are all fine and within your ranges on all 3. So if your formula is not right, it seems close. Have not tried all the way to modern day though
Yeah, I'm pretty sure my equation is at least 98% correct. Equations in programs are almost always based on simple numbers, but you can never be totally sure.

Math and Civ, two great tastes that taste great together!

Thanks for all the work, especially the +10 and +17 summaries.
Yeah, until I ran the numbers and saw that +17 meant 2x, the number for armies made no sense at all.

Thanks, Hans Lemurson for the combat formula and supporting data. Extremely well done analysis!
I do like analyzing games, and I saw that nobody had done this yet, so why not try to milk it for all the self-aggrandizing glory I can get?

Excellent, adding to Formula Thread
I wish I could have found a more intuitive way of stating it than e^x, since nobod- um, most people, don't have e memorized.

30 * 2^(StrengthDiff/17) is another valid representation, as is
30 * 10^(StrengthDiff/58) and
30 * 1.041^(StrengthDiff)
 
I'd think that quite a few people that care about the damage formula would have e memorized... Anyway, maybe using exp(x) would help (since it's the Excel function for exponential).
 
I'd think that quite a few people that care about the damage formula would have e memorized... Anyway, maybe using exp(x) would help (since it's the Excel function for exponential).
It's not so much the calculation itself being hard to do as it is that it can be hard to get an intuitive sense for the numbers when they aren't simple integers. I myself have little sense for what the 1.08x damage of +2 strength actually means. "Double" or even "1.5x" on the other hand are much clearer. I wish I could find clear numbers for the whole formula and its results.
 
I am not sure many people are going to calculate that formula each combat. To me the thing I will remember are

Armies, corps, fleets and armadas are very strong and very worth the investment
The difference makes the difference and autokills at 30 everytime.
I do like analyzing games, and I saw that nobody had done this yet, so why not try to milk it for all the self-aggrandizing glory I can get?

Hans Lemurson is da man, milk it, you deserve it
 
if anybody figures out a good simple way to phrase the exponential formula that even an idiot can understand, that would also be great.
Trying to square the circle aren't you?:p
If you really want something easy to understand for whoever have no mathematical background you probably need to drop your formula completely and go for something visual.
DamageGraph_400.png

Graph edited to include suggestion from icon41gimp
OK, i took my own combat log and plotted the results. Here's what i have (roughly what you have)

Unit vs Unit Both attacker and defender damage considered for a total of 748 samples after removing 100 and 0 damage (attacker always takes 0 when it's a ranged unit)
UnitVsUnit.png


District vs Unit (unit bombarded by City Center or Encampment with walls) Obviously only defender damage is used (126 samples)
DistrictVsUnit.png


Unit vs District. I used only the damage dealt by the unit to the district and removed the 200 damage (cap for max city wall). Only 79 samples unfortunately.
UnitVsDistrict.png


So both for unit vs unit and district vs unit i get very similar results. For unit vs district however, my results differ a lot but the distribution doesn't even show a clear exponential curve, i just fitted an exponential curve because it's what we have for normal combat. It's possible that the formula used to damage cities is different. Interestingly, the fitted curve has 15 baseline damage, half the normal baseline for unit vs unit, so it might be good despite the low number of samples.

EDIT. Just to let you know the log doesn't really tell you a district is under attack but there is a value set to either 1 or 3 to identify the object type of the attacker and defender. "AttackerObjType" 3 is clearly identified as a district (city center or encampment) while "DefenderObjType" 3 is "UNKNOWN" but given that city walls can grow to 200 and i see some 200 damage when defender is 3 i guess they used the same numeric identifier for defender and attacker and "DefenderObjType" 3 means a district (city center or encampment) was under attack at that time.
 
Last edited:
It's possible that the formula used to damage cities is different.

Not knowing the unit attacking does not help...and if it attacking walls or city?
It also looks like there is not enough samples in that one and you need to combing a few .csv's.
On the right track and very impressed as a non mathematician myself
 
Top Bottom