View Full Version : Combat Explained....


Pages : [1] 2

Arathorn
Nov 04, 2005, 03:22 PM
Ahh…fighting. Love it or hate it, there will be times it’s part of your Civ-ing career. This article attempts to explain a bit about how combat is figured, discusses some “jump points” where your odds of success change dramatically with a very small change in strength, discuss some odd ways that particular bonuses are calculated, and hopefully generally serve to enlighten you in terms of combat.

Thanks for this article in part to BomberEscort and snepp for their work in another thread http://forums.civfanatics.com/showthread.php?t=137350. Some credit also due to http://apolyton.net/forums/showthread.php?s=&threadid=140622 for descriptions (even though some are terribly wrong).

The basics

You don't even really need to understand this. You can get this by alt-mouseover or by right-click and dragging to the unit and checking the odds displayed in the lower left corner of the screen. This explains how those numbers are calculated.

Attacker’s modified strength

This is calculated first. Apply any bonuses the attacker gets independent of the defender (generic strength promotions only in the default game). Multiply this total by the unit’s hps/100. This gives the attacker’s modified strength.

Example: A swordsman with Combat I, City Raider I, and only 73 hps is lining up to attack a city. His modified strength is 6 * 1.1 (from Combat I) * 73/100 (from hps) = 4.82 (well, 4.818 actually, but I don’t know if Civ4 keeps more than 2 digits of accuracy).

Defender’s modified strength

This one is more complicated. Determine the defender’s bonuses from terrain, general strength bonuses, bonuses vs. the type of the attacking unit, fortification bonuses, etc. Sum those up. Now, subtract any bonuses the attacker might have if it attacks this unit. Those would include attacker bonuses against defender combat type, attacker bonuses against a city, attacker bonuses in the terrain type (?). If the overall value is positive, add that percentage to the defender to get its modified strength. If the overall value is negative, the defender’s modified strength is found by taking the original defender’s strength divided by (1-overall_value). [Note: That’s the same as dividing by (1+abs(overall_value)) when overall_value is negative, which is how I think of it.]

Once this value is calculated, the defender’s hps become an issue. This is again a straight multiplication by the number of hps remaining times the modified strength found above.

Example #1: (Both healthy) An archer (str:3) with City Raider I and Combat I promotions is attacking a warrior (str:2) on grassland. The attacker’s modified strength is calculated by simply taking the combat I promotion and getting a value of 3.3 (3 + 3*.1). The defender has no strength bonuses and the grassland defense bonus is 0, so the defender has a modified strength of 2.

Example #2: (Both healthy) A knight (str:10) with Combat I and Cover (+25% vs. archers) promotions is attacking a longbow (str:6) in a forest. The attacker’s modified strength is again simple, using the Combat I promotion of 10%. The knight’s attack value is 11 (10 + .1*10). The longbow has an initial bonus of +50% for the forest. However, the knight’s Cover bonus now affects the defending longbow, giving it a -25%, too. So, the overall bonus for the longbow is +25%. The defender’s modified strength is 7.5 (6 + .25*6).

Example #3: A knight (str:10) with Combat I, Combat II, and City Raider I (+20% attacking a city) but only 73 hps is attacking an axeman (str:5) in a town with a 3% defensive bonus from culture. The attacker’s modified strength is 8.76 (10 + .2*10)*76/100 from the two Combat promotions and the hps. The defender first calculates a +3% defensive strength from the city. Then the attacker’s bonus is kicked in. This gives a -20% to the defender. Thus, the overall value is -17%. The defender’s modified strength is 4.27 (5 / (1+.17) = 5 / 1.17)).

The actual combat

We now have the attacker and the defender’s modified strengths. We will call these A and D going forward to help the discussion. If a bit of algebra scares you, just jump ahead to repercussions....

Round odds

The odds that the attacker will win each round is given by A/(A+D), so the odds the defender wins a round is D/(A+D).

I’m now going to introduce a new variable – the ratio between the attacker’s and defender’s modified strength. This value is R. It is A/D and it controls all of combat. The greater R is, the better the attacker’s odds of winning.

Each round, the attacker wins with odds R/(1+R) and the defender with odds 1/(R+1).

Damage per hit

The attacker and defender both start with their current number of hps (NOT 100 as was previously stated). The attacker’s damage is given by floor(20*(3*A+D)/(3*D+A)). That is, you calculate the value and drop any fractional remainder. The defender’s damage is given by floor(20*(3*D+A)/(3*A+D)).

Going back to R notation, the attacker does floor(20*(3*R+1)/(3+R)) damage and the defender does floor(20*(3+R)/(3*R+1)) damage.

The maximum damage one size can do is 60 per hit. The minimum that can be done is 6. Only those values are possible, regardless of the relative strengths of the units.

Once one side goes below 0 hps remaining, it is destroyed (or retreats). The winner has strength remaining equal to starting_strength*hps/100, but it has fewer hps, so it is more likely to die in further combat. Modified strength no longer matters.

Exact odds can be found at http://c4combat.narod.ru/c4c.htm [Note: Updated to include hps -- thanks, Ellestar.]

First Strike

First strike round(s) are special. The number of them is determined by looking at the number of first strike rounds of the attacker and the defender. Whichever number is greater gets the difference of values in first strike opportunities. For x-y first strikes (possible first strikes), the math is still unproven, but it looks like a 50% likelihood of getting a first strike each "round" possible.

A first strike round is like any other round, except that the first striker is the only one who can do damage. For example, if the attacker has two first strikes and the defender zero, the first two rounds have two possibilities – the attacker wins so the defender loses damage or the defender “wins” and nobody gets hurt. The odds in this round are just like any other. The first striker is just immune to damage.

Retreat

Retreat rolls happen when a round ends that would kill the attacker. In that case, a special role is made against the attacker’s retreat chance. If successful, the attacker retreats with the number of hps he had before that final, potentially killing round. The attacker’s chance of winning combat is never decreased by having retreat chances. They only come into play when the attacker would die.

Retreat has a few points. First, any attacker with an X% chance of retreating will always have a strictly greater than X% chance of surviving a combat. He could win (greater than 0), retreat (x*die_percent), or die. The second is that retreat can only occur for the attacker, not the defender. Third, retreat is most valuable when the attacker is less strong than the defender – a catapult attacking a city, for example.

Example: A catapult (str:5) is attacking an archer(str:3) fortified in a city. The archer has +50% defense bonus for the city and 25% fortification bonus. The catapult has a 20% retreat chance (one Promotion). Attacker’s modified strength is 5. Defender’s modified strength is 5.25. Without retreat, the catapult would win 34.7% of the time and die the other 65.3% of the time. With retreat, the odds of winning are still 34.7%, but 20% of that 65.3% is retreat (.2*.653). So, win 34.7%, retreat 13.1%, and die 52.2% (.8*.653) of the time.

Collateral Damage

When attacking stacks, siege units have the built-in capability to damage additional units in the stack besides the one attacked. This is called collateral damage.

Collateral damage is done ONLY by an attacker and only to the stack member(s) that aren’t directly defending. The chosen defender will engage the attacking unit in a regular combat.

Maximum Damage

Gone are the Civ3 days of completely red-lining a unit. Each unit that can do collateral damage has a limit on the amount of damage it can do. These are given in the Units XML file. For catapults, it is 50; cannons 60; artillery 70. Tanks/panzers and modern armor are capped at 60; Cho-Ko-Nu at 60, and (stealth) bombers at 50. That means a catapult can not damage a unit at or below 50 hps. Similarly, an artillery cannot damage any unit at or below 30 hps. Those are hard caps.

Number of Targets

The number of targets is a function of both the attacking unit and the number of potential targets. The number of potential targets is the number of units in the tile which are not defending and who are above the maximum damage threshold.

Example: A catapult is attacking a stack a stack with a 100 hp musket, a 95 hp musket, a 42 hp knight, and a 73 hp axe. The number of potential targets is 2 – the 95 hp musket and the 73 hp axe. The 100 hp musket will defend, so is not a collateral target. The 42 hp knight is below the maximum damage for a catapult.

Each type of unit capable of doing collateral damage is limited in the number of targets it can hit, too. A catapult can only hit 5, a cannon 6, an artillery 7, Cho-Ko-Nu 5, a tank/panzer 5, a modern armor 6, a bomber 5, and a stealth bomber 6. So, even targeting a stack of 12 muskets, a cannon will only hit 7 total (1 directly which defends and 6 with collateral damage).

The number of targets, then, is the lesser of the two numbers – min(potential_targets,max_capable).

Selecting targets

The target of each “round” of collateral damage is selected randomly from the list of potential targets, as defined above. I don’t think the list is updated each round (so that a unit at the maximum damage mark could be selected), but I’m not certain.

Amount of Damage Done

The damage calculation is similar to the damage calculation for regular combat. However, the modifications to each unit’s strength are done differently.

The only potential attacker strength bonus is Barrage -- +20% for Barrage I, another 30% for Barrage II and another 50% for Barrage III. This affects the starting percentage of strength of each unit. The defender gets no strength bonus for anything. Hps are also not used in calculating these relative strengths.

All the regular artillery units (catapults, cannons, artillery, and (stealth) bombers) calculate based off of their full strength. The tanks (tank, panzer, modern armor) calculate based from 0 and the Cho-Ko-Nu starts at 50%.

Example: A Cho-Ko-Nu (str:6) will always have an adjusted strength of 3 (.5 * 6) when figuring collateral damage.

Example: A tank with Barrage I will have an adjusted strength of 5.6 (28 * .2) for collateral damage. With Barrage II, it would be 14 (28 * .5).

Then, the likely damage is half what it would be if the units were fighting directly with those relative strengths. That is, damage = floor(10*(3*A+D)/(3*D+A)). This amount is reduced only if the damage would put the defender past the damage threshold discussed above.

Example: A catapult (with Barrage I and Barrage II) is targeting a longbow with 71 hps in a city on a hill for collateral damage. The catapult’s adjusted strength is 7.5 (5 * 1.5) and the longbow’s adjusted strength is 6 – the hill defense, the city defense, the hps just don’t matter. The catapult does 11 damage to the longbow.

Putting It All Together

Then, the siege attack weapon simply loops through the selection and damage phase the number of times equal to the number of targets. Not every potential target gets hit and some may get hit more than once.

Example: A catapult (with Barrage I) attacks a stack with two full-strength muskets, a knight (with Combat I) at 54 hps, a sword at 38 hps, and an elephant at 83 hps. The number of targets is 3. The first random target is the elephant. Adjusted strengths of 6 and 8 means 8 damage to the elephant. Round 2, the knight is picked. Adjusted strengths of 6 and 10 mean 7 damage, but the limit is 4 because of maximum damage. Round 3, the elephant is selected again, and takes another 8 damage. Before combat between the catapult and the first full-strength musket begins, the stack now has two full-strength muskets, a knight with 50 hps, a sword with 38 hps, and an elephant with 67 hps. Then, the attack between the catapult and the musket would resolve as normally (described above).

Experience Points

The winner of combat gains experience points. Like most of combat, experience points are determined by the ratio of strengths. The value is floor(iXPValue*opponent_strength/your_strength), where iXPValue comes from the XML file. For all standard units, iXPValue is 4 for an attacking unit and 2 for a defending unit. The minimum number of experience points for a successful fight is 1, however. The strengths are the displayed modified strengths (from bonuses and hps).

Exceptions: A unit which attacks and retreats gains a single experience point in all cases. The defending unit receives no experience points in this case.

Example: A sword (str:6) attacks a spearman (str:4) on flatlands. If the sword won, he would receive 2 (floor(4*4/6)) xps. The spear would gain 3 (floor(2*6/4)) xps if it won.

Example: A modern armor (str:40) attacks a spear (str:4). If the modern armor wins (odds: 99.999999+%), it gains 1 xp, not 0 (floor(4*4/40)). If the spear wins (odds: 6e^-13), it would gain 20 xp (floor(2*40/4)).

(continued in next post)
Arathorn

Arathorn
Nov 04, 2005, 03:22 PM
Repercussions

Now I’ll discuss a bit of strategy. It helps to have understood, at least partially, the way combat works before reading this section, but it's not absolutely necessary.

Jump Points

Because of the nature of the hp damage dealt and the way it divides the attacker and defender’s hps, there are a few natural jump points, where a very small change in R can make a huge difference in relative odds of winning – these are points you should aim to be on the right side of, whether you’re attacking strong and want high odds or are attacking weak and need a best chance.

Full 100 hp situation

For ease in explaining, I’m going to describe the case when both the attacker and defender have 100 hps. Then I’ll discuss a bit of how it changes when either or both are injured.

The first is when the defender’s damage drops from 15 to 14. This happens when the attacker is at least 1.8 times as strong as the defender. It means the defender needs 7 hits to kill the attacker instead of 6. Above 1.8 R, the attacker wins 99+% of the time. That’s not to say upsets won’t happen (1% is actually pretty likely), but it does mean the odds are very good.

The second jump point is when attacker’s damage is 25. That means, the attacker needs only 4 rounds to destroy the defender. Doing a little math show that happens when R=11/7. If you are 1.57142857... times as strong as the defender, you win over 95% of the time. Shrink that just a little to only 1.57 times as strong and the odds of success drops all the way to 90%.

The third jump point occurs when the defender’s damage drops from 17 to 16. This is the difference between 6 hits to kill and 7 hits to kill. It happens when R = 43/31, which is approximately 1.387. Above that ratio, the attacker wins over 87.5% of the time. At 1.387 and below, the attacker wins less than 80% of the time. That’s a jump from 5/6 to 4/5. It’s significant. If you can achieve that 1.388 mark, it’s worth doing.

The final jump point is around an even battle. Even a tiny bit of strength makes a HUGE difference. Any stronger unit, by even .01, will have at worst a 62.3% chance of winning the combat. That’s because the stronger unit does 20 damage and the weaker only 19. 5 rounds to kill vs. 6 rounds to kill. That’s all there is to it. Going from a tiny bit stronger to a tiny bit weaker drops your chance of winning from 62.3% to 37.7%. A 40% chance of winning is impossible for fully-healed units(without first strikes).

Ratio value Odds of winning
>1.8 99%+
1.58-1.79 95%-98%
1.39-1.57 87%-90%
1.25-1.38 75%-80%
1.01-1.25 62%-75%
1.0 50%
0.80-0.99 25%-38%
0.73-0.79 20%-25%
0.64-0.72 10%-13%
0.56-0.63 2%-5%
<0.56 <1%

Obviously, it is to your benefit to just beat one of the jump points up if you can (so get 1.58:1 odds) and to avoid being on the bad end of a jump point. Attacking at 0.73:1 is a LOT better than at 0.72:1 (e.g., 4.4 vs. 6 is a LOT better than 4.3 vs. 6). Probably worth scrolling attackers to get good odds.

Note: the 75% spot is NOT a jump point. I just included it for perspective's sake.

Wounded Attacker/Defender

If one of the units is wounded, then the jump points situation will change. There will still be jump points, however. Those points will occur at the points when one side’s damage crosses a jump point. The jump points can be found by looking at ceiling(remaining_hps/n) where n is any number (but, in reality, only n up to 8 are very likely to be an issue). The attacker looks at the defender’s remaining hps and the defender looks at the attacker’s remaining hps.

Example: A 64 hp unit is attacking a 91 hp unit. Without consideration of strengths, we know that the jump points will occur when the attacker’s damage is 91, 46, 31, 23, 19, 16, 13, 12. Well, damage = 91 is impossible and damage = 46 is very unlikely, so there are jump points at 6 locations based off the defender’s hps. (More explicitly, ceiling (91/1) = 91, ceiling (91/2) = 46, ceiling (91/3) = 31, ..., ceiling (91/8) = 12.) There will be jump points for the defender, too. Those jump points occur at fractions of 64 – so 64, 32, 22, 16, 13, 11, 10, and 8. 64 is impossible and 8 is very unlikely. That leaves 32, 22, 16, 13, 11, and 10. So, the critical R values (from the attacker perspective) are 2.52, 1.32, 0.90, 0.64, 0.40, 0.32, 0.37, 0.83, 1.57, 2.47, 3.77, and 5.00. Those come from the attacker’s damage needed and the defender’s damage needed respectively (so that 0.90 corresponds to 19 attacker damage and 1.57 to 16 defender damage).

The R values needed to do a certain amount of damage (or to prevent it being done to you) are summarized in this table (all figures rounded to the nearest hundredth).

Min ratio to do x damage:
R 1/R damage
1/5 (0.20) 5/1 (5.00) 10
13/49 (0.27) 49/13 (3.77) 11
1/3 (0.33) 3/1 (3.00) 12
19/47 (0.40) 47/19 (2.47) 13
11/23 (0.48) 23/11 (2.09) 14
5/9 (0.55) 9/5 (1.8) 15
7/11 (0.64) 11/7 (1.57) 16
31/43 (0.72) 43/31 (1.39) 17
17/21 (0.81) 21/17 (1.24) 18
37/41 (0.90) 41/37 (1.11) 19
1/1 (1.00) 1/1 (1.00) 20
43/39 (1.10) 39/43 (0.91) 21
23/19 (1.21) 23/19 (0.83) 22
49/37 (1.32) 37/49 (0.76) 23
13/9 (1.44) 9/13 (0.69) 24
11/7 (1.57) 7/11 (0.64) 25
29/17 (1.71) 17/29 (0.59) 26
61/33 (1.85) 33/61 (0.54) 27
2/1 (2.00) 1/2 (0.50) 28
67/31 (2.16) 31/67 (0.46) 29
7/3 (2.33) 3/7 (0.43) 30
73/29 (2.52) 29/73 (0.40) 31
19/7 (2.71) 7/19 (0.37) 32
79/27 (2.93) 27/79 (0.34) 33
43/13 (3.15) 13/43 (0.32) 34

So, for all R between 1.10 and 1.21, 21 damage is done by the attacker.

Example: A 64 hp axeman attacks a 91 hp spear, with no bonuses or terrain modifications. The axeman’s adjusted strength is 5 * 1.5 * 64/100 = 4.80, and the spear’s adjusted strength is 4 * 91/100 = 3.64. R = 1.32 (just below). The spear wins 48% of the time and the axe just 52%, despite a rather significant advantage in R.

Example: Same as before, but now the axeman has 65 hps, instead of 64. Axeman’s adjusted strength is 4.87, so R = 1.34. The spear now only wins 34.4% of the time and the axe 65.6%.

How to Handle Jump Points

One problem with this is that hps are not displayed. I’ve not found any way to determine a unit’s hps other than to keep track of them from the Combat log window. Of course, for units strength 10 and higher, you can look at their remaining strength and determine exact hps. Either way is quite tedious.

Another problem is that the above table is rather long and complicated. I can generate it easily enough but there’s no way I can memorize it. The table for healthy units is easier – 7/5 is a good estimate for 1.39 and I can calculate that in my head. But figuring the jump points for injured units and then thinking 1.85? Hard to do.

The problem is that it matters. It matters in the order in which you attack. It matters in what your goals are. It matters in all kinds of things that insanely motivated Civers (like that guy I see in the mirror) care about.

Example: Two axemen, one with 64 hps and one with 55 hps absolutely, positively have to kill two spearmen (with 91 and 89) hps this turn. They’re on the only metal in my empire, for example. I have two choices. Attack with the stronger first and then the weaker? Or the semi-counterintuitive and attack with the weaker first? Well, attacker stronger then weaker gives me a 23.2% chance of killing both, whereas attacking weaker then stronger gives a 28.5% chance of killing both.

Example: Same as above, but my stronger axeman has 65 hps. Weaker then stronger is now a bit better, 28.8%. BUT, stronger then weaker is an even better 29.2%. Because of the jump points.

And, depending on how the computer rounds things ending in .x5, I might not be able to tell the difference between a 64 hp axeman and a 65 hp axeman by looking – one is strength 3.20 and one is strength 3.25 (which may well round to 3.2). Keeping track of hps, which aren’t even displayed, could make significant differences in outcomes. What tedious micromanagement – it’s creeping back in again.

Bonus Peculiarities

Because of the way situation-dependent bonuses are applied to the defender instead of the attacker, some care needs to be taken in their use. The difference between a 25% bonus to yourself and a 25% penalty to the foe can be quite significant.

Example: Consider a unit with 3.7 strength (injured sword or whatever) with a 25% Cover promotion (or just any 25% bonus against archer units) attacking an archer in the woods. I'd expect from reading the +25% strength promotion to have 3.7*1.25=4.6 strength attacking 4.5 (3*1.5), so I would hope to have the odds in my favor (almost 64% of the time). BUT because of the bonus peculiarity, it'd be my 3.7 against their 3.8 (3*1.25). So, in actuality, the odds would be against me (36% chance of success)!]

Now, the correct numbers are displayed, but a clever player wants to know which units to use when. Reaching a jump point is nice, but the bonus peculiarity can be used (dis)advantageously as well.

If the defending unit has no bonuses (from terrain or fortification or against the attacker), then the R value is unchanged. So, there’s no real area of gain to play against. It’s only when the defender has some defensive strength that the peculiarity makes a noticeable difference.

If the expected attacker bonus that is eventually subtracted from the defender’s bonus is greater than the defender’s bonus, the peculiarity helps the attacker (i.e., when overall value for the defender bonus is negative). That is, both the attacker and the defender have bonuses, but the attacker’s bonus is larger than the defender’s. So, a lot of bonuses will be more valuable than expected if they overcome defender’s bonus. If you’re attacking fortified units in cities, for example, that don’t have a city defense bonus, the specific promotion for that scenario will be worth a little more than its listed percentage value.

Example: A sword (str:6) with City Raider I, II, and III is attacking a pike (str:6) defending a city. The city has a 30% defensive bonus. The attacker’s strength is just 6, but the defender’s strength is 6/(1+1.1-.3) = 3.33, for an attack ratio of 1.80. The “right” way of doing things would have a strength 12.6 unit attacking a 7.8 unit, for a ratio of 1.62. So, here, the bonus peculiarity is helping the attacker.

If the expected attacker bonus does not overcome the defender’s bonus (i.e., when overall value for the defender bonus is positive), the targeted promotion is providing less than its promised weight. That is, your 25% bonus against archery units may only be providing 22% in this case. You’d probably be better off just defending, all other things being equal. (See the earlier example)

First Strike

First strikes make the most dramatic difference to pure winning percentage when the two fighting units are very close in strength. Two units with identical strength and equal first strikes each have a 50% chance of winning (YAY! Something that finally makes sense in this mess of math). Give 1 a single first strike, though, and the odds of that unit winning goes up to 56.8%. That’s a tremendous difference. Take somebody at the 1.39:1 level and a first strike only matters a few percentage points (from 87.6% to 90.8% and still 84.5% if the weaker unit has the first strike). More than one first strike are similarly weighted towards mattering most for units close in strength. Raw strength is still VERY important, though. A unit with 3.3 strength and no first strikes will still kill a unit with 3 strength and 2 first strikes more often (~56% of the time).

The other thing, though, is that units with first strike are less likely to be wounded. First strike helps preserve hit points, so that a unit which won will be healthier. Back to the 3.3 vs. 3 with 2 first strikes example. The stronger unit wins more, but it deals, on average, 78.6 hps damage, while the first strike unit deals, on average, 79.8 hps damage. And the first striker is more than twice as likely to walk away uninjured as the stronger unit.

If your unit is barely stronger with first-strike or barely weaker without first strike, then the first strike promotion is better than a strength promotion. This appears true out to about the 1.38/1.39 strength ratio barrier. If the strength ratio is outside 1.38, strength beats first strike. And if strength would change which unit is stronger, strength wins out. Exact calculations on this may come later. One thing to note -- Combat I doesn't always give 10% to modified strength. An archer defending a city on a hill, for example, gains far less than 10% modified strength with Combat I (6 vs. 6.3). In cases with lots of bonuses, Drill might be the better promotion, potentially even over a 20/25% bonus. Work is still in progress on this.

Graph of Win Percentages
http://www.civfanatics.net/uploads10/Civ4_Combat_Win_Percent.jpg
R = attacker's strength/defender's strength

Green -- attacker has 2 extra first strikes
Blue -- attacker has 1 extra first strike
Black -- attacker/defender even on first strikes
Orange -- defender has 1 extra first strike
Red -- defender has 2 extra first strikes
(sorry for the messiness -- I drew it by hand)

Arathorn

Mujadaddy
Nov 04, 2005, 08:15 PM
Here's some math, demonstrating the utility of the "vs. Specific situations" promotions over the General "Combat x" promotions...

For example, let's say you have two swordsmen ready to attack a city.....

1. Swordsman (+10% City Attack, and Combat II... 7.2 Strength) vs. Archer (+50% City Defense... 3 Strength) A/D Ratio is 1.714 (A=7.2 / D={3*1.4} 4.2)
2. Swordsman (+10% City Attack, and Combat I and City Raider I... 6.6 Strength) vs. Archer (+50% City Defense... 3 Strength) A/D Ratio is 1.833 (A=6.6 / D={3*1.2} 3.6)
Both situations show a significant advantage to the Swordsmen, but, in its role, the City Raider is numerically superior.

(I was worried that it wasn't even significant, statistically; but it appears that it is... )

Arathorn -- can you try to analyze the massive amount of damage the attacker seems to take when the odds are close... or even when they're not...

Kylearan
Nov 05, 2005, 07:05 AM
Hi,

great analysis! I knew how combat works internally before, but never thought about jump points and bonus peculiarities. Thanks! :goodjob:

-Kylearan

Khaim
Nov 05, 2005, 07:16 AM
I'm curious as to how your archers and knights get City Raider. But good stuff. The whole "subtract attackers mods from defender" is really counterintuitive; why didn't they just go back and add them to the attacker?

Pfeffersack
Nov 05, 2005, 08:59 AM
(...)
Example #2: A knight (str:10) with Combat I and Pinch (+25% vs. archers) promotions is attacking a longbow (str:6) in a forest. The attacker’s modified strength is again simple, using the Combat I promotion of 10%. The knight’s attack value is 11 (10 + .1*10). The longbow has an initial bonus of +50% for the forest. However, the knight’s Pinch bonus now affects the defending longbow, giving it a -25%, too. So, the overall bonus for the longbow is +25%. The defender’s modified strength is 7.5 (6 + .25*6).(...)

Small correction: The special promotion against archers is Cover, not Pinch.

Apart from that a great article!

Those "most attacker boni are applied to the defender" rule is somehow necessary to get the combat system working correctly.And it is definitly another issue to take in account, when deciding for or against certain promotions.

Entrinzikyl
Nov 05, 2005, 09:01 AM
So there are percentage ranges for odds of winning that don't exist? Like the odds of winning will never be 51-61%? Seems strange. Informative post though.

Pfeffersack
Nov 05, 2005, 09:06 AM
There are still first strikes, which may cause values within those ranges.

BTW, first strikes are not to be underestimated.There is no better countermeasure against the danger of :spear:

SPQR300
Nov 05, 2005, 12:58 PM
MOST USEFUL THREAD SO FAR!!!

WOW, after reading the thread, I played a little, and realised that the war system is way better and more complex then in any other strategy game. (except Warcraft maybe :D) The bonus damages against certain unit types, terrain, rivers, stacks, airplanes, siege make the wars extremely complex. I think it's even possible to make unit combinations, like war elephant +maceman in one stack. They can only be hurt by archers or other maceman, war elephant, this combo makes mounted units useless... After all this I think spies and recon can be very useful, cause if you know what units the enemy has, and you even have a slight technological advance, you can make incredible damage very fast.

Khaim
Nov 05, 2005, 01:19 PM
It's a real shame spies come so late in the game, and the only other way to get advance intel is holy city LOS.

spiceant
Nov 05, 2005, 02:14 PM
before attacking you can also keep a few units inside enemy territory and keep an eye on his techs to make a better predicition of what youll need

edit:
this is a great thread, however a lot of people might not bother to read and comprehend all of this algebra, i would kindly ask you make a summary of whats in this thread, namely the parts about jumping points (24 to 25 damage) first strikes and the alt-mouseover thing which automaticly calculates odds.

meowsqueak
Nov 05, 2005, 02:44 PM
Arathorn - thanks for this well written and interesting article. Might I suggest a few easily printable graphs esp. R vs odds of winning?

Khaim
Nov 05, 2005, 04:23 PM
Hey, could you mod it to display the % chance of winning? Or is that too hard?

meowsqueak
Nov 05, 2005, 04:55 PM
Hey, could you mod it to display the % chance of winning? Or is that too hard?

That's a great idea, if possible :)

Unfortunately I'd have no idea how to do this but it might make a great intro tutorial on the topic of modding the interface.

Tribute
Nov 06, 2005, 07:01 PM
How can being damaged not matter? That basically means free healing, right? There must be something I missed.... What could it be?

Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat.

meowsqueak
Nov 06, 2005, 07:15 PM
How can being damaged not matter? That basically means free healing, right? There must be something I missed.... What could it be?

The hitpoints aren't really 'hitpoints' they are simply a measure of progress in the combat mechanic. A 'wounded' unit has a lower than normal 'strength' and therefore suffers a greater hitpoint reduction per lost attack/defence. There's no healing unless a unit waits a few turns.

Rather than thinking of it as 100 hitpoints, think of it instead as percentage of total stamina for that fight. A weak or wounded unit still has 100% available stamina at the start of the fight, but that amount of stamina might be quite low.

Jazz_Newton
Nov 06, 2005, 07:24 PM
Because being injured lowers your strength. You really don't want to fight injured if you can avoid it.

Lord Chambers
Nov 06, 2005, 09:14 PM
First strikes make the most dramatic difference when the two fighting units are very close in strength.
Your conclusion differs with those at Apolyton Civilization (http://apolyton.net/forums/showthread.php?s=&threadid=140622&).

How do first strikes work?

First, in order to determine how many first strikes a unit A actually got, you need to look at the combatting unit B. If B ignore first strikes, unit A will have 0 first strikes. (very important early on!) If both A and B have first strikes (say A has 3, B has 1) it's the difference that counts (A gets 2, B gets 0).

Once battle is fought, each first strike gives a free round of battle. That means that a round is fought normally, but in case A has a first strike, he can't lose the round. If B would be hit, he gets hit. If the result is negative, it is ignored.

Notice that the base strength of the units is unaffected: if A has a strength (or hp) of 4, first strikes of 2 after modifiers, and B has a modified strength of 6, the first 2 rounds still have a 4/(4+6)=0.4 chance of succeeding, taking 0.2*6*(3*4+6)/(3*6+4)= 0.98 off the strength of B each time they hit. B, however, has 6/(4+6)=.6 chance of succeeding, but instead of taking .2*6*(3*6+4)/(3*4+6)=1.46 off the strength of A, it doesn't hit anything.

Once first strikes are over, combat continues as usual. At most, B has been hit once (but it could be twice or not), which would mean its strength is now at 5. (the average would be a bit higher) A is still at 4. The numbers in the formula don't change, though, so B still has a .6 chance of winning the next round, while A only has .4. With those numbers, B is almost certainly going to win, even if he was hit a little during first strikes.

You would be tempted to think that first strikes are thus unimportant. Nothing is farther from the thruth, you only need to use them well. If the situation is reversed, and a unit C has 6 strength and 2 first strikes, while unit D has 4 strength, the results are very different.

C will hit D in 60% of the cases, and it will do 0.97 damage. D can hit C in 40% of the cases, and will do 0.8 damage. With those numbers, C will hit D once or twice, doing at least 0.97 damage and reducing D to 3.03. Another 4 hits and he's dead... C still needs 6/.98= 6.1 or 7 hits.

(due to roundings, this is a bad example. In reality the number of rounds left will be 3 for C and 6 for D)

If you compare the battle of C with one without first strikes, you would see that C has a much higher chance of not getting damaged, with a sligthly higher chance of actually winning. The bigger the difference in strengths between C and D, the extremer this effect. Adding 2 first strikes to a unit that is already twice as superiour will mean he will win most battles undamaged. As your damage directly affects your strength in the next battle it is very important to keep a good health.

OTOH, if the difference between the strengths decreases, first strikes give a small advantage. You can use that to win fights where e.g. you have a 10% disadvantage. Once the difference is too large, first strikes won't help you to win, though.

First strikes should be used for two different types of units: those that defend and the overwhelming attackers. As defenders are most likely stronger because of the bonusses, they are helped as they can fend of multiple attacks, still remaining strong. It's very annoying to have dozens of units attack a city, where one single defender just shrugs of the attacks.

For the overwhelming attackers, it can keep you going. This especially applies to pillagers: they will remain healthy long enough to pillage that resource far inside the foreign borders, where units with the same strength but no first strikes will get slowly damaged over time to a point where an older unit can win. A tank which is damaged to strength 1 will most definately lose from a spearman of modified strength 5.

Dragonlord
Nov 07, 2005, 03:18 AM
Your conclusion differs with those at Apolyton Civilization (http://apolyton.net/forums/showthread.php?s=&threadid=140622&).

To the contrary: they're both saying the same thing with different words: First Strike makes a difference to winning when the units are at equal or almost equal strength

Tribute
Nov 07, 2005, 09:46 AM
I see. I wonder where he said that. *Searches (very hard)*

Lord Chambers
Nov 07, 2005, 05:38 PM
To the contrary: they're both saying the same thing with different words: First Strike makes a difference to winning when the units are at equal or almost equal strength
The math of the post I quoted reveals first strike to be most valuable to units that have a high strength ratio to the units they fight. Because they can steamroll (or brickwall, which I guess you could term the defensive equivalent).

DeepO does say that first strikes are a benefit in a close fight, but it's a smaller perk than in a not-close fight. He emphasizes the greater benefit in a mismatch.

Arathorn says they make the most dramatic difference in close fights.

Those are differing (not to be construed "opposite") opinions.

abj9562
Nov 08, 2005, 06:54 AM
Good thread!

icon41gimp
Nov 08, 2005, 09:00 AM
I think the article you posted is more concerned with HP left over after the battle than the odds of winning. The battle odds involving a ~2 strength ratio can't really be improved but I'm sure the odds of winning without HP loss increase greatly with first strikes. For equal strength ratio, with first strikes or not you're pretty much going to loss HP unless you can survive ~5 coin flips in a row.

Arathorn
Nov 08, 2005, 09:09 AM
No offense to DeepO, but I think he's wrong. Let's look at some numbers.

Close Fight

I'm going to take "close fight" to mean 1.1 vs. 1. We can disagree on what close fight means, but a 10% difference in strength is reasonably minor and not too infrequent. We can look at the difference first strike makes in this case and compare it with a "blow-out" fight. For the sake of reading (and without loss of generality), we'll assume the attacker is the stronger unit.

No First Strike

Attacker wins: 68.0%
Attacker wins flawlessly (0 damage): 3.9%
Average hp remaining when winning: 44.5
Average hp of defender remaining when attacker loses: 44.1
Average damage taken: 69.7 hps
Average damage done: 85.9 hps

Attacker 1 first strike

Attacker wins: 73.8%
Attacker wins flawlessly (0 damage): 5.8%
Average hp remaining when winning: 48.6
Average hp of defender remaining when attacker loses: 41.0
Average damage taken: 64.3 hps
Average damage done: 89.3 hps

Defender 1 first strike

Attacker wins: 62.2%
Attacker wins flawlessly (0 damage): 2.0%
Average hp remaining when winning: 40.1
Average hp of defender remaining when attacker loses: 46.2
Average damage taken: 75.1 hps
Average damage done: 82.5 hps

Attacker +10% strength (1.21 vs. 1)

Attacker wins: 73.3%
Attacker wins flawlessly (0 damage): 4.9%
Average hp remaining when winning: 49.5
Average hp of defender remaining when attacker loses: 40.1
Average damage taken: 63.7 hps
Average damage done: 89.3 hps

Conclusions for close

A single first strike makes about a pure 2% difference in surviving unscathed (taking no damage). But that's relatively about a 50% difference -- an attacker is 1.5 times as likely to come out without damage with a single first strike advantage as without. And the difference in winning is notable, too -- a pure 5.8%, which is a relative 8.5%. These are pretty significant differences. First strike also makes about a 5 hp difference in the "average" case -- 5 more hps are done and 5 fewer hps are taken. That has healing time repercussions.

I added the +10% strength for comparison's sake. Note that the single first strike is better across-the-board here.

Blowout Fight

Again, you can argue with the definition, but for simplicity of example's sake, I took a blowout fight to mean 2 vs 1. So the attacker (again, for simplicity) is twice as strong as the defender.

No first strike

Attacker wins: 99.1%
Attacker wins flawlessly (0 damage): 19.8%
Average hp remaining when winning: 72.8
Average hp of defender remaining when attacker loses: 30.3
Average damage taken: 27.9 hps
Average damage done: 99.7 hps

Attacker 1 first strike

Attacker wins: 99.4%
Attacker wins flawlessly (0 damage): 26.3%
Average hp remaining when winning: 77.1
Average hp of defender remaining when attacker loses: 28.1
Average damage taken: 23.3 hps
Average damage done: 99.8 hps

Defender 1 first strike

Attacker wins: 98.8%
Attacker wins flawlessly (0 damage): 13.2%
Average hp remaining when winning: 68.5
Average hp of defender remaining when attacker loses: 31.3
Average damage taken: 32.3 hps
Average damage done: 99.6 hps

Attacker +10% strength (2.2 vs 1)

Attacker wins: 99.4%
Attacker wins flawlessly (0 damage): 22.3%
Average hp remaining when winning: 76.9
Average hp of defender remaining when attacker loses: 27.4
Average damage taken: 23.6 hps
Average damage done: 99.8 hps

Conclusions for blowout

A single first strike makes about a pure 6.5% difference in surviving unscathed (taking no damage). But that's relatively only about a 33% difference -- an attacker is 1.33 times as likely to come out without damage with a single first strike advantage as without. The difference in winning is pretty microscopic -- a pure 0.3%, which is a relative 0.3%. These are differences that will be very hard to detect. First strike still makes about a 5 hp difference in the "average" case -- 0.1 more hps are done but 4.6 fewer hps are taken. That has healing time repercussions, but not as pronounced as in the close fight case.

Again, though, we note that first strike is better than +10% strength universally. It's better in every category we noted.

Overall Conclusions

First strike does make a bigger pure percentage difference of coming out of a battle without injury in the blowout case. If your units are WAY stronger and you want to be blitzing a lot and care almost exclusively about not being injured at all, first strike helps. I didn't show the numbers, but it helps more than an extra 10% of strength, too (even more than an extra 25% strength, but, again, ONLY for coming out completely uninjured).

When looking at overall damage taken, first strike is quite minor in the blowout case, even moreso than in the "close" case. Total expected healing time (what I find to be the most compelling statistic) is affected more by first strike in the close case than in the blowout case.

Also, first strike is quite compelling. It's better than +10% strength in these cases. Of course, if the +10% strength can put you over a "jump point", it's going to clearly be better. If not, though, first strike is pretty strong. It just makes more difference in the "close" case than the blowout case.

Arathorn

Arathorn
Nov 08, 2005, 12:47 PM
First post updated -- including a graph of various combat odds with first strikes.

I'm working on something about damage done/taken and # of units of x strength that will be expected to kill a unit of y strength, but those will be a while. It's hard to do too much over lunch here at work.

Arathorn

takatok
Nov 08, 2005, 05:23 PM
The conclusion were not different. Lord Chambers was just confusing to differnt points both were making. First strike can affect 2 things:

Chance of Winning:
DeepO: Only good if close strength makes little difference in lopsided fights
Arathorn: Only good if close strength makes little difference in lopsided fights

Maintaining health after fight:
DeepO: In lopsided fights the heavily favored unit will first strike will sustain great reduced health loss (possible none).
Arathorn: In lopsided fights the heavily favored unit will first strike will sustain great reduced health loss (possible none).


Both uses are of great importance at various times of the game, and the posts on both sites were great.

Takatok

秦始皇
Nov 09, 2005, 05:05 AM
good aricle but seems not clear about combat promotion
the bonus is just influenced by the strength when the unit is born such like
one knight with combat 4 promotion now has only 1.1strength but at the battle it will be 1.1+40%*10=5.1 so it can be more powerful even when it is
not healthy, Yet the combat level si very improtant when your unit grow up
PS: I'm a new comer to here from china

Arathorn
Nov 09, 2005, 08:48 AM
I don't think you're right about combat promotions. They only seem to affect the unit's CURRENT strength, not its overall total strength. So, an injured knight with combat 4 promotion with 1.1 strength will only fight at 1.1*1.4 = 1.51, not at 5.1. But I should verify to be certain.

Arathorn

icon41gimp
Nov 09, 2005, 09:26 AM
Yeah combat promotions work off the current strength. I had a 0.1str swordsman with Combat 3 and the odds when I dragged him over a barbarian sword was 0.1 vs 6.0

Renata
Nov 09, 2005, 12:25 PM
Do you have any information on how XP is assigned? I haven't been able to find any details in the manual. (Not that I've looked very hard. :blush: )

Fantastic article, by the way. Thanks.

Arathorn
Nov 09, 2005, 12:36 PM
Do you have any information on how XP is assigned?

Sorry, not yet. It's on the "To do" list, but it's quite a ways down at this point. :( All that's known is the hard cap of 10 vs. barbs (you can't get more than 10 xps by fighting barbs), and vague discussions of "more" for attacking and "more" for winning upset battles. And something vague about less for dominating victories.

Arathorn

Short Timer
Nov 09, 2005, 06:15 PM
Hi All -

I've enjoyed reading the info in the forum - thanks. Based on Arathorn's equations for damage and the odds of winning an individual round as I understand them, I put together a Monte Carlo simulation in Excel. Basically it runs 100,000 simulated encounters for each value of R (from 1.00 to 2.00 in 0.01 increments). The odds of winning are approximated by the number of times (out of 100,000) that the attacker was successful, by being the first to "score" 100 points of damage. The curve plots the odds of winning as a function of R ratio, and shows some breakpoint features similar to what has been described... I only spent a couple hours on it, so please don't take it as gospel. If anybody's interested, please PM me, and I'll email the spreadsheet.

- Pete

meowsqueak
Nov 09, 2005, 06:49 PM
The curve plots the odds of winning as a function of R ratio, and shows some breakpoint features similar to what has been described.

Nice work. What does the graph look like below 50%? Is it a 180-degree rotation around [1.00,50%] ?

Heroes
Nov 10, 2005, 01:35 AM
Great analysis, thanks, Arathorn! :)

The first conclusion I can draw is that we should try all the means to get R>1 in the 1st place. This should become much harder at higher levels.

The 2nd idea is to get every new unit at least 6 XP: 4 from barracks, 2 from vassalage or theocracy. 6 XP means 2 promotions before battle, giving much larger chance to make R>1 than 4 XP.

The 3rd: could I say that combat promotions are in general the best ones? Not only because they are generically useful, but also because their effect is not necessarily worse than a specific +20% or +25% promotion. A classical example is sword vs. archer in a hill city. The defensive bonus gotten by archer is 50% from city, 25%+25% from hill, 25% from fortifying, altogether 125%, then reduced by sword's born city attack 10%, therefore 115%. Now, if the sword has combat 1, A=6*(1+0.1)=6.6, D=3*(1+1.15)=6.45, R=A/D=1.023. OTOH, if it's city raider 1, A=6, D=3*(1+1.15-0.2)=5.85, R=1.026. The net difference in combat result is rather small, but combat 1 will be also useful when not attacking city.

Mathematically, it's comparing (1+a)/(1+d) and 1/(1+d-b), where a is the combat promotion bonus, d is total defensive bonus, b is specific promotion bonus. This is assuming d-b>=0, which is in most cases true. To make the 2 things equal, we get (1+a)(1+d-b)=1+d, therefore a(1+d)=(1+a)b, b=a(1+d)/(1+a), or b/a=(1+d)/(1+a). So, the bigger d is, the bigger we need b/a to make specific promotion better. In another word, the smaller d is, the more profitable is specific promotion.

When to begin assign drill promotion (first strike)? I guess it should be after making sure you get a large enough R, then you mainly care about remaining health. As you show, a first strike helps more than combat 1 when R=1.1, but that's because 1.21 from 1.1 doesn't make a jump. And if the defender gets combat 1 rather than drill 1, he will make R=1, thus turn the tide. Before getting large R, I guess it's still wise to add more strength than first strike.

WuphonsReach
Nov 10, 2005, 11:47 AM
For defense, you talk briefly about forests/jungle. But what happens when your defending unit is on a forest/jungle hill? (Or a coastal tile.) Do you get the sum of 25%+50% (or 10%+50%) or do you just get the max for that particular tile?

Same question with regards to applying a fort to a tile. Does a fort on a hill grant 25%+25%, or just 25%?

Arathorn
Nov 10, 2005, 11:58 AM
Terrain bonuses stack, so a forested hill is worth 75% defense (+25% for hill, +50% for forest). I should really write those up in more detail. :( This is all work in progress, though, and there are so many things on my "to do" list just for combat, it's not even funny.

I don't know how forts work for certain yet. I'd guess they stack as well, but that's just a guess until I can do some actual testing on it.

Arathorn

Krikkitone
Nov 10, 2005, 01:27 PM
One question, are you certain that the bonuses are applied to the defender, because that makes for an interesting situation

assume that unit 1 has a net +25 v. unit 2 (unit 1s bonus - unit 2's bonus)

If unit 1 attacks, then the R in unit 1s favor goes up by 33% (the defender is reduced to 75% and there fore the attackers bonus is the inverse 3/4 -> 4/3)

If unit 2 attacks the R in unit 1s favor only goes up by 25% (unit 1 is the defender so the bonus applies dirsctly to it.)

This means that if
1) combat is inevitable
2) either unit has a net bonus against the other unit
3) there are no 'defender only' bonuses (fortification, culture, terrain, garrison)

You always want to be the attacker

especially leading to interesting situations, for example Quechas with 100% v archers reduce an archer to 0 strength if they attack it while it has no defense bonuses (so a Quecha/Pikeman/Explorer v. Archer/Knight/Animal unfortified in the open field will kill its target and suffer no damage)

Arathorn
Nov 10, 2005, 02:17 PM
If unit 1 attacks, then the R in unit 1s favor goes up by 33% (the defender is reduced to 75% and there fore the attackers bonus is the inverse 3/4 -> 4/3)

Nope. For "negative" bonuses for the defender, the absolute value of it is added to 100% and the defender's strength is divided by the total. So, in this case, the defender has a -25% bonus, so its strength is divided by 1.25. Coincidentally (no, not really), that's the same as multiplying the defender's strength .8 (4/5). That leads to R = 1/.8 = 1.25. Exactly the same!!! It's only when there ARE other defender bonuses that the system doesn't do exactly what it claims.

So, that quencha attacking an archer in the open will show a strength of 2 vs. 1.5. The archer's defensive bonus is -100%, but to prevent the situation you talked about, negative percentages don't really subtract. The archer's strength is 3/(1+1) = 3/2 = 1.5. That's the same as if the quencha were given its 100% bonus to be 4 on 3, like you'd expect.

Put that archer in a forest, though, and you get a -50% defender bonus, so the archer's strength is 3/(1.5) = 2 and you get 2 vs. 2, which is worse for the attacker than the expected case of 4 vs 3.75.

Fortify the archer on a hill in a city, and the defender bonus is 25% (fortification) + 50% (hill for archer) + 50% (archer city bonus) - 100% (quencha bonus) = 25%. The attack is 2 vs. 3.75 or R = .53. The "expected value" is 4 vs. 6.75 or R = .59, so the attacker is again worse off than the way the desciption normally would lead one to believe.

HTH,
Arathorn

Krikkitone
Nov 10, 2005, 02:31 PM
Nope. For "negative" bonuses for the defender, the absolute value of it is added to 100% and the defender's strength is divided by the total. So, in this case, the defender has a -25% bonus, so its strength is divided by 1.25. Coincidentally (no, not really), that's the same as multiplying the defender's strength .8 (4/5). That leads to R = 1/.8 = 1.25. Exactly the same!!! It's only when there ARE other defender bonuses that the system doesn't do exactly what it claims.

So, that quencha attacking an archer in the open will show a strength of 2 vs. 1.5. The archer's defensive bonus is -100%, but to prevent the situation you talked about, negative percentages don't really subtract. The archer's strength is 3/(1+1) = 3/2 = 1.5. That's the same as if the quencha were given its 100% bonus to be 4 on 3, like you'd expect.

Put that archer in a forest, though, and you get a -50% defender bonus, so the archer's strength is 3/(1.5) = 2 and you get 2 vs. 2, which is worse for the attacker than the expected case of 4 vs 3.75.

Fortify the archer on a hill in a city, and the defender bonus is 25% (fortification) + 50% (hill for archer) + 50% (archer city bonus) - 100% (quencha bonus) = 25%. The attack is 2 vs. 3.75 or R = .53. The "expected value" is 4 vs. 6.75 or R = .59, so the attacker is again worse off than the way the desciption normally would lead one to believe.

HTH,
Arathorn

I see, makes sense. (in some sense making it easier because its only about adding/subtracting all the necessary bonuses.)

snepp
Nov 10, 2005, 04:24 PM
I see, makes sense. (in some sense making it easier because its only about adding/subtracting all the necessary bonuses.)

Yes, once you get past the situations when a "negative bonus" is applied to a defender (and the subsequent formula change), it does make it easier.

Roland Johansen
Nov 11, 2005, 11:37 AM
Thank you for this great article. It is very useful for people who understand the mathematics a bit.

I read one part that I didn't get completely:

If the expected attacker bonus that is eventually subtracted from the defender’s bonus is greater than the defender’s bonus, the peculiarity helps the attacker (i.e., when overall value for the defender bonus is negative). So, a lot of bonuses will be more valuable than expected if they overcome defender’s bonus. If you’re attacking fortified units in cities, for example, that don’t have a city defense bonus, the specific promotion for that scenario will be worth a little more than its listed percentage value.

In a earlier part you explained how the negative defense bonuses work:

If the overall value is negative, the defender’s modified strength is found by taking the original defender’s strength divided by (1-overall_value). [Note: That’s the same as dividing by (1+abs(overall_value)) when overall_value is negative, which is how I think of it.]

If I understand this correctly, then if the defender has no defense bonuses then it doesn't really matter if the bonuses from the attacker are added to his strength or the defender's strength is reduced by a relative similar amount.

Attacker strength 10 *1.25 vs defender strength 10 has probabilistically the same outcome as attacker strength 10 vs defender strength 10/1.25.

Of course, you already know this, but the first quoted part of text suggests something else. I do agree with the text that describes the lesser effectiveness of specific bonuses of the attacker if the defender has a defense bonus. And it is of course very useful to know the exact percentages of the jump points.

Arathorn
Nov 11, 2005, 12:05 PM
I read one part that I didn't get completely:

Re-reading, I'm not quite sure what I meant either. Let me ponder on it for a while over the weekend. I have a major goal of understanding collateral damage and having it written up early next week. This is an article in progress. And I think the part you quoted is ... inaccurate. I've got to sit down a bit more and think about the effects of the not-add-to-attacker but subtract-from-defender method they're using. I think I may have it a bit wrong. :( Thanks for pointing it out and encouraging me to think on it a bit more.

Arathorn

snepp
Nov 11, 2005, 06:35 PM
Do you have any information on how XP is assigned? I haven't been able to find any details in the manual. (Not that I've looked very hard. :blush: )
I know it's been a couple days, but if you haven't already run across this thread (http://forums.civfanatics.com/showthread.php?t=139534), it should answer most (if not all) of your XP assignment questions.

Roland Johansen
Nov 11, 2005, 07:01 PM
Re-reading, I'm not quite sure what I meant either. Let me ponder on it for a while over the weekend. I have a major goal of understanding collateral damage and having it written up early next week. This is an article in progress. And I think the part you quoted is ... inaccurate. I've got to sit down a bit more and think about the effects of the not-add-to-attacker but subtract-from-defender method they're using. I think I may have it a bit wrong. :( Thanks for pointing it out and encouraging me to think on it a bit more.

Arathorn

That's absolutely ok. Civ 4 is just out and you're already writing an article about one of the more difficult game mechanics. Errors will be almost unavoidable.

You described the effects of a first strike. But there are differences in the first strike upgrades. Some mention '1 chance of first strike' and some just mention '1 extra first strike'. Do you know what is exactly the difference (how big is the 'chance' on a first strike)?

I guess that completing the article will require some research, because it's not an easy subject. But the main points have been covered by the present version. Great job so far.:goodjob:

hairylegs
Nov 12, 2005, 03:05 PM
Put that archer in a forest, though, and you get a -50% defender bonus, so the archer's strength is 3/(1.5) = 2 and you get 2 vs. 2, which is worse for the attacker than the expected case of 4 vs 3.75.

Fortify the archer on a hill in a city, and the defender bonus is 25% (fortification) + 50% (hill for archer) + 50% (archer city bonus) - 100% (quencha bonus) = 25%. The attack is 2 vs. 3.75 or R = .53. The "expected value" is 4 vs. 6.75 or R = .59, so the attacker is again worse off than the way the desciption normally would lead one to believe.


What do you mean by these "expected" vs "actual" cases? For example in game if you mouse over the archer in the first situation with the quencha would the game show the strengths 4 vs 3.75 or 2 vs 2?

anton_z1
Nov 13, 2005, 12:11 AM
Can anybody give me numbers for 3-6 First Strikes !!!!.

WackenOpenAir
Nov 13, 2005, 08:40 AM
Nice, and so soon :)
I have my game since yesterday.

Arathorn
Nov 13, 2005, 05:42 PM
Issues I'm trying to work on right now/have planned to resolve:
- Correcting the article because hps ARE tracked and kept, so that a 5.0/6.0 unit (e.g., a wounded longbow) is weaker than a 5/5 unit (e.g., unwounded axeman). I had pulled the information on full hps at the start of battle from the Solver/DeepO article, but it's incorrect.
- Collateral damage. I've got most of this figured out, I think. A few more details to really work on nailing down, but I should have that part up early this week.
- XPs. As snepp mentioned, we got that figured out in another thread and I need to write it up.
- x-y first strikes. The "chance of first strike" thing. I'm not even sure how I'm going to test that at this point. It's probably important, but I don't even have a plan of attack.
- Air combat. Another major area, but it's going to have to wait a bit.
- A full-bore combat calculator to do stack combat and recommend best order for combat given the conditions. One-on-one is easy (and I'm sure the linked one will be corrected soon for the hp "problem"), but a stacked combat is much harder. I'm working on it, but even if I do it, I can't design a reasonable GUI to save my life.

If anyody knows of these (or wants to figure them out), I'd love to incorporate them into the article. I'm leveraging a LOT of people's work here, not just mine. Thanks to all who have contributed (snepp, especially, has helped a TON). And I'd love to get some more... :)

Arathorn

snepp
Nov 13, 2005, 06:22 PM
- Correcting the article because hps ARE tracked and kept, so that a 5.0/6.0 unit (e.g., a wounded longbow) is weaker than a 5/5 unit (e.g., unwounded axeman). I had pulled the information on full hps at the start of battle from the Solver/DeepO article, but it's incorrect. I looked at this the other day after reading a post somewhere, as all of my testing had been done on full-strength units. I was surprised to see that when attacking with a 5.5/10 knight that I didn't start at 100 HP as I expected, but at 55 HP.

So as you mentioned, this means that a knight with strength 6/10 is weaker than a longbowman at a full 6/6, not equally matched as I was assuming. The odds to win in each round of combat are equal (50/50), as is the damage that they will deal per round win (20). But with the knight starting at 60 HP compared to the longbow's 100 HP, the odds lean heavily towards the longbow.

Side note: If you haven't been making use of collateral damage in warfare, this is a very significant reason why you should.

- Collateral damage. I've got most of this figured out, I think. A few more details to really work on nailing down, but I should have that part up early this week.Excellent, I haven't looked much at collateral numbers other than the basic values assigned to cata/cannon/artillery.

- XPs. As snepp mentioned, we got that figured out in another thread and I need to write it up.Git'er done! :lol:

- x-y first strikes. The "chance of first strike" thing. I'm not even sure how I'm going to test that at this point. It's probably important, but I don't even have a plan of attack.
- Air combat. Another major area, but it's going to have to wait a bit.When you've got a plan of attack give me a shout, I love testing.

I'm leveraging a LOT of people's work here, not just mine. Thanks to all who have contributed (snepp, especially, has helped a TON). And I'd love to get some more... :)I....I think I'm starting to tear up a bit. Now if you fix my name in the first post I'll be all set. :lol:

WuphonsReach
Nov 14, 2005, 09:07 AM
Aye, collateral damage is key in Civ4 warfare. Especially against stacks-of-doom where your units would have to go up against the strongest defender in the stack.

At the start of a turn, I might be looking at 30 vs 60 odds (not very good for me) for attacking a heavily entrenched defender. But after a few bombing runs and a few suicide runs by artillery / heavy armor, those odds change over to 30 vs 15. Which lets me mop up the enemy stack with almost zero losses.

Krikkitone
Nov 14, 2005, 01:57 PM
I looked at this the other day after reading a post somewhere, as all of my testing had been done on full-strength units. I was surprised to see that when attacking with a 5.5/10 knight that I didn't start at 100 HP as I expected, but at 55 HP.

So as you mentioned, this means that a knight with strength 6/10 is weaker than a longbowman at a full 6/6, not equally matched as I was assuming. The odds to win in each round of combat are equal (50/50), as is the damage that they will deal per round win (20). But with the knight starting at 60 HP compared to the longbow's 100 HP, the odds lean heavily towards the longbow.

Are you sure of those last 2 facts? (equal chance to hit and damage per round) After all, if the number of hp reflect the 'max strength' of the unit might not the chance to hit or damage calculations Also use the knight's 10 instead of its 6?

snepp
Nov 14, 2005, 04:02 PM
Are you sure of those last 2 facts? (equal chance to hit and damage per round) After all, if the number of hp reflect the 'max strength' of the unit might not the chance to hit or damage calculations Also use the knight's 10 instead of its 6?

Absolutely certain. It's tough to setup the ideal testing situation I described with a 6/10 vs 6/6, but here are a couple examples that are close. The numbers in () are what the damage dealt would have been if units were at full strength.

Swordsman 1.7/6 vs Warrior 2.0
Swordsman starting HP: 28
Damage dealt per round win: Swordsman 18 (33) vs Warrior 21 (12)
Swordsman died in 2 hits

Swordsman 5.2/6 vs Jaguar 5.0
Swordsman starting HP: 86
Damage dealt per round win: Swordsman 19 (21) vs Jaguar 20 (18)
Swordsman died in 5 hits

Swordsman 4.3/6 vs Skirmisher 4.0
Swordsman starting HP: 72
Damage dealt per round win: Swordsman 20 (24) vs Skirmisher 19 (16)
Swordsman died in 4 hits

Krikkitone
Nov 14, 2005, 04:28 PM
Well I guess that explains damage, are the odds also althered (bes one I can think of is the swordsman/warrior battle, did the swordsman only get in one or two hits...hm actually that's not the best way to ask the question.) the odds would be a bit harder to test.

snepp
Nov 14, 2005, 05:16 PM
Well I guess that explains damage, are the odds also althered (bes one I can think of is the swordsman/warrior battle, did the swordsman only get in one or two hits...hm actually that's not the best way to ask the question.) the odds would be a bit harder to test.

I can't provide specific numbers for rounds won (should have kept a save), but the ratio was pretty close to 1:1, leaving the victorious unit significantly damaged.

Arkalius
Nov 14, 2005, 06:44 PM
Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat.

You know this for sure... I always thought units started with the hp they had...

Unfortunately it's hard for me to test this... there's no easy way to damage a unit in the worldbuilder.

snepp
Nov 14, 2005, 06:47 PM
You know this for sure... I always thought units started with the hp they had...

Unfortunately it's hard for me to test this... there's no easy way to damage a unit in the worldbuilder.
Read the handful of posts directly above yours.

Arkalius
Nov 14, 2005, 06:57 PM
Oh... perhaps I should pay attention, eh?

Krikkitone
Nov 14, 2005, 07:11 PM
what this actually means is that numbers are much more valuable, a 'wave' of troops can easily take out a more advanced one, because as each one damages it, they do more damage. (they already did, but this increases it)
reworked 'zergling' numbers
# units strength 10 attacking; strength of unit they can on average take out (based on this average number of X units required to destroy a tank)

1; 10 (tank to beat tank)
2; 17 (2 Infantry/Marines to beat tank)
3; 24 (3 Cavalry/Riflemen to beat tank)
4; 29 (4 knights to beat tank)
5; 34 (5 macemen/elephants/Muskets to beat tank)
6; 38
7; 42
8; 46 (8 swordsmen/longbowmen/horsearchers to beat tank)
9; 50
10; 54
(11 axemen to beat tank)
12; 61
15; 71 (~15 spearmen/chariots to beat tank)
20; 87
25; 101 (~25 archers to beat tank)
30; 115
40; 142 (~40 warriors can take on a tank/Panzer)
50; 168

Arkalius
Nov 14, 2005, 07:14 PM
I've developed a command-line Java app that calculates the odds of a unit winning given both it's health status and it's strength values. It also supports first strikes but only a single amount, it doesn't consider a range of first strikes (ie 1-2 first strikes). This is because I'm not sure how the game determines how many first strikes a unit will get in a particular situation. I'd be happy to send the app to anyone who knows how to work such things. I'm not terribly interested in making a "how to run a java app" tutorial and troubleshooting :)

snepp
Nov 14, 2005, 07:28 PM
Oh... perhaps I should pay attention, eh?
Just a friendly heads up is all. :lol:

Breunor
Nov 14, 2005, 07:36 PM
Arathorn,

You were amazing for Civ III and here you are again! Great stuff!

Breunor

snepp
Nov 15, 2005, 04:09 PM
Spurred on by Arathorn, another test on the HP to take into account for promotion/bonus changes.

Tank w/Combat I vs Cavalry

Initial Full Strength Combat
Tank 30.8 (28 + 10%) vs Cavalry 15.0
Damage dealt per round win: Tank 28 vs Cavalry 14
Cavalry died in 4 hits
Tank hit once for 14 (86/100 HP remaining)
Strength: 24.08/28.0

Weakened Second Combat
Tank 26.48 (24.08 + 10%) vs Cavalry 15.0
Initial Tank HP: 86/100
Damage dealt per round win: Tank 26 vs Cavalry 15
Cavalry died in 4 hits
Tank hit 3 times for 45 (41/100 HP remaining)
Strength: 11.48/28.0

Weakened Third Combat
Tank 12.62 (11.48 + 10%) vs Cavalry 15.0
Initial Tank HP: 41/100
Damage dealt per round win: Tank 18 vs Cavalry 21
Cavalry hit once for 18
Tank died in 2 hits
Strength: 0.0 - poor tank

Nothing new (or unexpected) here, time to move on. :)

Speaker
Nov 15, 2005, 11:51 PM
Very nice work Arathorn, Snepp, et al.

Any chance of writing up your "Tank w/Combat I vs. Cavalry," but change Cavalry to Spearman and show how many Spears it truly takes to knock off a tank. Post that in GD and end that discussion once and for all. The community would be much better off....

snepp
Nov 16, 2005, 04:06 AM
:lol:

It will never end. The spearman/tank debate has moved beyond calculations and realism, it has taken on a life of its own.

Short Timer
Nov 16, 2005, 12:02 PM
Nice work. What does the graph look like below 50%? Is it a 180-degree rotation around [1.00,50%] ?

Yes, the graph is symmetric around 1.00, which suggests that I managed to type in the formulas correctly. I would think that it should be symmetric based on the presumption that, all other things equal (first strikes, etc.), an attacker with a favorable R-value should have the same odds of winning an encounter as a defender in an entirely different encounter, with the same favorable R-value versus a weaker attacker. Since there are only two outcomes in an encounter, and the probability of success adds up to 100%, the odds of success will always be (A/D) 90/10, 80/20, 20/80, 10/90, etc.

Arathorn
Nov 16, 2005, 02:52 PM
First two posts updated. Just trying to clean things up before doing the collateral damage.

To answer an earlier question about bonus peculiarities, I hope the following example helps....

Example: A sword (str:6) with City Raider I, II, and III is attacking a pike (str:6) defending a city. The city has a 30% defensive bonus. The attacker’s strength is just 6, but the defender’s strength is 6/(1+1.1-.3) = 3.33, for an attack ratio of 1.80. The “right” way of doing things would have a strength 12.6 unit attacking a 7.8 unit, for a ratio of 1.62. So, here, the bonus peculiarity is helping the attacker.

It's also in the "main" stuff in the first two posts, which is now well over the 20K character limit. A number of clarifications, clean-ups, and such were made. Most notably, additional discussion on lower hps was added.

Arathorn

Roland Johansen
Nov 16, 2005, 03:54 PM
A good example. It is clear to me now what the exact effects of the unit bonusses are (2.1/1.3 < 1.8).

I was wondering if there is actually a reason for Firaxis to create this strange way of calculating the effect of the bonusses of units. I see that it has some effects on the outcome of battles, but mostly (with small bonusses) the effects will not be too big. And it is also not exactly clear why the effects of the strange combat calculations are preferable compared to how you would expect the system to work (adding bonusses to the strengths of units instead of substracting them from the defender).

Any insight in the matter, Arathorn?

zienth
Nov 16, 2005, 05:00 PM
Question regarding first strikes. If a unit has first strikes and also is immune to first strikes, and is fighting a unit with first strikes, how many first strikes would happen?

For example, a Keshik (which has a fs) with Flanking II, which makes it immune to first strike, attacks an archer (which has a fs). Would there be no first strike because they both have 1, or would the keshik still get his first strike, since the archer's fs is negated, but the keshik's isn't?

What if the Keshik had Drill I, giving him an extra fs chance, so he might have 2 vs. the archer's 1? Would the keshik get 1 first strike (his 2 minus the archer's 1) or 2 (his 2, since the archer doesn't get his 1)?

Basically, it seems to boil down to when the immunity is applied. Does it negate the opponents first strike(s) before the relative numbers are compared (thus always giving the unit first strikes), or after the comparison (and thus only has effect of the opponent has more first strikes)?

Keith

Arathorn
Nov 16, 2005, 05:57 PM
I was wondering if there is actually a reason for Firaxis to create this strange way of calculating the effect of the bonusses of units.

Just a semi-educated guess that it's for ease in programming. This way, they can simply calculate the attack value of the unit in question and have it "stored" in memory and then go through all the defenders, looking for the highest value in the stack. As you alt-mouseover different values, the program only has to calculate the new relative defensive values.

As BomberEscort pointed out at one point, though, it wouldn't be that much harder to simply regenerate the modified attacker strength and modified defender strength for each unit in a defensive stack and pick the one with the lowest A/D value. It might take a bit more programming, but the speed is such that the user would never notice. And it would eliminate such odd things, where the listed bonuses aren't really bonuses, but negatives to the opponent. I also wouldn't be surprised if they noticed (what we've said) that it's the same thing with no other effects and didn't consider the other effects. I get the feeling mathematic sophistication is NOT one of Firaxis's strengths. Which is OK, but semi-problematic in cases like this.

Unfortunately, the hp issue and jump points don't have such "easy" programming resolutions.

@zienth: Dunno. First strike testing is on the list, but I'm still not quite completely sure how to even detect a first strike, let alone count how many rounds were that way. Anybody have good insights?

Arathorn

Roland Johansen
Nov 16, 2005, 07:21 PM
Just a semi-educated guess that it's for ease in programming. This way, they can simply calculate the attack value of the unit in question and have it "stored" in memory and then go through all the defenders, looking for the highest value in the stack. As you alt-mouseover different values, the program only has to calculate the new relative defensive values.

As BomberEscort pointed out at one point, though, it wouldn't be that much harder to simply regenerate the modified attacker strength and modified defender strength for each unit in a defensive stack and pick the one with the lowest A/D value. It might take a bit more programming, but the speed is such that the user would never notice. And it would eliminate such odd things, where the listed bonuses aren't really bonuses, but negatives to the opponent. I also wouldn't be surprised if they noticed (what we've said) that it's the same thing with no other effects and didn't consider the other effects. I get the feeling mathematic sophistication is NOT one of Firaxis's strengths. Which is OK, but semi-problematic in cases like this.

Unfortunately, the hp issue and jump points don't have such "easy" programming resolutions.

"I get the feeling mathematic sophistication is NOT one of Firaxis's strengths." That sentence actually made me laugh, although it is not really funny. It is quite possible that they do not realise that the effects of adding percentages to the attacker or subtracting them from the defender are not the same thing. Probably 95% of the worlds population wouldn't realise the difference. Most people aren't mathematical sophisticated. Which is OK (as you say), but indeed problematic if you're a programmer of a game in which mathematical formulas dominate gameplay.

The jump points were something that I immediately realised when I looked at my first combat log (although I of course didn't calculate the exact jump point values which are very good to know). The hp issue (you mean that a unit has decreased strength and hps when it is wounded) just means that units decrease in strength quadratically. If that is a good thing or not is more a philosophical discussion.

Although all these combat specifics are helpful to know, I don't think they will influence the game of the average player. But knowledge of these formulas is probably beneficial for a player who wants to compete at the highest levels.

@zienth: Dunno. First strike testing is on the list, but I'm still not quite completely sure how to even detect a first strike, let alone count how many rounds were that way. Anybody have good insights?

Arathorn

I would like to know how the actual knowledge of the first strike (which is written down in the first posts) is discovered. When looking at the naming of the 'first strike' and the 'chance of a first strike', I would expect the "first strike' to always do damage (independent of actual unit strength but damage amount dependent on A/D) and the 'chance of first strike' to do damage sometimes (dependent on A/D to hit and damage dependent on A/D). If this was true than it would be easy to test by taking a unit of great strength and attacking it with a very weak unit that has a 'first strike' and a weak unit that has a 'chance of first strike'. The first unit should do a light amount of damage, the second one shouldn't.

But the above is inconsistent with the knowledge of the first posts. How was this knowledge acquired?

Arathorn
Nov 17, 2005, 08:41 AM
Collateral damage section added. Experience points section added. (both to the first post) A couple more minor corrections made.

The information on first strike comes from the DeepO/Solver article. It should be re-verified, because it may be inaccurate, like much of the rest of their descriptions. I think first strike stuff is now on the top of my list. But probably, I won't work on it all until next week -- the next few days are busy (unless snepp starts providing me with data... :))

Arathorn

Roland Johansen
Nov 17, 2005, 05:29 PM
The collateral damage section is very interesting.

Just an example: If a catapult would attack a stack of 6 full health catapults than it would do 5*10 = 50 hps of collateral damage. That is not huge, but weakening strong units to a level below the strength of your attacking units is very important as you have shown in the jump point analysis. And the catapult (and other siege weapons) can weaken a whole stack of units to a strength level below your attacking units. That is the strength of the siege units, correct? (of course next to weakening defensive bonusses) I'm asking this just to get a feeling for the units as I've not fought a lot of battles yet.

snepp
Nov 17, 2005, 08:06 PM
Nice work on the collateral damage. I still haven't looked at it myself and probably won't, choosing instead to assume everything is accurate. :lol:

I'm not sure of the best (or could say easiest) way to test first strikes, with the combat log not distinguishing between first strikes and normal rounds.

For the time being, here's a couple combat logs to chew on that I found quite interesting, not for the result, but for the start....

Archer Attack 3.0 vs Archer Defend 3.0
Both have Drill I, II, III, and IV, giving them 4-7 first strikes each.

D hit for 20 (100/100)
D hit for 20 (100/100)
D hit for 20 (80/100)
D hit for 20 (60/100)
A hit for 20 (80/100)
A hit for 20 (60/100)
D hit for 20 (40/100)
D hit for 20 (20/100)
A hit for 20 (40/100)
A hit for 20 (20/100)
D hit for 20 (0/100)

2nd test, same conditions...

D hit for 20 (100/100)
D hit for 20 (100/100)
D hit for 20 (80/100)
A hit for 20 (80/100)
D hit for 20 (60/100)
D hit for 20 (40/100)
D hit for 20 (20/100)
A hit for 20 (60/100)
A hit for 20 (40/100)
A hit for 20 (20/100)
A hit for 20 (0/100)

Speaker
Nov 17, 2005, 09:28 PM
Here is a pictoral sequence which describes the power of upgrades and bonuses.

http://www.civfanatics.net/uploads10/Speaker_-_Combat12.jpg

http://www.civfanatics.net/uploads10/Speaker_-_Combat22.jpg

http://www.civfanatics.net/uploads10/Speaker_-_Combat32.jpg

meowsqueak
Nov 17, 2005, 10:18 PM
Will all doubt about these things be removed when the SDK is released? Or is the combat mechanism implemented in closed code? That would be a pity.

Luhh
Nov 18, 2005, 02:49 AM
Are you sure collateral damage is only dealt on offense? That would make machine gun unit useless, and I think I've suffered collateral damage when attacking artillery/catapults from a stack of my own.

snepp
Nov 18, 2005, 03:08 AM
Yes, collateral is on offense only.

Arathorn
Nov 18, 2005, 08:59 AM
Will all doubt about these things be removed when the SDK is released? Or is the combat mechanism implemented in closed code?

I dunno. But I'd wager the combat mechanisms could be changed fairly easily once the SDK is released. Finding out what it does might be harder than writing a new one from scratch, honestly.

Are you sure collateral damage is only dealt on offense?

Like snepp said, Yes. It's 100% certain. Attackers are always a single unit anyway, in calculations at least.

For the time being, here's a couple combat logs to chew on that I found quite interesting, not for the result, but for the start....

Definitely interesting. I'm going to tentatively interpret those as defender first-strike rounds that "missed". That is, the defender had a first-strike advantage, but the attacker had the combat round roll go in his favor. That would mean.... We should be able to determine the number of first strike rounds an attacker has if the defender is a TON stronger, in general, because we'll get a bunch of "A hit for 30 hps (100/100)" messages. (if I'm right)

(1) An archer with all the drill promotions vs. a mech infantry (for example, a HIGH strength unit with no first strikes) would be a good set of info to have full combat results on. It might help determine the 4-7 thing. The more results, the better.

(2) An archer with an exact number of first strikes (2, I think, from drill I and drill II? I need to learn my promotions better) against a mech infantry (again, e.g.) should help nail down whether the DeepO/Solver article is right on how first strike rounds work. A consistent set of "2 rounds of D wins but A takes no damage" would be pretty convincing. A single counterexample would also be good, as it would disprove at least one theory.

(3) Some kind of "immune to first strike" unit with first strikes and with a combat disadvantage (like horse archer vs. a modern armor, if I recall my units correctly) might help us determine how immunity and first strikes work. If the horse archer consistently gets a first strike, that would mean one thing and if it didn't, it would mean another. Drill promotions for both sides would also potentially yield interesting information.

With all of those, full combat logs would be required to determine what's going on. But at least we have a shot at determining first strikes from combat logs! That's something. If my theory is wrong, well, there's SOMEthing to be gleaned from what's going on.

Any chance of getting some more tests run, snepp?

We're getting there.
Arathorn

Vol
Nov 18, 2005, 01:44 PM
Wow. Fascinating stuff with the collateral damage and keeping HPs.

So doing collateral damage has a cubic effect on the probability of victory! By lowering the combat strength of the unit and lowering its HPs, three seperate "multipliers" are affected. Firstly, it takes less damage to kill the unit. Secondly, you do more damage per round. Thirdly, you are more likely to win each round. What an incredible combination, none of which is obvious from the in-game combat odds pop-up.

snepp
Nov 18, 2005, 08:23 PM
Definitely interesting. I'm going to tentatively interpret those as defender first-strike rounds that "missed". That is, the defender had a first-strike advantage, but the attacker had the combat round roll go in his favor. That would mean.... We should be able to determine the number of first strike rounds an attacker has if the defender is a TON stronger, in general, because we'll get a bunch of "A hit for 30 hps (100/100)" messages. (if I'm right) That's a bit different than what I had decided to interpret them as (100% pure unbridled speculation), that they represented both the attacker and defender hitting with a first strike at the same time, thus negating any damage. I observed the same thing happening with other first strike combinations, Archer vs Archer (1 first strike per) and Archer vs Archer (drill 2 and 4, giving 4 first strikes per). Though after looking at it a bit more this seems unlikely, as they always appeared as the first or second entry in the log. If it did work this way, you'd think the situation would arise where there was a mutual hit, a one way hit, then another mutual hit, but I never saw one.

Hypothetical Example:
D hit for 20 (100/100)
D hit for 20 (80/100)
D hit for 20 (80/100)

(1) (2) (3)
With all of those, full combat logs would be required to determine what's going on. But at least we have a shot at determining first strikes from combat logs! That's something. If my theory is wrong, well, there's SOMEthing to be gleaned from what's going on.

Any chance of getting some more tests run, snepp? I think I can spare a bit of time. Was tempted to get into it last night, but *gasp* actually played a game last night. My first experience using Praetorians, I was not a friendly neighbor. :lol:

Heroes
Nov 18, 2005, 08:54 PM
Wow. Fascinating stuff with the collateral damage and keeping HPs.

So doing collateral damage has a cubic effect on the probability of victory! By lowering the combat strength of the unit and lowering its HPs, three seperate "multipliers" are affected. Firstly, it takes less damage to kill the unit. Secondly, you do more damage per round. Thirdly, you are more likely to win each round. What an incredible combination, none of which is obvious from the in-game combat odds pop-up.

I am not sure here, because Arathorn says: "Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat." So, to kill an injured unit still needs knocking down 100 HP?

snepp
Nov 18, 2005, 09:46 PM
I am not sure here, because Arathorn says: "Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat." So, to kill an injured unit still needs knocking down 100 HP?
That was part of his initial article, I'm sure he simply overlooked it when making corrections/additions, as we've discussed the effects of HPs since that time.

snepp
Nov 18, 2005, 11:32 PM
More stuff...

All combat screens available HERE (http://sio.midco.net/snepp/civ4/firststrike/)

Test 2: Tank vs Archer, Drill 1-4 (4-7 FS)

Test 3: Archer, Drill 1-4 (4-7 FS) vs Tank

Test 4: Tank vs Archer, Drill 2 & 4 (4 FS)

Test 5: Tank, Flanking 2 (immune to FS) vs Archer, Drill 2 & 4 (4 FS)
http://sio.midco.net/snepp/civ4/firststrike/test5.jpg

Test 6: Tank, Drill 2 & 4 (4 FS) vs Archer, Drill 2 & 4, Flanking 2 (4 FS, immune to FS)
http://sio.midco.net/snepp/civ4/firststrike/test6.jpg

Test 7: Tank, Drill 2 (1 FS) vs Archer, Drill 2 & 4 (4 FS)
http://sio.midco.net/snepp/civ4/firststrike/test7.jpg

Mujadaddy
Nov 19, 2005, 12:03 AM
So what you're saying is First Strikes are only important when Strengths are relatively equal?

eg577
Nov 19, 2005, 04:56 AM
I'm a little confused about the way hitpoints are handled. A damaged unit will have a lower strength which adversely affects R, AND suffers from having less hitpoints to kill it?

I'm sure you guys are already aware, but you can changes things in XML to make data collection easier. For example, making some promotion give 100 first strikes would be an easy way to test the "Flanking 2 Keshik vs Archer" question in one go.

Luhh
Nov 19, 2005, 06:57 AM
No. First strikes are a lot better when you are stronger than your opponent by a large margin.

The effects are very small when you are a little bit weaker, and also not big when you are only a little big stronger.

In those cases you'd be much better off upgrading other things than drill.

Edit: A good example where first strikes are very bad compared to strength upgrade is naval units.

Arathorn
Nov 19, 2005, 09:49 AM
A damaged unit will have a lower strength which adversely affects R, AND suffers from having less hitpoints to kill it?

Yes. Injured units are significantly weaker than fully-healthy ones.

@snepp:
Thanks. I've started looking through those results. Most of them seem to make a lot of sense to me. I think there are some theories I can disprove from the data. The one that really confuses me is set 7. Are you certain all your tanks were upgraded to Drill 2 in that set? My quick glance through makes me wonder. It's very confusing in light of all the other data. I *think* my theories from before are mostly supported by the data, but set 7 doesn't fit my notions.

I'll be looking through them more later and writing up my thoughts on a theory. Mostly it's what I said before, though. Thanks for all the data! And if you could reverify set 7, I'd hugely appreciate it!

Arathorn

BomberEscort
Nov 19, 2005, 10:33 AM
...Example: A modern armor (str:40) attacks a spear (str:4). If the modern armor wins (odds: 99.999999+%), it gains 1 xp, not 0 (floor(4*4/40)). If the spear wins (odds: 6e^-13), it would gain 20 xp (floor(2*40/4)).

(continued in next post)
Arathorn

Just a minor note, I don't know if this is testable since simulating a battle where a spearman defeats a moden armor is unlikely. I noticed in GlobalDefines.xml the maximum XP for any encounter is capped at 10. (see MAX_EXPERIENCE_PER_COMBAT tag). If this is the case, then this penalizes the weaker unit, but since they would almost never win this battle. All is well.

But, if you get max experience, even for damaged units, then this is a gameplay balance issue. On a sidenote, maybe this has been covered, I didn't notice, but does the Spear in the case above get the 20 XP (or 10XP if the cap is in effect) from defeating a severely damaged Modern Armor (reduced to 4 STR for instance)? I have not found a way to simulate damaged units in WorldBuilder...

Arathorn
Nov 19, 2005, 01:31 PM
I noticed in GlobalDefines.xml the maximum XP for any encounter is capped at 10.

Hmm....no, that had not actually been tested. Winning an upset of that size is impossible with normal testing time, of course, but....I think I might be able to set up a big enough upset to get "11" xps and see if it works...I'll check into it. Thanks.

XPs are culculated by relative strength at the beginning of the battle -- NOT from pure potential strength. So, the spear defeating a Modern Armor with 10 hps (strength 4) would only get 4 xps on the attack and 2 on the defense. It's hard to get a ton of xp fast.

Arathorn

snepp
Nov 19, 2005, 09:39 PM
The one that really confuses me is set 7. Are you certain all your tanks were upgraded to Drill 2 in that set? My quick glance through makes me wonder. It's very confusing in light of all the other data. I *think* my theories from before are mostly supported by the data, but set 7 doesn't fit my notions.

Can't be 100% certain and it wouldn't be the first time that a click in the world builder didn't register. I'll run that set again, in bulk, making use of eg577's suggestion to edit the xml to speed things up.

snepp
Nov 20, 2005, 12:13 AM
Test 7, part deux, in bulk...

Gyathaar, you're a lifesaver!
http://forums.civfanatics.com/showthread.php?t=141769

Results: http://sio.midco.net/snepp/civ4/firststrike/test7.zip

Celebithil
Nov 21, 2005, 10:43 AM
It is quite fascinating to see the complications of the intricacies of the combat system of Civ 4. I immediately put it to good use in my second game (especially the bit about jump points).

This might be more suited for modders, but I might have a "simple" solution to remove the jump points (which I think are undesirable, I want units which are almost as strong to have about 50% change of winning, not more than 60% vs. less than 40%). Instead of units doing a fixed amount of damage one could randomize this using an appropriate distribution. The one that springs to mind is that the damage given is decided according to a Poisson distribution with parameter 20*(3R+1)/(3+R) (so on average as much damage is done as is now.) I did some calculations and indeed the winning probabilities are a continuous version of the function with jump points as it is now, see the graph below.

As for testing whether there is a cap of 10xp gained per battle you could make a 1 strength unit fight a very wounded (1 hp left) 275 strength unit. Chances are pretty good he wins, and should get 11 xp. Of course you should first mod those units in ;) .

Aminor
Nov 21, 2005, 10:17 PM
I like the smooth curve *far* better than the present system and would suggest you try to bring it to Firaxis attention. The proposed curve also seems to be slightly less severe for the higher ratios which is fine by me. While I have been following this thread with great interest I didn't realize that ~equal opponents was a 60:40 advantage for the attacker? But I already know a re-reading of this thread would be helpful.

EDIT: I assume this revised formula also has 'nice' behavior for the <1.00 ratios as well?

As for testing whether there is a cap of 10xp gained per battle you could make a 1 strength unit fight a very wounded (1 hp left) 275 strength unit. Chances are pretty good he wins, and should get 11 xp. Of course you should first mod those units in ;) .

If I recall correctly, somewhere up in this thread or a thread nearby on XP there was mention that XP is based on the adjusted strength of the opponent. But this ought to be relatively easy to test in the world builder and this might be more appropriate to explore than starting a new game tonight.

Of course, both also sounds like a fine idea other than the sleep impact. ;)

Celebithil
Nov 22, 2005, 02:04 AM
The point of the XP testing based on a very wounded very high strength unit is that the adjusted strength does determine the chance to hit and the damage done, but is still relatively too high as a measure of the real strength of a unit, as it doesn't show how much damage needs to be done to the unit to kill it. Hence the adjusted strength of a 1 hp 275 str. unit is 2.75, whereas the chance it wins is much less than that of a full health 2.75 strength unit. Since the minimum damage done per hit is 6, you can probably just take a 6 hp 45 5/6 str unit to achieve the same goal (and then maybe you don't need to create new units).

The curve for R<1 in the smoothed curve is just as smooth, as the winning probability P satisfies P(1/R)=1-P(R), and hence a sort of symmetry around R=1 (as does, by the way, the original curve). I, too, noticed that weaker units have more change against stronger opponents. At first I thought it was some rounding effect (also due to the fact that before the jump point at 47/19 (where the weaker unit goes from 13 damage to 12 damage) the two curves are again equal. However now I believe that part of it is also determined by the fact that it is more probable for weak units to be lucky in hitting and requiring one hit less than it is for them to hit one extra time.

I also hope that this curve will remove the strange optimal order-of-attack dependence on the health of units you attack with, as was acutely noted by Arathorn. I also wonder what it does to the "first strike or combat 1" debate. I have got to do some calculations on that to be sure though.

LeSphinx
Nov 22, 2005, 03:32 AM
Hello warmongers!! ;)

As I'm a culture warmonger, I do not read not very much articles. But I read this threat and I learn news tips and things. It's interresting.

Here are the excellent threat about cultural/building's mongers!

http://forums.civfanatics.com/showthread.php?t=141825

http://forums.civfanatics.com/showthread.php?t=138647

Let read it and share our different experience of the game!!!! :rolleyes:

LeSphinx

Luhh
Nov 22, 2005, 05:20 AM
Hello warmongers!! ;)

As I'm a culture warmonger, I do not read not very much articles. But I read this threat and I learn news tips and things. It's interresting.

Here are the excellent threat about cultural/building's mongers!

http://forums.civfanatics.com/showthread.php?t=141825

http://forums.civfanatics.com/showthread.php?t=138647

Let read it and share our different experience of the game!!!! :rolleyes:

LeSphinx
GW on being off topic. Also, it's not nice to threaten people. :rolleyes:

Yeah, I kind of wonder how firaxis could have missed how their own combat system work, like the erroneously calculated combat odds regarding damaged units. It would really help to preserve your veterans if this was calculated correctly.

Also, I dislike that my modern armors so often are the ones defending against gunships instead of the mechanized infantry in the stack. Perhaps they do sometimes have a marginally higher strength, because of more experience, but that should be a reason why the computer should NOT use them for defence. They are an offensive units, and used defensively is just plain waste. I would like to see better use of this, or preference settings. If for instance there were 2 equally strong units or one marginally stronger, but the other had the hill defense or city defense upgrade, it could perhaps have a higher priority because of this? Not necessary, just a thought, and some peculiarities regarding always strongest units now that they only have one strength value.

Also, are you guys sure that experience is based on combat odds only? Because I think I've seen combat instances where the odds were similar, but one unit reveived more experience than the other victorious unit (both on offense) because it received more injury in the fight. Unless I'm mistaken here there seem to be a factor of damage received in experience as well. Most unfair fight in my games so far - level 6 modern armor at strength 48 against a catapult at 0.3 strength. :D

LeSphinx
Nov 22, 2005, 06:10 AM
Sorry Luhh if you think I was not nice.
I was not my intention. Just a little humor!

all the thread are very interessting.
As I only completely read the threat according to information of culture, building, wonders, opening strategy... and so on. I never read war thread...
except today, and I learn a lot reading this thread.
So maybe some people in contrary only read war thread and missed something elsewhere...

Happy civing!!
LeSphinx

Beamup
Nov 22, 2005, 09:47 AM
Yeah, I kind of wonder how firaxis could have missed how their own combat system work, like the erroneously calculated combat odds regarding damaged units. It would really help to preserve your veterans if this was calculated correctly.
They're correctly calculated. They just aren't the combat odds.

Arathorn
Nov 22, 2005, 10:32 AM
Interesting chart on the Poisson data, Celebethil. That seems much more intuitive to me. Interesting how it seems to give lower odds for those high-odd attacks. Something I can think about while driving across Illinois tomorrow.

So, here's what I have gleaned from snepp's first strike tests....

Test 2:
You CAN see first strike misses when the first striker is defending. They show as "Defender is hit for x dmg (orig_hps/100)". x is apparently just the last damage it had calculated (more testing could confirm this, I believe). My guess is that if the non-first-striker wins, the "damage" module is just never called, so that the damage value is never updated and so the old damage value is just displayed out to the combat log.
And 4-7 appears to mean 4-7. The number of first strikes was 5/6, 6, 4/5/6, 4, 5, 5. Never 7. The /s indicate that it couldn't be determined from the log (because the archer hit). Diminishing chances of each successive first-strike hitting? Fixed chance? We can rule out a hypothesis that "A failed first strike means no more first strikes" or that "A successful first strike means no more first strikes" or any hard and fast rules like that. Softer, odds-changing rules can't be, of course.

Test 3:
I can conclude nothing, for certain. Do attackers not get first strikes? That's possible, but then an archer hit first in all 6 cases, which is definitely against the odds. Are attacking first strikes not displayed? That could well be, as the distribution isn't too out-of-whack for what we might expect if the archer is getting 4-7 first strikes and only the hits are displayed. Does the attacker with a first_strike advantage just get one guaranteed first strike hit? Again, not ruled out by the data. A larger sample of something like test 3 would be good -- maybe with 4 fixed first_strikes with drill 2 and 4 or something (but see comments on test 7). It might help clarify some of these cases.

Test 4:
Exactly what I would expect after test 2. The defender has exactly 4 first strike rounds (successful or not telling whether the damage is actually updated/accrued or not).

Tests 5 and 6:
Immune to first strikes puts the opponent's first strikes value down to 0. The unit with immunity still gets its total number of first strikes. A unit with one first strike and immune to first strike facing a unit with 100 first strikes would still get one first strike and the opponent zero. That seems pretty well determined.

Test 7:
I would expect the archer to always get 3 first strike rounds. That would follow the DeepO/Solver article. BUT it's not the case. Sometimes the archer gets 4 first strike rounds. Sometimes 3. It doesn't appear to be the archer gets 4 first strikes then the tank 1 (although that's hard to eliminate) because of results like...
Snepp's Tank (28.00) vs Bismarck's Archer (3.00)
Defender Odds: 9.6%
Bismarck's Archer is hit for 47 (100/100HP)
Snepp's Tank is hit for 8 (92/100HP)
Bismarck's Archer is hit for 8 (100/100HP)
Bismarck's Archer is hit for 47 (53/100HP)
Bismarck's Archer is hit for 47 (6/100HP)
Bismarck's Archer is hit for 47 (0/100HP)
That's clearly 3 first strikes and NOT a fourth one. But other results clearly have 4 first strikes for the archer.

I just don't know what to do with test 7. I think x first_strikes against y first_strikes is very uncharted territory. That's where I'd focus our efforts. That combat-logger utility is very handy. Probably easier to test and definitely easier to read!

First step: I'd like to narrow down the attacker has first strike, the defender doesn't case. That's test 3. 20 iterations of 4 weak first strikes should be enough to make some fairly compelling arguments one way or another, I think.

After that, we can look at x vs. y in more detail. I need to think about what I would even hypothesize for that case and try to test. Any suggestions of what's going on would be greatly appreciated! I just can't even get a first feel for what's happening. I still have to wonder if snepp got Drill I and Drill II messed up or something. If I weren't so lazy and did my own testing (cough, cough), that would be the first thing I would retest -- several times.

Arathorn

Luhh
Nov 22, 2005, 11:10 AM
Sorry Luhh if you think I was not nice.
I was not my intention. Just a little humor!

all the thread are very interessting.
As I only completely read the threat according to information of culture, building, wonders, opening strategy... and so on. I never read war thread...
except today, and I learn a lot reading this thread.
So maybe some people in contrary only read war thread and missed something elsewhere...

Happy civing!!
LeSphinx
No sorry. I tried to be funny, but I realize I wasn't. :blush:

Threat - to intimidate someone with possible future repercussions if you don't get will through.

Thread - This is one.

Vol
Nov 22, 2005, 11:28 AM
Does anyone think that the "jump point" distribution of combat odds was intentional by Firaxis? It seems so flawed and unintuitive compared to the rest of the game. I genuinely think that they never stepped back and did the math, realized what the effect of all of the rounding and floor functions might do. I have to believe that smooth curve is what the designers wanted, they just failed in the implementation, and lacked time to do a full analysis like Arathorn has.

Hopefully they'll come to their senses and fix it in a patch so that the combat system is as simple and intuitive as the rest of the game.

Roland Johansen
Nov 22, 2005, 11:29 AM
Weird hypothesis: Maybe the number of first strikes aren't substracted but are also based on the chance to hit the opponent. So the tank has a 90.4% chance to get its first strike against the archer and the archer has a 9.6% chance to get its fourth first strike against the tank. But somehow the people at Firaxis screwed up and switched the percentages and the tank gets the 9.6% and the archer the 90.4% chance to get its first strike.

This weird hypothesis is based on the number of times that the archer gets 4 first strikes (close to 90,4%) and the number of times it gets 3 first strikes (close to 9.6%). It's a very weird hypothesis, I know. But the results are weird, so a weird hypothesis is in order. Of course the exact number of first strikes that the archer gets is not clearly visible.

Good luck with any further tests. :thumbsup:

DaveMcW
Nov 22, 2005, 12:04 PM
I think attacker and defender first strikes cancel out, and only the remaining ones deal damage.

Zombie69
Nov 22, 2005, 12:04 PM
Snepp's Tank (28.00) vs Bismarck's Archer (3.00)
Defender Odds: 9.6%
Bismarck's Archer is hit for 47 (100/100HP)
Snepp's Tank is hit for 8 (92/100HP)
Bismarck's Archer is hit for 8 (100/100HP)
Bismarck's Archer is hit for 47 (53/100HP)
Bismarck's Archer is hit for 47 (6/100HP)
Bismarck's Archer is hit for 47 (0/100HP)

I believe the archer is safe for the first 4 rounds and the tank is safe for the first round only. This would make sense, right? If as you say the attacker's first strikes don't show up in the log, this would explain the results shown in the post above, if we assume that the archer got the first hit. This would mean :

Round 1 : archer hits, tank uses first strike to avoid taking damage, doesn't show up in the log (like all instances where attacker uses first strike).
Round 2 : tank hits, no damage (archer's first strike).
Round 3 : archer hits.
Round 4 : tank hits, no damage (archer's first strike).

Whatever happens, tank's first strike can't work after round 1, while archer's first strike can't work after round 4.

Arathorn
Nov 22, 2005, 12:42 PM
Zombie69, thanks. That makes a certain degree of sense. It kind of corresponds to the suggestion Roland was making, too. In 90+% of the cases, the tank wins the first round and so the hit is visible. In the <10% of the cases the archer wins, the tank's first strike gives it immunity, but it's not visible (assuming our hypothesis about attacker first strikes is correct). That one does work exactly like you'd think. A combat round where neither side can be damaged is just as good as no combat round at all. And the calculation time is invisible. That should be testable fairly easily, once we are certain attackers DO get first strikes and they just don't show up unless they hit.

Welcome to CFC, too! Quite a first post! :)

@Vol: I highly doubt it was intended. Whether it gets changed in a patch or not is an open question for which I have no answer. I would like to see it changed to be more intuitive, yes. I'm not entirely convinced Poisson distributions are the way to go, but some way of smoothing the curve seems logical to me.

Arathorn

Roland Johansen
Nov 22, 2005, 01:15 PM
I agree with Zombie69 's hypothesis. It's a good explanation and clearly not on the level of intelligence of a Zombie, so I suggest taking a different name! :goodjob:

Krikkitone
Nov 22, 2005, 01:18 PM
so that basically means the "First Strikes" are merely "rounds of immunity" Which makes sense.

Vol
Nov 22, 2005, 01:32 PM
If we want Firaxis to fix the "jump points" in the resulting probabilities, we should make it easy on them by identifying exactly what needs to be done. Would just removing the floor() functions from the damage calculation make the end result smooth? I suppose fractional HPs would also have to be stored throughout the combat for that to have an effect.

Roland Johansen
Nov 22, 2005, 01:41 PM
The only way to get rid of the jump points is by making the amount of damage variable (with an average amount of damage equal to the present value).

The reason for jump points is that you need 5 hits of 20-24.999 damage to kill a unit and 4 hits of 25-33.333 damage to kill a unit. It's far more probable that a unit succesfully hits 4 times (or more) than that it succesfully hits 5 times (or more).

Zhukov
Nov 22, 2005, 01:44 PM
I really do wonder if it was intentional, because the 50%->64% jump point has a huge effect on gameplay - IMO a pretty good one too. It makes it so that he who best manages bonuses can wipe the floor with the other guy since even a .001 advantage in strength can tide the odds in your favor.

Makes war a lot more strategic - especially vs humans.

Beamup
Nov 22, 2005, 01:55 PM
The only way to get rid of the jump points is by making the amount of damage variable (with an average amount of damage equal to the present value).
There are other ways. Replacing the round-based mechanic with a differental equation-based, approximately continuous, method would be one (much more complicated, but it would do the job).

Variable damage would be the simplest route, but certainly not the only route.

Another easy approach which has its own advantages would be to recalculate R for each round, based on current HP. What makes this particularly appealing IMO is that, currently, a 100-HP Rifleman facing a 50-HP Grenadier can be completely different depending on whether the Grenadier lost those HP in this battle or the previous one. It's not entirely based, right now, on the current status of the units.

With this approach, there would still be discontinuities, but there would be a very large number of very small discontinuities instead, so they would not be important.

Roland Johansen
Nov 22, 2005, 01:57 PM
I liked this (basic) combat model presented by Krikkitone a month ago:

I Very much agree, (Ideally the way to do it would be to have each unit damage the other one in each round ie each unit hits. Give all units ~100 hit points. The amount of damage done is 20*A/(A+B) to unit B and 20*B/(A+B) to unit A... Have a coin toss (50/50) each round allowing one unit to do triple damage, and
wala, a healthy unit of strength over 3X will Never (mathematically) lose to a healthy unit of strength X, there is still randomness and the Actual combat value of units A+B are their strengths (adjusted for hp)

It's simple and produces the combat effects that I would like to see. Maybe it can be modded in Civ4, but I suspect that it might be difficult to make the AI use it correctly.

edit: maybe it is not directly clear, but there are no chances to hit in this model. But a stronger unit does more damage.

Beamup
Nov 22, 2005, 02:05 PM
Trouble is that it makes jump points even more important and greatly reduces the power of being stronger than the enemy. You're not going to have "spearman beats tank," it's true, but you'll have a LOT more "spearman badly damages tank" than the current system.

Roland Johansen
Nov 22, 2005, 02:14 PM
There are other ways. Replacing the round-based mechanic with a differental equation-based, approximately continuous, method would be one (much more complicated, but it would do the job).

The part about differential equations is a bit vague, but you're right in the general assesment that there are different ways to reach the continuous function we want to see. But every (increasing) continuous function representing the chances of victory against the ratio of attack and defense can be reached by a combat formula based on some form of variable damage. So in essence the variable damage way is the only way ;) (just joking)

Let's stop the mathematical discussion before we scare every reader away. :D

Roland Johansen
Nov 22, 2005, 02:19 PM
Trouble is that it makes jump points even more important and greatly reduces the power of being stronger than the enemy. You're not going to have "spearman beats tank," it's true, but you'll have a LOT more "spearman badly damages tank" than the current system.

What I also liked about that model (next to the stopping of spearman beats tank) is that a strength 6 unit was twice as strong as a strength 3 unit. Something that is not true in the present model. The model should be refined a little so that the damage is continuously variable. How badly a spearman damages a tank is completely dependent on the actual values you give the spearman and the tank, not the combat model.

That post (112) was not in response to your previous post (111). I can't type that much and find that post of Krikkitone in 2 minutes.

Beamup
Nov 22, 2005, 03:42 PM
That post (112) was not in response to your previous post (111). I can't type that much and find that post of Krikkitone in 2 minutes.
I realized that. I just also wanted to respond to it!

Zombie69
Nov 22, 2005, 05:16 PM
Thanks for the welcome. You can call me Zombie by the way (but that nick was taken).

I'd been reading this forum for a couple days and when i came across this, the solution struck me as obvious so i wanted to help out if i could to keep the discussion going, so i created an account.

I must say that i've liked all that i've read about this game so far. I'll definitely go out and buy it asap, probably later this week.

Do you guys think this game is playable on a 800 MHz machine, on tiny maps if necessary? RAM is not a problem and videocard should be ok. I don't feel like buying a new computer right now just for one game. Please reply by PM if you can (is there even such an option on this forum?) because i don't want to hijack this thread anymore than i already have.

Back on topic, i agree that adding a small random element would be ideal. All other strategy games i know (Warcraft, Starcraft, Heroes of Might and Magic) already have this included in their combat calculations. Plus, Civ4 combat already has some random element as well (to decide who gets a hit), so it's not like this would be sacrilege or anything like that.

snepp
Nov 22, 2005, 05:30 PM
Also, are you guys sure that experience is based on combat odds only?
Not entirely sure, no (at least I'm not :lol:). The XP testing was very quick and didn't involve combat with injured units. I'll throw this on my list of things to play with when I'm bored.

Edit: Should have linked the entire thread, not the single post.
http://forums.civfanatics.com/showthread.php?t=139534

snepp
Nov 22, 2005, 05:50 PM
That combat-logger utility is very handy. Probably easier to test and definitely easier to read!Without a doubt. Between the log dump and a modified xml file, running a few hundred (or thousand) combats can be done very quickly.

I still have to wonder if snepp got Drill I and Drill II messed up or something.Can't say for the initial tests, but where the bulk test 7 is concerned, I am 100% certain of the testing conditions as no unit modifications were made in the world builder (set in the xml, which I have a copy of).

If I weren't so lazy and did my own testing (cough, cough), that would be the first thing I would retest -- several times.Hinting at something? ;)

snepp
Nov 22, 2005, 07:08 PM
First step: I'd like to narrow down the attacker has first strike, the defender doesn't case. That's test 3. 20 iterations of 4 weak first strikes should be enough to make some fairly compelling arguments one way or another, I think.
Bulk run.... (for those curious, the archers lose all 445 combats)

Test 3: Archer, Drill 1-4 (4-7 FS) vs Tank

http://sio.midco.net/snepp/civ4/firststrike/test3.zip

Here's one interesting result:

Snepp's Archer (3.00) vs Bismarck's Tank (28.00)
Defender Odds: 90.3%
Bismarck's Tank is hit for 8 (92/100HP)
Bismarck's Tank is hit for 8 (84/100HP)
Bismarck's Tank is hit for 8 (76/100HP)
Bismarck's Tank is hit for 8 (68/100HP)
Bismarck's Tank is hit for 8 (60/100HP)
Snepp's Archer is hit for 47 (53/100HP)
Snepp's Archer is hit for 47 (6/100HP)
Snepp's Archer is hit for 47 (0/100HP)
Bismarck's Tank has defeated Snepp's Archer!

Arathorn
Nov 22, 2005, 08:58 PM
Actually, snepp, I think Zombie has explained case 7 very well. I'll go through the expanded test 3 when I have time. It will probably be next week, as the holiday weekend is pretty well filled for me. Or, it probably will be. Maybe I'll examine it at my in-laws. I dunno. Not tonight, though. :) Thanks for running them, though.

Almost makes me want to learn perl just to parse the results....

Arathorn

snepp
Nov 22, 2005, 09:12 PM
Actually, snepp, I think Zombie has explained case 7 very well.I agree, hadn't read all the way through before making my posts.

Maybe I'll examine it at my in-laws.I couldn't think of anything better to do while at the in-laws. ;)

Almost makes me want to learn perl just to parse the results....I was tempted to try a bit of parsing, but my php is so rusty it would be more trouble than it's worth. :lol:

Aminor
Nov 22, 2005, 09:26 PM
You're not going to have "spearman beats tank," it's true, but you'll have a LOT more "spearman badly damages tank" than the current system.
Well, 'badly damages' would be overstating as the functions would still yield bare scratches on the tank relative to its damage each round to the spearman. However, even these scratches accumulate and would be more substantial the present system which likes leaves the tank completely untouched through multiple spearmen encounters.

With the proposed system:
Tank does: 20 * (26/[26+4]) = 17.3 pts/round so Spearman dies in 6 rounds.
Spearman does: 20 * (4/[26+4]) = 2.6 pts/round so Tank will take 6x 2-3 (depending on rounding) so would be at 82-88% after each encounter.

This all assumed you were referring to Post #112 in your post #113. Context wasn't fully clear given the multiple discussions on the thread.

Krikkitone
Nov 23, 2005, 12:48 AM
Well, 'badly damages' would be overstating as the functions would still yield bare scratches on the tank relative to its damage each round to the spearman. However, even these scratches accumulate and would be more substantial the present system which likes leaves the tank completely untouched through multiple spearmen encounters.

With the proposed system:
Tank does: 20 * (26/[26+4]) = 17.3 pts/round so Spearman dies in 6 rounds.
Spearman does: 20 * (4/[26+4]) = 2.6 pts/round so Tank will take 6x 2-3 (depending on rounding) so would be at 82-88% after each encounter.

This all assumed you were referring to Post #112 in your post #113. Context wasn't fully clear given the multiple discussions on the thread.

Well with that proposed model you would also have to change the actual strengths, currently a tank can with stand tthe attacks of something like 20-40 spearmen (I forget the actual value) which means that to maintain the same gameplay balance, a tank under the new model would have a strength of 80-160 to a spearman of strength 4.

The current model does have one thing going for it though.
In my model, the units are really just an amalgam of total combat strength (I'd tend towards the idea of making healing cost money like upgrading... in essence rebuildng the portion of the unit that was destroyed).

The Civ IV model forces you to treat each unit as special (healing/damage is Very important) which ties in well with the promotion system.

The unclearness of the odds could Definitely be cleared up a bit though. Even a display that gave a general ranking...near even (40-60% chance), in our favor (60-80% chance), strongly in our favor (80-95%), We really should win (95%+). Also the player should know of all factors that contribute to their win loss which are

Strength ratios (already displayed well)
First Strikes+Immunity (already displayed well)
Retreat (displayed)
Collateral Damage (minimal display)
Hitpoint ratios (no display)

Uniqueuponhim
Nov 23, 2005, 09:04 AM
Something doesn't seem right with this, or I am just very unlucky.
Recently in a game I'm playing, Isabella has attacked one of my cities with 6 conquistadors. Defending the city, I had 1 pikeman with combat 1, 1 longbowman with city defense 1, and 1 maceman with combat 1. Her conquistadors all had combat 1. My city had walls, a castle, and a 20% culture bonus, and all three units were fortified.

So, her conquistadors should have an effective strength of 11.
All of my units should have as a base, 50% from wall + 50% from castle + 20% from culture + 25% from fortification, totalling 145%.
On top of that, my spearman has 100% against mounted + 10% for combat 1, totalling 255%, giving an effective strength of 21.3
My maceman has further bonuses 10% for combat 1, totalling 205%, giving an effective strength of 20.4 (not sure if the 50% vs melee applies to mounted melee units too, so I'm leaving it out)
My longbowman has further bonuses of 25% for being in city + 20% for city defense 1, totalling 190%, giving an effective strength of 17.4

Against a unit with 11 strength (isabella's conquistadors with combat 1) every one of my units does at least 25 damage, meaning they need 4 hits to win.
So, on average, my pikeman will be hit 2.06 times, for a total of 30 damage, leaving it with 70 hp, or an effective strength of 14.7, which is enough for about a 78% chance of victory against a second attack.
On average, my maceman will be hit 2.16 times, for a total of 31.9 damage, leaving it with 68.1 hp, or an effective strength of 13.9, which is enough for about a 75% chance of victory against a second attack.
Finally, my longbowman will be hit 2.53 times on average, for a total of 40.35 points of damage, leaving it with 59.65 hp, or an effective strength of 10.38, leaving it with a mere 35% chance of victory in a second attack.

So what are the chances of Isabella taking my city in one turn (as she did)? about 22% * 25% * 65%, or 3.6%... I guess I'm just really unlucky.

Roland Johansen
Nov 23, 2005, 09:29 AM
double post

Roland Johansen
Nov 23, 2005, 09:31 AM
So, her conquistadors should have an effective strength of 11.
All of my units should have as a base, 50% from wall + 50% from castle + 20% from culture + 25% from fortification, totalling 145%. On top of that, my spearman has 100% against mounted + 10% for combat 1, totalling 255%, giving an effective strength of 21.3

The defensive bonuses of walls and castles aren't added to the culture bonus. Only the best of the two bonuses applies (can be found in the civilopedia I think).

I'm not quite sure, but isn't the conquistador a gunpowder unit. Walls and castles don't work against gunpowder units (civilopedia info, not this thread).
So that leaves you with a +20% from culture, + 25% from fortification (only if your units were fortified for 5 turns or longer), + 100% against mounted +10% for combat1 totaling a +155% bonus. So your spearman is strength 4 + 155% of 4 = 10.2 strength. So you should expect to lose against the conquistador of strength 11.


My maceman has further bonuses 10% for combat 1, totalling 205%, giving an effective strength of 20.4 (not sure if the 50% vs melee applies to mounted melee units too, so I'm leaving it out)
My longbowman has further bonuses of 25% for being in city + 20% for city defense 1, totalling 190%, giving an effective strength of 17.4

The maceman has a bonus of 20% + 25% + 10% = 55% and thus is strength 8 + 55% of 8 =12.4 and slightly stronger than the conquistadors.
The longbowman has a bonus of 20% + 25% + 25% + 20% =90% and thus is strength 6 + 90% of 6 = 11.4 and is again slightly stronger than the conquistadors.

Check the combat logs, they can help you understand the combat results and you can see if you were just unlucky or really deserved to lose a combat result.



So what are the chances of Isabella taking my city in one turn (as she did)? about 22% * 25% * 65%, or 3.6%... I guess I'm just really unlucky.

You would have to be very lucky if her 6 units of about equal strength compared to your defending 3 units would not take the city in 1 turn. Even if one of your units wins a combat, then it will be weakened to such an extent that it has virtually no chance to win against the next conquistador. A unit becomes weakened in two way: its hitpoints go down meaning it can sustain less damage and its strength goes down (relative to the number or hitpoints lost) which means that it has worse chances to hit and does less damage while receiving more damage.

edit: Just read that one unit is called spearman and pikeman in your post (which are different units). If it was a pikeman then its strength would have been 6 + 155% of 6 = 15.3. You should expect it to win its first combat against a conquistador of strength 11, but it will probably be significantly weakened before the second combat. You can check how much it was weakened in the combat logs.

Arathorn
Nov 23, 2005, 10:04 AM
All of my units should have as a base, 50% from wall + 50% from castle + 20% from culture + 25% from fortification, totalling 145%.

Nope. For a city, only the higher of the man-made and cultural bonus is applied. That means only 100% bonus plus 25% fortification bonus (only if they've been fortified 5+ turns).

The conquistador also has a 50% bonus against melee units, negating much of your pike's strength and hurting your maceman a fair bit. Immunity to first strike and 2 first strikes also come with the conquistador. So, your modified strengths were really 17.1 (pike), 16.2 (longbow), and 12.8 (mace), if my math is right. That is, the pike's relative strength is 6 * (1 (base) + 1 (castle+walls) + .25 (fortification bonus) + .1 (Combat I promotion) + 1 (vs. mounted) - .5 (conquistador bonus vs. mounted)) = 6 * 2.85 = 17.1.

I tried to find the odds of the attacker winning (my program can do it, but it's VERY inefficient). It sucked up all my memory. Improvements in progress. I'm not terribly surprised by the results, though. Top of my head GUESS (yes, guess, not verified, so take with general helpings of salt) is the attacker had a 25% chance or so of winning.

Arathorn

Edit: Took me a long time to post. Conquistadors are mounted units, not gunpowder units, so the walls/castle should be effective.

Arathorn
Nov 23, 2005, 10:26 AM
OK, I think I have my combat simulator working for larger combats than a single unit -- more or less. By my calculations (still in need of a bit of verification by me), the attackers in that situation had a slightly greater than 20% chance of success. In 4.3% of the cases, all the attackers were destroyed. In the other ~75% of the cases, some attackers and some defenders were destroyed.

Change that pike to a spear and the attackers win about 25% of the time (again, unverified).

Arathorn

Beamup
Nov 23, 2005, 10:37 AM
Well, 'badly damages' would be overstating as the functions would still yield bare scratches on the tank relative to its damage each round to the spearman. However, even these scratches accumulate and would be more substantial the present system which likes leaves the tank completely untouched through multiple spearmen encounters.
The bit I bolded is actually exactly what I meant by 'badly damages.' Apparently I was unclear, sorry.

Uniqueuponhim
Nov 23, 2005, 12:57 PM
Interesting. I hadn't noticed the 50% against melee bonus the conquistadors has - doesn't that make them a little unbalanced? For pretty much every other unit, even UUs, there is always a unit to counter them - with these guys, though, it doesn't appear as if there is any unit at that tech level which has better than 35% odds against these guys on open ground.

Arathorn
Nov 23, 2005, 03:24 PM
@uniqueponhim -- war elephants. Even earlier techwise (but dependent on a semi-rare resource). That's your best option. Knights will be close to 50/50 with them. Those are the immediate options I think of off the top of my head.

Arathorn

GenericKen
Nov 23, 2005, 05:28 PM
I'm sorry, Arathorn, but parts of your article weren't clear at all.

Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat.
Seems to directly contradict
If one of the units is wounded, then the jump points situation will change. There will still be jump points, however. Those points will occur at the points when one side’s damage crosses a jump point. The jump points can be found by looking at ceiling(remaining_hps/n) where n is any number (but, in reality, only n up to 8 are very likely to be an issue). The attacker looks at the defender’s remaining hps and the defender looks at the attacker’s remaining hps.


I'm just trying to get a statistical grasp on combat. I'd appreciate it if you could answer the following points: :)

1) Is A/D = R set in stone at the begining of combat for the duration of combat, or is it recalcualted after each round, resulting in a sort of "slippery-slope"?

2) Is the current HP used in calculations to determine when a unit would die (i.e., how many hits at x damage each it could take), or is it 100 as quoted above, with HP only playing a factor in modified strength values?

3) If it's the former, could the number of round wins required to win a combat be calculated simply at the begining of combat based on the A/D ratio ( ceil(remaining hp/damage per round) )?

4) What do you mean by:
Once one side goes below 0 hps remaining, it is destroyed (or retreats). The winner has strength remaining equal to starting_strength*hps/100, but it has fewer hps, so it is more likely to die in further combat. Modified strength no longer matters.
? Does this mean that a wounded unit that is wounded further has his disadvantage compounded, or is the modified strength simply recalculated with the new hp for the next combat?


I get the sneaking feeling that the answers to the above all lean toward the intuitive, but I just wanted to be sure.


And my $0.02 on first strike: intuition would say that the extra free rounds would be more significant in shorter combat, but when walking through the math, it becomes clear that the extra rounds are easily lost in the shuffle against large odds in EACH round, especially if R is not recalculated according to hp after each round.

Arathorn
Nov 23, 2005, 05:50 PM
Yeah. That first part you quoted was in the original article and I've not gotten around to removing it yet. Maybe I should do that this weekend, since I can't actually play. :cry:

1) R is calculated at the beginning of combat and fixed in stone. On my ever-growing, rarely-shrinking list of "To do"s is to see how the "slippery slope" concept works out. I tend to think it might be awfully cool. There will still be jump points, but there will be more of them and they'll be harder to find (second order effects instead of first).

2) Current hps. A unit with 60 hps taking 20 damage will die in 3 rounds.

3) Absolutely. That's the way I do it. I suspect other combat calculators do, too.

4) Modified strength is recalculated, but the displayed strength is equal to strength * hps / 100. That bit of article should also be reworked with the revelation of not all battles starting with 100 hps.

On first strikes (I like the term "rounds of immunity"), Drill I-III promotions appear to be relatively weak, but if you can get Drill IV, it's huge and might make up for the initial weakness. I need to run more tests -- probably just mathematical models, actually, but....

HTH,
Arathorn

Aminor
Nov 23, 2005, 05:57 PM
The bit I bolded is actually exactly what I meant by 'badly damages.' Apparently I was unclear, sorry.
I am also trying to wrap my brain around the whole system. :)

EDIT: Should also add the second half of that thought which remains a little unclear in how to express. I am glad that I was at least appropriately following the discussion and that there was just a different impression of what was considered substantial damage/change. And that is one of the problems with the current system: it can be hard to determine the cost one will face when deciding to attack or whether one has prepared suitable (not too little, not too much) defense.

GenericKen
Nov 23, 2005, 06:46 PM
Thank goodness it's intuitive. That means the overall probabilities of combat are based on exponential models of modified strength and hp, and are gaussian, allowing for the application of stuff like expected value and standard deviation. At least I think so, if I remember my statistics correctly. :p

I would discourage any modder from trying to implement slipperly slope in combat by recalculating R after each round of combat. It's not computationally prohibitive or anything, but it wildly, wildly increases the variances, effectively defeating the purpose of this massive probability scheme int he first place. You'd no longer need 6 rounds of bad luck to lose your dude, but only the first 2 rounds of bad luck.

So, if I'm understanding you correctly, the following summary of Civ4 combat is accurate and sufficient:

*** Civ4 Combat in summary: ***

A = base * (1+generic mods [combat 1-4]) * (hp/100) ~ (given)
D = base * ((1+pos total mod) or 1/(1+neg total mod)) * (hp/100) ~ (given)

R = A/D

Attacker wins round with (A/(A+D)) = R/(1+R). Defender wins round with (D/(A+D)) = 1/(R+1). No ties.

Base 100 hp, enter combat with current hp. Take dmg per round.
A dmg = 20*(3A+D)/(A+3D)
D dmg = 20*(A+3D)/(3A+D)
Max 60 dmg, min 6 dmg. 20 dmg if A=D. Die on 0 hp.


First strike: First striker immune to damage during first strike combat.


Retreat: If would die (lose roll and hp death), % chance retreat instead.


Collateral: Extra 100% combat rounds w/ other units besides normal combat rounds.
Barrage only generic str mods for A. Normal mods for D. No hp str modifier for A and D. Dmg = A dmg.
Collateral min hp cap = 50-30 hp. # affected cap = 5-7. (catapult-artillery)


XP: Str Ratio, w/ modifier M = (4 attacker, 2 defender). Total XP caps for barbs (5) & animals (3).
AXP = floor(M*D/A), min 1. If win.
DXP = floor(M*A/D), min 1. If win.

eg577
Nov 23, 2005, 07:20 PM
For first strike testing, which I gather is not easy to find the probabilities, how about modding the xml to give archers 100% retreat chance? Assuming archers don't retreat during their own first strike round (hmm, what a funny image that would be) then this would get rid of all that junk data of regular combat rounds.

snepp
Nov 23, 2005, 07:55 PM
For first strike testing, which I gather is not easy to find the probabilities, how about modding the xml to give archers 100% retreat chance? Assuming archers don't retreat during their own first strike round (hmm, what a funny image that would be) then this would get rid of all that junk data of regular combat rounds.

Hmmm, excellent idea. Maybe work in a second modified unit that could "potentially" kill the archer in one hit?

Zombie69
Nov 23, 2005, 09:44 PM
You don't need to modify the other unit to do this. Just modify the archer, giving him 1 HP (or whatever amount the other unit could take away in one hit) and increase his strength to compensate.

But what are you trying to test really? Don't we already have first strike figured out?

rkyte
Nov 24, 2005, 01:51 AM
A couple of people mentioned that the game may round numbers when doing calculations. I think all calculations are done to full precision.

I found this code in the CvMainInterface.py file:
if (pHeadSelectedUnit.isHurt()):
szRightBuffer = u"%.1f/%d%c" %
(((float(pHeadSelectedUnit.baseCombatStr() * pHeadSelectedUnit.currHitPoints())) /
(float(pHeadSelectedUnit.maxHitPoints()))), pHeadSelectedUnit.baseCombatStr(),
CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR))
It does the full calculation (pHeadSelectedUnit.baseCombatStr() * pHeadSelectedUnit.currHitPoints() / pHeadSelectedUnit.maxHitPoints()) and then only the display is truncated to one decimal place. (u"%.1f/%d%c")

GenericKen
Nov 24, 2005, 11:28 AM
I don't think so rkyte. That's just the script for the display, not for the actual combat.

Burebista
Nov 24, 2005, 11:41 AM
On first strikes (I like the term "rounds of immunity"), Drill I-III promotions appear to be relatively weak, but if you can get Drill IV, it's huge and might make up for the initial weakness. I need to run more tests -- probably just mathematical models, actually, but....


If first strikes are rounds of immunity, then for the case when both the attacker and the defender have x and y first strikes respectively, this new theory is equivalent to the old x-y theory. Am I missing something?
However, I think eg577's suggestion to give the archer unit 100% retreat chances is a good way to do further testing.

The second question is how the system works when there is a range of first strikes. Is the number of first strikes for that unit selected using a uniform distribution, or the relative strength of the units is taken into account?

rkyte
Nov 24, 2005, 08:37 PM
I don't think so rkyte. That's just the script for the display, not for the actual combat.
Yes, but people were using the numbers this script displays in their calculations. The point is that they would do similar calculations everywhere. The game stores the exact number of hit points for each unit. Why would it also be storing some arbitrarily truncated strength number? It isn't. It's using the above formula.

Zombie69
Nov 25, 2005, 10:51 AM
If first strikes are rounds of immunity, then for the case when both the attacker and the defender have x and y first strikes respectively, this new theory is equivalent to the old x-y theory. Am I missing something?

The end result is the same, but not the display.

BomberEscort
Nov 26, 2005, 09:55 PM
Reference Material for the next post

For each 10% strength increase over an adversary

00% - 50% chance of victory
10% - 68% chance of victory (Combat I)
20% - 73% chance of victory (Combat II)
30% - 77% chance of victory (Combat III)
40% - 88% chance of victory (Combat IV)
50% - 90% chance of victory (Combat V)
100% - 99% chance of victory


For each Drill Promotion against an equal adversary without promotions
FSC - First Strike Chance; FS - First Strike, C1 - Combat I (Free for agressive civs)

Drill I -- 1 FSC - 53.4% chance of victory
Drill I -- 1FS, 1 FSC - 60.2% chance of victory
Drill I -- 2FS, 1 FSC - 67.1% chance of victory
Drill I -- C1, 1FSC - 73.8% chance of victory
Drill I -- C1, 1FS, 1 FSC - 77.2% chance of victory
Drill I -- C1, 2FS, 1 FSC - 82.5% chance of victory
---------
Drill II -- 1FS, 1 FSC - 60.2% chance of victory
Drill II -- 2FS, 1 FSC - 67.1% chance of victory
Drill II -- 3FS, 1 FSC - 70.3% chance of victory
Drill II -- C1, 1FS, 1FSC - 77.2% chance of victory
Drill II -- C1, 2FS, 1 FSC - 82.5% chance of victory
Drill II -- C1, 3FS, 1 FSC - 83.9% chance of victory
---------
Drill III -- 1FS, 3 FSC - 67.0% chance of victory
Drill III -- 2FS, 3 FSC - 73.9% chance of victory
Drill III -- 3FS, 3 FSC - 76.7% chance of victory
Drill III -- C1, 1FS, 3FSC - 84.0% chance of victory
Drill III -- C1, 2FS, 3 FSC - 89.3% chance of victory
Drill III -- C1, 3FS, 3 FSC - 90.7% chance of victory
---------
Drill IV -- 3FS, 3 FSC - 76.7% chance of victory
Drill IV -- 4FS, 3 FSC - 80.7% chance of victory
Drill IV -- 5FS, 3 FSC - 83.5% chance of victory
Drill IV -- C1, 3FS, 3FSC - 90.7% chance of victory
Drill IV -- C1, 4FS, 3 FSC - 96.1% chance of victory
Drill IV -- C1, 5FS, 3 FSC - 97.5% chance of victory

BomberEscort
Nov 27, 2005, 02:27 AM
Ran a simulation of 301 Japanese Samurai (Combat I, 50% vs Melee, 2 First Strikes) vs 301 Mongolian Macemen (Combat I, 50% vs Melee). Samurai on the offense (43 stacks of 7 each).

Odds were 8.8 vs 8.8 (according to Civ's calculations).

The results were Samurai 175 Wins 126 Losses (58.1% Victory). 2 First Strikes give a small advantage when fighting a unit of equal strength (according to this data)

An 8.1% advantage doesn't seems to follow what I would mentally calculate...

On average 2 First Strikes will damage a unit of equal strength 20 HP (0, 20, or 40hp of damage being the possibilites, and assuming first strikes are calculated like regular rounds, in this case each having a 50% chance to hit and the total strength at the beginning of the battle used throughout the calculation, unlike Defensive Bombard in Civ III).

From http://c4combat.narod.ru/c4c_v0_13.htm I get 63.67% chance to win for the Samurai. 1 standard deviation = 60.898% to 66.441%, 2 sd = 58.127% to 69.212%. We are at the 2sd/3sd boundary with our data, about a 0.3% chance of happening (assuming the maths are correct in the calculator, which I think they are). Either the data are an extreme case (someone else can do this test again and compare notes) and both the calculator and first strikes are functioning properly, the combat calculator noted above is wrong and first strikes are working properly, or the calculator is correct and first strikes are not working properly.

Assuming the calculator is wrong, the new value for victory is 58.1% which gives us a s.d. of 2.84%. 68% of the time, the samurai will win 55.26% to 60.94%. If the next test is within this range (giving us 602 sample cases), it will confirm that first strikes are indeed broken or that there is some information of how they function that we do not know...

... A couple of hours later

Tested 497 more battles. For these the Samurai won 326 out of 497 (65.59%). Total for all battles is 501/798 = 62.782%. Close enough to call it good.
First Strike appears to be working properly and gives an overall ~ +7% (6.835%) chance of victory for EQUAL strength units
(62.782 - 50)/2 First Strikes = 6.391% per first strike in this simulation.

Tested 1,050 battles of Samurai vs American Knight (Immune FS) -- (Odds show as 8.8 v 10.0)
Combat Calculator above figures odds at 30.133% victory for Samurai
Actual Testing: 346 Wins, 704 Losses = 32.952% victory for Samurai
Immune to First Strike appears to be working properly

Tested 1,120 battles of Samurai vs Mongolian Maceman -- (Odds show as 8.8 v 8.8)
Samurai has 0-10 first strike chances, Combat I; Maceman has Combat I
Combat Calculator above does not figure odds
Actual Testing: 857 Wins, 263 Losses = 76.52% victory for Samurai
--------
Using an 8.8 vs 8.8 battle as 50% victory. We can work backwards and calculate that each First Strike Chance has a (76.52 - 50)/10 percent chance of increasing victory (2.7% increase per chance). This is not that far off from my estimate of 3.5% for each FSC (see below). The difference could be that not all FSCs above 7 had a chance to hit since there were in most cases 7 Samurai vs 7 Macemen. If we factor this in, and divide by 7 instead of 10 we get 3.79% which is very close to the estimate of 3.5%
Each First Strike Chance gives an overall +3.5% chance of victory for EQUAL strength units assuming FSC are 1/2 as likely as FS.

In conclusion, as I believe has been confirmed elsewhere, First Strikes work the best when the units are closest in strengths with the optimal configuration being equal in strength. For equal strength (this will be its best case), each First Strike equals approximately 7% increase in the chance for victory (3.5% for first strike chances). In all cases I would go for the Combat upgrades as they give you the full 10% strength bonus (18% increase in the chance for victory for same strength adversaries) against all units (that 7% for first strike will fall dramatically as the strength between units differ).

To make first strikes more attractive, the developers or modders, could remove first strike chances from Drill and have only first strikes. Still weaker than the combat promotion option, but better than it is now (something along the lines of Drill I thru IV - 1 FS and a 4% combat bonus for each; this would have to be tweaked to make sure FS's are not lethal, allowing for at least one round of normal combat) Making first strikes always hit would make them too powerful. As a sidenote, in my mod I have Drill modded as above (Drill requires disipline, at least that is what my drill instructors told me :) , and disipline makes a better soldier)

I think a balanced solution is to have every first strike (not first strike chance) give full damage when it hits and half damage when it misses (to simulate the element of surprise). Instead of a first strike for equal unit strengths dealing of average 10 hp of damage (0hp for miss or 20hp for a hit), they would average 15 hp (+10.5% chance to win) of damage for each strike (10hp - 20hp).

Also, make each first strike chance 50/50 for equal strength units (decide ratio by a normal battle round calculation). Then if you have an available chance, calculate the same as above, if the chance fails no damage is done. So each first strike chance on average (against equal strength units) would be 0hp for a missed chance, 10hp for a successful chance that misses (first strike), 20hp for a successful chance that hits (first strike). Averaging 7.5 hp (+5.25% chance to win) of damage for each first strike chance.

As it stands currently, the Japanese Samurai and the Chinese Chokonu have 2 first strikes available, the most of all units before upgrades. This gives the Samurai an equivalent strength rating of 9.92 (8 + 24%; Combat I and 2 First Strikes) verses other strength 8 units. A Samurai that uses it next four promotions for Drill I-IV will have an equivalent strength rating of 12.64 (8 + 58%; Combat I, 5 First Strikes, 3 First Strike Chances). A Samurai that uses it next four promotions for Combat II-V will have an equivalent strength rating of 13.12 (8 + 64%; Combat I - IV and 2 First Strikes).

Under the proposed balanced system above, a Samurai that uses it next four promotions for Drill I-IV will have an equivalent strength rating of 14.26 (8 + 78.25%; Combat I, 5 First Strikes, 3 First Strike Chances) instead of 13.12 with Combat promotions.

As the system currently is, it works out similarly for an American Maceman for instance. A maceman that uses it next four promotions for Drill I-IV will have an equivalent strength rating of 10.52 (8 + 31.5%; 3 First Strikes, 3 First Strike Chances) as opposed to 11.2 (8 + 40%; Combat I-IV)

Under the proposed system, a maceman that uses it next four promotions for Drill I-IV will have an equivalent strength rating of 11.78 (8 + 47.25%; 3 First Strikes, 3 First Strike Chances) as opposed to 11.2. This creates a choice, do I go for the long term benefit of the combat promotions or do I need the higher bonuses now, because I am fighting units of equal strength. This proposed system increases the benefit of Drill for units that initially have 1-2 first strikes also.

The modifications above would not be unbalancing because as strength differs, the value of first strikes decline, only being valuable when strength are near equal. As it stands now, first strikes are good if they are given away as freebies (obviously), but they are not worth the selection in promotions regardless of the fact that your unit may have 0-2 first strikes given to it. Drill over Combat promotion cannot be justified under any circumstances currently (v1.09). Stick with the Combat promotions over Drill , unless something changes in the next patch.

Enkidu_Warrior
Nov 27, 2005, 05:47 AM
Something else I like about your suggestion, BomberEscort, is that the standard combat promotions open up many other possibilities. So sacrificing a bit of strength (ie not picking drill) to open up that flexibility seems only fair.

ew

Luhh
Nov 27, 2005, 03:58 PM
But removing "chance" of first strikes hitting, to actual hits of varying strength, makes some fights default victories, which I think is a bad idea. This will be especially true against damaged but strong units.

This way samurai will do very well against more advanced units on the offensive, since they will probably be damaged often attacking. Not a good solution imo.

But I agree of course that first strike is one of the weakest upgrades in the game generally.

BomberEscort
Nov 27, 2005, 04:21 PM
But removing "chance" of first strikes hitting, to actual hits of varying strength, makes some fights default victories, which I think is a bad idea. This will be especially true against damaged but strong units.

If you notice in my post above, making this change results in very little benefit. It is just enough to make the Drill promotion of more value than the combat promotions under certain circumstances. For the samurai it results in an increase of 14% against other 8.8 strength units only. The value will decline as the strengths differ.


This way samurai will do very well against more advanced units on the offensive, since they will probably be damaged often attacking. Not a good solution imo.

There is still a normal combat round, and the damage that would be dealt by a first strike that misses (1/2 damage) would be very small if the unit strengths varied greatly. As I also noted above first strikes could not be lethal, to guarantee at least one round of normal combat. Also any fully healed inferior unit has a good chance of defeating a severly damaged superior unit as the game is now.

Roland Johansen
Nov 27, 2005, 06:36 PM
There is another statistic that is interesting besides the basic chance to win a battle and that is the amount of hitpoints left. This is an interesting statistic when one unit has to defeat many. If the strong unit that has to defeat many units has a big chance to win the first combat but is left with only half its strength (on average) then it will not win the other ensuing battles against the other weaker units. Another example is when you're on the offensive and you don't want your offensive battles to be slowed by heavily wounded units that need to heal before they can fight again.

First strikes can be useful to avoid damage if your units are (a lot) stronger than the enemy units. This is a situation that can occur when you're technologically more advanced or if your units have large combat bonuses from cities.

To show this I used the combat calculator that you linked to.

Case 1: Unit A (St 50) vs Unit B (St 5): Average hps left when A wins: 97.6
Case 2: Unit A (St 16, 4 First Strikes) vs Units B (St 5): Average hps left when A wins: 99.0

So a strength 16 unit with 4 first strikes is better in number of hps left than a strength 50 unit against the weak strength 5 unit (not in the basic chance of winning). I bet that a strength 25 unit with 4 first strikes can defeat more strength 5 units in a row than a strength 50 unit can.

I know that this is an extreme example and will not typically occur, but it is only used here to show an advantage of first strikes. I will not try to defend that first strike promotions are better than basic combat promotions (because I don't think they are) or even that they are well balanced. But they are more useful than people might think after reading the posts above mine. I personally think that your modding might have overpowered first strikes a bit. I would go for a setting somewhere in between the Firaxis settings and yours.

Good luck with any further analysis of this difficult subject.:thumbsup:

BomberEscort
Nov 27, 2005, 06:49 PM
I understand your points and I agree with them (except the overpowering issue). But, if you have such an overwhelming technological advantage, you are going to win anyways. Also, an advantage that is unlikely to happen is the same as no advantage at all IMO. About the waiting to heal before attacking, just get the March promotion and heal on the move. It's cheaper (available after Medic I), than Drill IV.

Roland Johansen
Nov 27, 2005, 08:02 PM
I understand your points and I agree with them (except the overpowering issue). But, if you have such an overwhelming technological advantage, you are going to win anyways. Also, an advantage that is unlikely to happen is the same as no advantage at all IMO. About the waiting to heal before attacking, just get the March promotion and heal on the move. It's cheaper (available after Medic I), than Drill IV.

Okay, maybe it was not such a good move to provide an example that was not realistic. This example was only used to exaggerate the point that I was trying to make.

Here an example that could happen with an equal tech level. Unit A has basic strength 6 and a 100% defense bonus (castle or a unit fortified in a city on hills with a wall or some large culture defense bonus combined with fortifying bonus or...). Unit B attacking the city has strength 6.
Unit A has a 40% bonus from combat promotions -> strength 6 + 140% of 6 = 14.4 vs unit B strength 6. Expected hit points left if unit A wins: 78.6
Unit A has 4 first strikes -> strength 6 + 100% of 6 = 12 and 4 first strikes vs unit B strength 6. Expected hit points left if unit A wins: 90.7

4 first strikes help a unit more with defending the city against a horde of equal tech level attackers because it wouldn't lose its hit points and thus its strength as fast.


Unit A has a 50% bonus from city defense promotion and 20% combat promotion -> strength 6 + 170% of 6 = 16.2 vs unit B strength 6. Expected hit points left if unit A wins: 82.3.

4 first strikes help a unit more with defending the city against a horde of equal level attackers than 2 levels of the city defense promotion + 2 levels of standard combat promotions because it wouldn't lose its hit points and thus its strength as fast.


Why do first strikes work so well in this case? Simply because 4 first strikes from a stronger unit (modified strength is a lot greater) will do heavy damage to the other unit before it can actually combat the first strike unit.
First strikes become 'exponentially' stronger when a unit has more of them because the relative amount of hit points left on the opponent is very low. A unit A with one first strike might damage unit B for only 20 damage on average before real combat ensues. But a unit A with 4 first strikes will sometimes outright kill unit B before any real combat ensues. It will at least do some heavy damage against unit B before real combat ensues.

Because of the above argument, I think that Firaxis made a mistake with the first strike promotions. The first few levels of first strike should be relatively easy to acquire because they aren't worth much, but the later levels should be more difficult to acquire because these are worth much more (except when the enemy is immune to first strikes). Because of the option of immunity to first strike enemies, I think that a balanced first strike progression would be a flat +1 first strike per level of the first strike promotion, with an extra first strike at the first level of this promotion.
So:
level1: +2 extra first strikes
level2: + 1 extra first strikes (for a total of 3)
level3: + 1 extra first strikes (for a total of 4)
etc.
It would be a pretty powerful promotion type when the 'first striker' gains significant combat bonuses from a city or so, but it would still be inferior to the combat promotions in the open field (if I read your previous posts correctly) and it could be countered easily by units that are immune to first strikes.

What do you think?

edit: calculation mistake

CiverDan
Nov 28, 2005, 03:17 PM
bottom line of combat calculations: Dont attack with injured units.Yesterday I was in an MP game where I player bombarbed my city down to 0% defense and used his catapults to attack, but then decided to bypass it in favor of one which I was unable to reinforce. Before his stack moved on to the second target, I had bombarbed his 15 unit axe/cat stack with 6 cats. The second city had city defense 20% and on a hill w/ 2 longbow (City def I & II) and a catapult. All his units died on that attack. I checked the combat log and the percentages with ~90% win for me in most cases.

BomberEscort
Nov 28, 2005, 05:20 PM
...Here an example that could happen with an equal tech level. Unit A has basic strength 6 and a 100% defense bonus (castle or a unit fortified in a city on hills with a wall or some large culture defense bonus combined with fortifying bonus or...). Unit B attacking the city has strength 6...

I agree with your calculation, but my examples above were for units of equal modified strength. I didn't say this explicitly, I said equal strength, but my examples show equal modified strength. I could have been more clear on this point. In your example above, I do not believe that an experienced player would attack with unit B in this situation. But I understand your point :)

...4 first strikes help a unit more with defending the city against a horde of equal level attackers than 2 levels of the city defense promotion + 2 levels of standard combat promotions because it wouldn't lose its hit points and thus its strength as fast...

Using 6.0 vs 6.0 Modified Strength

Defender = 6.0 w/ 4 First Strikes
Attacker = 6.0
Defender Win = 76.4% (63 hp left)

Defender = 6.0 w/(CG I & II; CI & II) = 7.65
Attacker = 6.0
Defender Win = 76.0% (53hp left, in a city heals at 22% per turn)

Not much of a difference, factor in that the latter promotion path is open to all units, whereas the former promotion path is open to Archery, Siege, Armor, and Chopper Units. More often that not, it will be archery units that have Drill IV since they are on the scene first and have longer to get promoted. Plus nothing upgrades to Tanks, choppers do not get a defender bonus, ships can't defend cities, and the highest unmodified Archery unit strength is 6 with 2 FS for the Chokonu (granted he upgrades eventually to MechInf, but if you are at this tech level, your probably going to win with or without first strike capability). I would say in the vast majority of examples, the fact that the second promotion path is available to more units makes it more valuable that its lacking 0.4% in survivability and the extra 10hp.

...But a unit A with 4 first strikes will sometimes outright kill unit B before any real combat ensues...

I am not certain that FS are lethal I will have to test this somehow. I don't think they are though.

...Because of the option of immunity to first strike enemies..., I think that a balanced first strike progression would be a flat +1 first strike per level of the first strike promotion, with an extra first strike at the first level of this promotion.
So:
level1: +2 extra first strikes
level2: + 1 extra first strikes (for a total of 3)
level3: + 1 extra first strikes (for a total of 4)...

This isn't far from what I've modded and suggested: 1 FS and +4% General Combat bonus for Drill I - IV [(@ Drill IV +4 FS & +16% Combat Bonus) vs (+5 FS and No Combat Bonus)] (see a few posts up)

What do you think?

I think for the most part we are on the same page and I believe that eventually I will turn you to the dark side!!! ;) ... In all seriousness, I think we are saying similar things, you tend to value a few extra hp more that I do, where I favor healing on the run (March). We both get the 22% healing bonus in cities though. In the end it may come down to different playing styles, but I still think Combat promotions are better than Drill promotions for the reasons listed throughout my posts. I will have to set up a city taking scenario with and without FS Defenders and see how it goes.

Roland Johansen
Nov 28, 2005, 06:07 PM
I think for the most part we are on the same page and I believe that eventually I will turn you to the dark side!!! ;) ... In all seriousness, I think we are saying similar things, you tend to value a few extra hp more that I do, where I favor healing on the run (March). We both get the 22% healing bonus in cities though. In the end it may come down to different playing styles, but I still think Combat promotions are better than Drill promotions for the reasons listed throughout my posts. I will have to set up a city taking scenario with and without FS Defenders and see how it goes.

OK, I agree with your post all the way, except on the point that I will be turned to the dark side...:p

I think the first striker will be at its greatest strength when defending a city, that's why I used that example. Arathorn was also saying that first strikes weren't that good (he agrees with you), so I wanted to present a situation where they could be relatively good. Arathorn also argued that first strikes provided the greatest benefit when fighting units of equal strength (do you agree with this?). This is absolutely true when looking at the chances of victory. But a single victory won't win the war, so the hitpoints with which the unit is left are also important. If a unit is attacked multiple times in a turn (no time for healing), then it is very important to lose as few hitpoints as possible. I think that a unit that is promoted a lot with the first strike promotions will be very able in defending cities. The first few first strike promotions are rather worthless though, so that's why I suggested the change.

If you look at the strength of the modified first strike promotions, then our suggestions are quite comparable. I just want the first strike promotion to be very different from the combat promotions. That will make it more difficult to balance, but it might make the ingame choice between combat and first strike promotions more interesting. With both of our suggestions the first strike promotion will be valuable from the first level of this promotion. Something that is clearly not true for the Firaxis model.
I consider both models superior to the Firaxis model, but there can be only one....:ninja:

BomberEscort
Nov 28, 2005, 06:32 PM
The following tests revealed something interesting...

The first battle was 300 Musketman (9.0) vs 300 Samurai (8.0; 2 FS)
165 Musket Wins (55%) Calc Predicts (57.4)
First Strikes work on Defense

The second battle is the strange one.

300 Cho-ko-nu vs 300 Immortals (6.0; 2 FS vs 6.0; +50% vs Archers)

Results = Cho-ko-nu win 82% (Calc predicts 63.6%). This is unusually high, I wonder if this has something to do with the way +50% vs Unit Type bonuses are handled or maybe Immortals can retreat when defending. I will confim this in the next battle.

The Third battle is 300 Cho-ku-Nu vs 300 Jaguar on Forested Hill
(6.0; 2FS; +50% vs Melee vs 6.3; +75% Tile Defense)

Results = Cho-ku-nu win 82.3% (247/300)(calc predicts 47.1%)

The previous two are strange results... Any ideas anyone??

Fourth battle
300 Samurai (2 FS; +50% vs Melee) vs 300 Musketman (8.0 vs 9.0)
Samurai wins 134/300 (44.7%) (Calc predicts 42.6%)

Summary:

Battle #1: First Strike works on Defense
Battle #2: Defender has Unit Bonus vs First Strike Attacker w/ No Counter Unit Bonus (Strange Results)
Battle #3: Attacker has Unit Bonus and FS vs Defender (Strange results)
Battle #4: Attacker has No Unit Bonus and has FS vs Defender (Results Good)
Battle #5: Defender has Unit Bonus vs First Strike Attacker w/Counter Unit Bonus (Results Good)(See First Battle Here (http://forums.civfanatics.com/showpost.php?p=3375369&postcount=146))

There appears to be something happening with first strikes when:
a) (Defender has Unit Bonus against FS Attacker) vs (First Strike Attacker w/ No Counter Unit Bonus)
b) (Attacker has Unit Bonus against Defender and FS) vs (Defender w/ No Counter Unit Bonus)

Update: Nevermind, the Cho-ko-nu can cause collateral damage. This is why its win% is so high. This is a good unit!! Like having a 6 Strength Archery unit and a 3 strength siege unit in ONE unit!!

Zombie69
Nov 28, 2005, 06:48 PM
As it stands now, first strikes are good if they are given away as freebies (obviously), but they are not worth the selection in promotions regardless of the fact that your unit may have 0-2 first strikes given to it. Drill over Combat promotion cannot be justified under any circumstances currently (v1.09). Stick with the Combat promotions over Drill , unless something changes in the next patch.

I disagree. As it stands now, first strike is better than combat in some circumstances. For instance, in city defense, i would take first strike over combat if i think that my defender can beat off multiple attackers. Archers are so powerful as city defenders that it often takes 3 or 4 opposing units for every archer taken out. With or without first strike, the archer will win the first fight or two. But with first strikes, he'll win those lopsided battles with more HP remaining, making it harder to take him out in subsequent battles. Instead of losing 3 units before killing the archer, you might end up losing 4.

Edit :
I see that Roland Johansen beat me to it. Then let me just say that i agree with him!

BomberEscort
Nov 28, 2005, 06:57 PM
I disagree. As it stands now, first strike is better than combat in some circumstances. For instance, in city defense, i would take first strike over combat if i think that my defender can beat off multiple attackers. Archers are so powerful as city defenders that it often takes 3 or 4 opposing units for every archer taken out. With or without first strike, the archer will win the first fight or two. But with first strikes, he'll win those lopsided battles with more HP remaining, making it harder to take him out in subsequent battles. Instead of losing 3 units before killing the archer, you might end up losing 4.

Edit :
I see that Roland Johansen beat me to it. Then let me just say that i agree with him!

Remember, First Strike is only good when you are equal to or stronger than your opponents. If they are stronger than you it is better to go for the City Garrison and Combat promotions over Drill. Plus Combat Promotions open up other avenues (Blitz, Amphibious, etc.), Drill is a dead-end.

It is possible for Drill IV to be useful IF you upgraded your Drill IV archers to MechInf (20% Intercept) AND your opponent was just as advanced and was not using Air Power. That is a big IF... By the time bombers are on the scene they can strike your offensive first strike units with impunity (unless you have SAM Infantry, but even they only intercept 40%, and unlike Civ III, inteception does not automatically destroy the air unit). So eventually your stacks will be 1/2 strength and can be easily mopped up by his Combat V units. Drill is practically worthless when Bombers arrive. Combat V is forever!!! ;)

Zombie69
Nov 28, 2005, 09:31 PM
I've never played a Civ 4 game (admitedly i haven't played many yet) or Civ 3 for that matter where i've seen any air unit at all. My games end long before that. In fact, the farthest i've ever been in technology in those games was getting to Cavalry in Civ 3 once or twice. So the bomber argument for me is null and void.

My games are usually decided in the ancient era. By the time this is over, i pretty much know who's gonna win. In the ancient era, archers are top notch defensive units. They can, and will, beat off many attackers. Especially if the city was put on a hill. For this, first strike can be absolutely awsome. I think you underestimate this promotion a lot. I wouldn't change it at all. For me, it's perfect as it is.

GenericKen
Nov 29, 2005, 11:50 AM
I think many of you are underestimating first strike. While one isn't impressive, the effects of multiple first strikes are cumulative. Think of it as free bombardment.

While generally, if a unit has inferior combat strength, combat promotions will be better, consider that your defenders will sometimes inevitably be bombarded by multiple units, and that inferior combat strength or inferior numbers will be inevitable. First strike is often the better call in these cases, especially vs units that deal collateral damage.

token mac user
Nov 29, 2005, 05:15 PM
Probability
Several posters to this thread have shown both mathematical aptitude and made some excellent observations. I miss one comment on probability though. When your odds to win a battle is better than 50%, it is more telling to look at the odds of losing than the odds of winning. At least if the unit is valuable. For example, the 5% from 90% to 95% is more valuable than the 5% from 50% to 55%. In the first case, you cut the risk of losing your unit in half, while in the other case the risk is all but unchanged. This means that higher end bonuses is very useful for your most valuable units. If all your units are the same all percentages are equal (heh).

First strikes are useful for:
-defending against several units in a single round. If you disallow your opponents to attack your city defences, a drill IV longbowman could singlehandedly defend against a large number of attackers. This allows for more counterattacking units instead of purely defending ones.
-(possibly) blitzing.

It certainly seems like the samurais are underpowered. They are only good for defence, and knights totally rip them up as they have +50% against melee and are immune to first strikes.

BomberEscort
Nov 29, 2005, 07:05 PM
I think that the people who overvalue first strikes are forgetting one important fact. On the harder levels and most decent players that play multiplayer will bring siege weapons to attack a city. A group of Swordsman and Catapuls will destroy longbowmen with the first strike capability. Why? Because the good player will not attack the longbowmen until the catapults have lowered the city defense to zero and damaged the longbowmen collaterally. Then it is a 6.0 Swordsman vs 3.0 Longbowman, and no amount of first strikes will help with that battle. (2 to 1 Strength ratio results in 99% victory). So although against a player or AI that throw men into the breach, without siege support, the first strike may prove useful. But not against an equally matched player who comes to play if you know what I mean... But I digress, this thread is quickly becoming a debate about first strike when its intention was to explain combat and post findings. I don't want to threadjack the original intention of this thread, but I believe this has happened or is in the process of happening, against my original intentions. If anyone has anymore comments about first strike, please start a new thread and we can debate it there. Thanks.

Zombie69
Nov 30, 2005, 07:37 AM
Until catapults show up though, archers with first strikes can totally dominate. I'm playing a game right now where an archer with Drill 4 just got another promotion. Sweet. I'm almost done eliminating a 3rd opponent and nobody is even close to having catapults yet. A good example of how the Ancient era can be the most crucial in the game.

First strikes can also be great against raging barbarians (i guess, haven't tried yet), as you don't necessarily get lots of time to heal in between attacks and i don't think barbarians ever get catapults.

You have to agree at least that in some cases, Drill is by far the best promotion. It may be a highly specialized one, but it does have its uses.

korn469
Dec 01, 2005, 12:55 AM
Arathorn (or any mathematician who can give me an answer)

In the originial post Arathorn wrote this

Both the attacker and the defender always begin with 100 hps, regardless of whether they are injured or not at the start of combat...Going back to R notation, the attacker does floor(20*(3*R+1)/(3+R)) damage and the defender does floor(20*(3+R)/(3*R+1)) damage.

The maximum damage one size can do is 60 per hit. The minimum that can be done is 6. Only those values are possible, regardless of the relative strengths of the units.

Tell me if I have this concept correct. If somebody changed the 20 in the floor(20*(3*R+1)/(3+R)) and floor(20*(3+R)/(3*R+1)) to 22, then the jump points would remain in the outcomes. However, they would shift up to around 1.2 maybe 1.25. So what would the graph and jump points look like look like for that?

zakalwe
Dec 01, 2005, 01:23 AM
Hi Arathorn,

In the first post of this thread, you dive directly into how to resolve a combat between a given attacker and defender. But you don't mention how the defender is selected to begin with, from a stack of potential defenders. I only skimmed the rest of the thread, so maybe this is covered in some of the replies. If so, you should edit it into the first post as well.

Intuitively, one would expect the defender to be picked according to the actual odds of winning (not the strength ratios), so this would confirm that there is an actual built-in combat odds calculator. Alternatively, the defender is selected by some other criterion, such as the strength ratio or some variant thereof. This could mean that wounded, but more advanced units in a stack would run the risk of being killed due to their deceptively high strength (but low HPs). To be concrete, if I have a fully healed spearman at strength 4, I would want him to defend rather than a wounded pikeman at strength 4.1/6, since the latter would actually have a lower chance of winning.

Bottom line, in order to always pick the best possible defender, the game requires a full-fledged combat odds calculator which accounts for everything, including first strikes. If it's not already there, it would be high on my wish-list for a mod.

Roland Johansen
Dec 01, 2005, 05:47 PM
Arathorn (or any mathematician who can give me an answer)

In the originial post Arathorn wrote this



Tell me if I have this concept correct. If somebody changed the 20 in the floor(20*(3*R+1)/(3+R)) and floor(20*(3+R)/(3*R+1)) to 22, then the jump points would remain in the outcomes. However, they would shift up to around 1.2 maybe 1.25. So what would the graph and jump points look like look like for that?

You're correct that there still would be jump points. But the graph would be pretty different. Now there's a jump point at the point that units are equal in strength. This is because 100 hitpoints is exactly 5 times 20 hitpoints so 5 hits would kill a unit. If a unit is only a little bit stronger, then the weaker unit would need 6 hits to do more than 100 hitpoints of damage. Because the chances of hitting 6 times (before your unit is dead) are a lot smaller than the chances of hitting 5 times, there is a jump point at the R value of 1.

Now 22 is not a divisor of 100 (there exist no integer n so that n times 22 is equal to 100). It would still take 5 hits of 22 damage to kill a unit of 100 hitpoints. However 5 hits of 21 damage will also do the job and even if you're doing 24 damage, you'll still need 5 hits to do more than 100 hitpoints of damage. Therefore, if a unit is only a little bit stronger then another, then both units will still need to hit 5 times. The stronger one will have a slightly larger chance to hit 5 times, but there's no jump point at the R value of 1.

The jump points will occur when the stronger unit will do 25 damage (needing only 4 hits to kill a unit) and the weaker unit will do 19.99999... damage (needing 6 hits to kill a unit).
The jump point where the stronger unit will only need 4 hits is at R=1.2927,
The jump point where the weaker unit will need 6 hits is at R = 1.2105.
It's not a good thing that these two jump points are so close to each other. Ingame, you'll effectively will see them as one super jump point. Before R= 1.2105 you'll be pretty even and after R=1.2927 the weaker unit will be at a very serious disadvantage.

Of course there are more jump points (which I will not calculate). However, I think that the above mentioned differences are the ones that you're most likely to notice ingame.

Ellestar
Dec 02, 2005, 06:09 AM
Exact odds can be found at http://c4combat.narod.ru/c4c_v0_13.htm [Note: Last I checked, this did not have the capability to deal with starting hps other than 100.]

I added it in v0.14 here http://c4combat.narod.ru/c4c.htm
It used HPs during calculations anyway.

snepp
Dec 02, 2005, 07:01 AM
I added it in v0.14 here http://c4combat.narod.ru/c4c.htm
It used HPs during calculations anyway.

Thanks! :)

Zombie69
Dec 02, 2005, 11:03 AM
Hi Arathorn,

In the first post of this thread, you dive directly into how to resolve a combat between a given attacker and defender. But you don't mention how the defender is selected to begin with, from a stack of potential defenders. I only skimmed the rest of the thread, so maybe this is covered in some of the replies. If so, you should edit it into the first post as well.

Intuitively, one would expect the defender to be picked according to the actual odds of winning (not the strength ratios), so this would confirm that there is an actual built-in combat odds calculator. Alternatively, the defender is selected by some other criterion, such as the strength ratio or some variant thereof. This could mean that wounded, but more advanced units in a stack would run the risk of being killed due to their deceptively high strength (but low HPs). To be concrete, if I have a fully healed spearman at strength 4, I would want him to defend rather than a wounded pikeman at strength 4.1/6, since the latter would actually have a lower chance of winning.

Bottom line, in order to always pick the best possible defender, the game requires a full-fledged combat odds calculator which accounts for everything, including first strikes. If it's not already there, it would be high on my wish-list for a mod.

You're right, it's not already in there, and you're right, it should be. A good example is in my current game, where my archer with 0.5 strength left but 4-7 first strikes, wanted to attack an archer with 0.8 strength left but only 1 first strike. I'm pretty sure my archer is supposed to win this (and he did without losing any HP), but the odds showed as 0.5 vs 0.8, which is obviously wrong (or at the very least incomplete). My archer's score was shown in red and my opponent's in green.

I'm pretty sure the same applies to choosing defenders.

Krikkitone
Dec 02, 2005, 01:00 PM
well it does at least List the First strikes, it Doesn't show the decreased HP ratio.

BomberEscort
Dec 02, 2005, 04:00 PM
I just thought of an advantage for first strike units. When calculating how much XP you'll get from a win, cIV uses the current strengths of the units only. It does not modify for first strike ability. FS units can defeat stronger full strength units than there non-FS counterparts (although this difference isn't very much). Therefore giving it a little more experience in the long run.

For Example:

6.0 Attacker w/o FS vs 7.0 Defender w/o FS = 28.6% Win w/ 4 XP
6.0 Attacker w/ 4 FS vs 7.0 Defender = 53.3% Win w/ 4 XP

It's not much, but over the long run, if you attack stronger units with your firststrikers instead of non-firststrikers you will gain more experience (because your survivabilty is much higher). Still Combat II is only 2 promotions and gives 20%. To get 4 FS may take more promotions.

eg577
Dec 02, 2005, 04:46 PM
But by taking the inferior promotion you decrease your chance of winning battles in the first place.

BomberEscort
Dec 02, 2005, 05:20 PM
But by taking the inferior promotion you decrease your chance of winning battles in the first place.

True, I was trying to give the First Strike crowd hope ;)

fed1943
Dec 03, 2005, 03:36 AM
Great math work you have done,gentlemen;that´s the basis,surely.
But,IMO to think about the promotions,one must decide first what for he wants the unity:to protect a city?just to defend the city square?recon?counteractack?conquer cities?all atack?destroy cities´defenses?weaken stacks?deep strikes?or try the all propose unity?

zakalwe
Dec 03, 2005, 04:27 AM
You're right, it's not already in there, and you're right, it should be. A good example is in my current game, where my archer with 0.5 strength left but 4-7 first strikes, wanted to attack an archer with 0.8 strength left but only 1 first strike. I'm pretty sure my archer is supposed to win this (and he did without losing any HP), but the odds showed as 0.5 vs 0.8, which is obviously wrong (or at the very least incomplete). My archer's score was shown in red and my opponent's in green.

I'm pretty sure the same applies to choosing defenders.

Well, your example only shows that the displayed strength ratios differ from the actual chance of winning, which is of course well-known by now. What would be interesting is if someone could come up with an example where the game picks a sub-optimal defender for a given attacker. I personally suspect that the game *does* have an algorithm for calculating the odds of winning, that is at least pretty accurate (if not perfect). This algorithm is presumably used both to pick the best defender, but also by the AI. If so, the game already knows the % chance of winning any given combat, so exposing it through a mod could turn out to be pretty easy.

Zombie69
Dec 03, 2005, 10:21 AM
If it does have such an algorithm, why doesn't it use that algorithm to determine the amount of experience you get? The combat i mentioned above gave me 6 XP, and i'm pretty sure my odds were well above 50%.

It's true that a test is needed to know for sure, but i highly suspect that the algorithm is not there at all.

carn
Dec 03, 2005, 11:26 AM
(removed due to double post)

carn
Dec 03, 2005, 11:28 AM
I didn't read all the dicsussion about first strike vs combat, but i think you overlooked, how % bonuses add for defender.

If there is no bonus present, then the 10% from combat 1 will be better than 1 first strike, but if there is either a large positive or negative bonus there first strike gets stronger.

Example(using combat calculator): Longbowman(str 6 + 1 FS) with 150% defense(walls,castle,city+hill) vs cavalry with combat 1(str 15);

chance to win for bow with combat 1: 40.25%
chance to win for bow with drill1: 44.03%

The reason is simply that all combat bonuses are added, a +10% on top of +150% is less worth than on top of +0%. Above the combat increases combat 1 increases the longbowman final strength just from 15 to 15.6.

Of course the combat 1 will still be better if it jumps odds above the ratio 1 gap:

chance to win for bow with combat 3(str16.8): 69.5%
chance to win for bow with combat 2 and drill1(str16.2): 49.12%

but above that favor is again with drill:

chance to win for bow with combat 4(str17.4): 71.49%
chance to win for bow with combat 3 and drill1(str16.8): 75.23%

A similar effect is off course at the other jumppoints.

For attackers i think this argument does not hold, as they do not receive any strength modification except combat, so the +10% always increases final strength by 10%.

But if there are no large bonuses combat is better.

A very complicted effect is that with higher combat drill 1 gains slightly ground against further combat promotions.

So drill is better for a defender if there are already large bonuses(no difference whether for or against i think) and strength ratio is not around a jump point.

Someone motivated could do an extensive analysis how much other bonuses already have to be present, that drill gets better than combat, assuming no jump point.

Conclusions: If units are expected to fight with high final bonuses present and a 10% does not get over jump point(difficult to know in advance), then drill is better than combat.


P.s. i fear i can become a real addict, i have so far only played the demo version, but i cannot stop starting again and again to play that 100 turns - and its probably even more fun when the terrain is no longer black!:scan:

zakalwe
Dec 03, 2005, 02:13 PM
If it does have such an algorithm, why doesn't it use that algorithm to determine the amount of experience you get? The combat i mentioned above gave me 6 XP, and i'm pretty sure my odds were well above 50%.

Good point. But again, this only shows that the amount of XP you gain does not necessarily correlate all that well with your chance of winning. The clincher would be an example of the game picking a sub-optimal defender; that would convince me that the game is in fact incapable of calculating the correct chance of winning.

It is possible (or even probable) that the algorithms for resolving a combat, calculating the chances of winning one, and determining the amount of XP the winner should gain, might not have been kept all that synchronized during the development process.

We can only speculate (which we do) :lol:

BomberEscort
Dec 03, 2005, 07:40 PM
If it does have such an algorithm, why doesn't it use that algorithm to determine the amount of experience you get? The combat i mentioned above gave me 6 XP, and i'm pretty sure my odds were well above 50%.

It's true that a test is needed to know for sure, but i highly suspect that the algorithm is not there at all.

XP = (4 * Defender Str)/(Attacker Str)
XP = (4 * 0.8)/(0.5) = 6.3 = 6 XP

Your correct, first strikes and chances are not displayed in the odds and are therefore misleading. I'd get upset when I'd have a 5.0 attacker vs 3.5 defender and lose, until I realized the defender had first strikes. Again the odds are only good for Unit vs Unit w/Bonuses, but are misleading for first strikes attackers (actual winning odds are higher than listed) and when the defender has FS and the attacker doesn't the odds are lower than listed for the attacker. See Here (http://forums.civfanatics.com/showthread.php?t=137615&page=8) for a first strike analysis

Arathorn
Dec 03, 2005, 08:25 PM
@carn -- thank you for the good analysis. I had had some initial thoughts along those lines, but hadn't had time/motivation to do a good write-up. Two promotions would also be a bit different, I think. I hope to do further analysis along those lines, but I'm not sure when I'll have time/motivation to do them.

Arathorn

CiverDan
Dec 03, 2005, 09:01 PM
A Quecha/archer question. In my MP experience I have had high % of losses attacking archers on flat land with quechas, with both units at full health and archer unfortified. Just some bad luck or is there something in the calcs that make archers harder for quechas to kill outside of cities that the civ numbers dont include. Odds are listed at ~2.2 to 1.5 for the Qeucha. I had a similar experience with attacking longbows in the open w/muskets.

On the other hand if i can wear a stack down with seige so that I have a >50% chance against the strongest enemy units, I can then get repeated wins and dispose of the stack. This is how I kill 6-7 infantry at the cost of 3-4 cannons (and get my cav promoted as well). Well worth it.

Krikkitone
Dec 03, 2005, 09:52 PM
A Quecha/archer question. In my MP experience I have had high % of losses attacking archers on flat land with quechas, with both units at full health and archer unfortified. Just some bad luck or is there something in the calcs that make archers harder for quechas to kill outside of cities that the civ numbers dont include. Odds are listed at ~2.2 to 1.5 for the Qeucha. I had a similar experience with attacking longbows in the open w/muskets.

On the other hand if i can wear a stack down with seige so that I have a >50% chance against the strongest enemy units, I can then get repeated wins and dispose of the stack. This is how I kill 6-7 infantry at the cost of 3-4 cannons (and get my cav promoted as well). Well worth it.

That's whats been discussed, Archers and longbowmen have first strike which alters the odds in their favor (although you should still beat them with muskets/quechas)

Ellestar
Dec 05, 2005, 03:03 AM
Relative strength of wounded units

HP Str
95 0.949
90 0.899
85 0.849
80 0.799
77 0.769
76 0.685
75 0.676
70 0.565
65 0.51
60 0.471
55 0.431
50 0.359
45 0.285
40 0.253
35 0.222
30 0.166

So, a unit with 77 or more HPs is about as strong as a unit with 100 HP and a marginally lower strength in Combat Odds. However, with the equal "Combat Odds" strength wounded unit has 62% chance to lose (99-81 HP) or 75% chance to lose (80-77 HP).
After that, unit becomes significantly weaker than non-damaged unit with the same "Combat Odds" strength so it's not recommended to fight with it.

Roland Johansen
Dec 05, 2005, 06:49 AM
Relative strength of wounded units

HP Str
95 0.949
90 0.899
85 0.849
80 0.799
77 0.769
76 0.685
75 0.676
70 0.565
65 0.51
60 0.471
55 0.431
50 0.359
45 0.285
40 0.253
35 0.222
30 0.166

So, a unit with 77 or more HPs is about as strong as a unit with 100 HP and a marginally lower strength in Combat Odds. However, with the equal "Combat Odds" strength wounded unit has 62% chance to lose (99-81 HP) or 75% chance to lose (80-77 HP).
After that, unit becomes significantly weaker than non-damaged unit with the same "Combat Odds" strength so it's not recommended to fight with it.

How was this relative strength determined?

Ellestar
Dec 05, 2005, 07:48 AM
How was this relative strength determined?
Wounded unit with "HP" Hit Points and Strength 1 has 50%+ chance to win against non-wounded unit with Strength "Str" from that table (both units don't have first strikes).

v0.15 http://c4combat.narod.ru/c4c.htm
Check only checkbox "Relative Strength of Wounded units"
You also can set first strike for 1st or 2nd unit if you want.

Roland Johansen
Dec 05, 2005, 02:10 PM
Wounded unit with "HP" Hit Points and Strength 1 has 50%+ chance to win against non-wounded unit with Strength "Str" from that table (both units don't have first strikes).

v0.15 http://c4combat.narod.ru/c4c.htm
Check only checkbox "Relative Strength of Wounded units"
You also can set first strike for 1st or 2nd unit if you want.

Okay, that is good to know. So a unit of strength 1 with 70 hitpoints has close to 50% chance to defeat a unit of strength 0.565 with 100 hitpoints.

I should note that the special value of 76-77 hitpoints has to do with this specific battle. If you take 2 units with one wounded then in general it is not that important if the wounded unit has 76 or 77 hitpoints. It is just that a jumppoint (as defined by Arathorn in his article) occurs somewhere between 76 and 77 hitpoints in this lineup.

If you take a wounded unit of basic strength 10 and a healthy of strength 6, then there is a jumpoint for the strength 10 unit at the following health values:94-95, 83-84 and 72-73 etc. There's no jumppoint at health value 76-77.

Chance for the basic strength 10 unit to defeat the strength 6 unit when the wounded strength 12 unit starts with the following number of hitpoints:
100: 0.962

95: 0.954
94:0.851

84:0.805
83:0.691

73:0.619
72:0.466

and for the argument:
77:0.650
76:0.642

I only post this so that people don't think there's something special with the 76-77 hitpoint value. I don't know if you were trying to prove that this hitpoint value is important, but people could think it is after reading your post.
It's interesting to see how quickly the real strength of a unit drops after losing some hitpoints and your post shows that quite well.

Ellestar
Dec 06, 2005, 12:43 AM
I only post this so that people don't think there's something special with the 76-77 hitpoint value. I don't know if you were trying to prove that this hitpoint value is important, but people could think it is after reading your post.
It's interesting to see how quickly the real strength of a unit drops after losing some hitpoints and your post shows that quite well.
Well, it's not that important itself, but you can rely on "Combat Odds" if your unit has 77+ Hit points and there are no first strikes involved. After that, unit may be actually weaker (less than 50% chance to win) even if it's stronger in "Combat Odds" comparision.
The most important thing is that it's easy to use that simple rule when you're playing - you don't need any complicate formulas etc.

Zombie69
Dec 06, 2005, 06:26 AM
The key here is "may be". If the unit is stronger in combat odds (rather than just equal), this throws your whole table out the window and requires a new table. On that new table, depending on what the combat odds are, the break point could be completely different. It could be at 66 for example. So remembering the number 77 is useless for all purposes except for absolutely equal combat odds, which you generally don't want to get into anyway.

Arathorn
Dec 08, 2005, 01:06 PM
Very small updates to the first two posts -- linked the new combat calculator, added a bit more on first strikes, corrected the "start with 100 hps" sentence, things of that nature.

What open questions do we still have for land combat?

Arathorn

zakalwe
Dec 08, 2005, 02:05 PM
What open questions do we still have for land combat?

My question was: How does the game pick/determine the best defender (from a stack of possible defenders)?

Krikkitone
Dec 08, 2005, 03:43 PM
Very small updates to the first two posts -- linked the new combat calculator, added a bit more on first strikes, corrected the "start with 100 hps" sentence, things of that nature.

What open questions do we still have for land combat?

Arathorn

First Strike 'Chances'?

Thalassicus
Dec 10, 2005, 03:43 AM
Also, I dislike that my modern armors so often are the ones defending against gunships instead of the mechanized infantry in the stack. Perhaps they do sometimes have a marginally higher strength, because of more experience, but that should be a reason why the computer should NOT use them for defence. They are an offensive units, and used defensively is just plain waste. I would like to see better use of this, or preference settings. If for instance there were 2 equally strong units or one marginally stronger, but the other had the hill defense or city defense upgrade, it could perhaps have a higher priority because of this? Not necessary, just a thought, and some peculiarities regarding always strongest units now that they only have one strength value.
This would easily be solved if they add "Designated Defender" back in. The strongest Designated Defender is chosen for defense. If there there are none in a stack, the strongest non-defender unit is chosen.

This was in Civ 1 through SMAC, (don't remember about CivIII). I have absolutely no idea why this isn't included as you can now specialize units for attack or defense. Why would you ever want a lvl 6 City Raider axeman to defend (with Combat II, City Raider III) if there's a half-dozen lvl 3 Combat II axemen in the stack?

Or to make matters more simple (since designated defenders are replaced more often), switch it around and have a "Designated Attacker" button. It could be a toggleable button on the command bar titled "Never defend" or some other self-explanatory wording. This way your designated assault units would be the last chosen for defense.


The only way to get rid of the jump points is by making the amount of damage variable (with an average amount of damage equal to the present value).

The reason for jump points is that you need 5 hits of 20-24.999 damage to kill a unit and 4 hits of 25-33.333 damage to kill a unit. It's far more probable that a unit successfully hits 4 times (or more) than that it successfully hits 5 times (or more).

Variable damage in a turn-based game is actually identical in effect to a single formula-calculated % chance to win and health loss, since it all occurs in one unit of combat. Just eliminating the rounds method of combat would solve this, using one unified combat result formula instead :)

Variable damage is something more commonly used in real-time combat to provide the randomness you get from a percentage formula in turn-based combat. The thing here is the inherent "rounds" method of calculating odds, which results in the odd jumps.

Roland Johansen
Dec 12, 2005, 10:23 AM
Variable damage in a turn-based game is actually identical in effect to a single formula-calculated % chance to win and health loss, since it all occurs in one unit of combat. Just eliminating the rounds method of combat would solve this, using one unified combat result formula instead :)

Variable damage is something more commonly used in real-time combat to provide the randomness you get from a percentage formula in turn-based combat. The thing here is the inherent "rounds" method of calculating odds, which results in the odd jumps.

Civ 3 also worked with rounds of combat, but there were no odd jumps in the chances of victory. It really has to do with the effect described earlier in this thread. 5 hits of 20 damage each kill a unit, but if you only do 19.999 damage per round then 6 hits are required (units have 100 hitpoints). So a unit of strength 3 has a much better chance to beat a unit of strength 3 then a unit of strength 2.999 would have.
If the damage was not determined to be exactly 20 but vary a little, then a unit of strength 3 fighting another unit of strength 3 might need 6 hits to defeat it (or only 4 hits), while the unit of strength 2.999 might be able to defeat the unit in 5 hits. This will eliminate the jump points. The graph in post 92 shows an example of variable damage per combat round.

Another game where this occured was Starcraft: Marines did 6 points of damage in this game, needing 6 hits to kill the 35 hitpoints zergling. If the marines upgraded their weapons to do 7 hitpoints of damage then only 5 hits were needed. If the zerglings however upgraded their natural armor, then the marines would only do 5 hitpoints of damage, needing 7 hits to kill the zergling. In this matchup of realtime units, this was not a bad thing. In civ4 it is because very small differences in strength can have large differences in combat effectiveness.

Thalassicus
Dec 12, 2005, 12:12 PM
Another game where this occured was Starcraft: Marines did 6 points of damage in this game, needing 6 hits to kill the 35 hitpoints zergling. If the marines upgraded their weapons to do 7 hitpoints of damage then only 5 hits were needed. If the zerglings however upgraded their natural armor, then the marines would only do 5 hitpoints of damage, needing 7 hits to kill the zergling. In this matchup of realtime units, this was not a bad thing. In civ4 it is because very small differences in strength can have large differences in combat effectiveness.
That is an excellent point, I had forgotten about that. It's a good example of jump points being worked into the design of a game :) Warcraft III avoided them with slightly variable damage on all units and a wider range of health values.

Still, when all combat is resolved in one sequence, it seems that having a formula calculate the result would have the same effect as multiple rounds of combat, since it's all invisible at the user end, and would require less processing time.

Roland Johansen
Dec 12, 2005, 12:51 PM
You're right, the rounds of combat don't necessarily have to be shown to the player. However, some gamers (like me) like to know how exactly the combat formula works, so for them the combat log is very interesting. The reason that the civ combat model uses rounds of combat is to lower the randomness of combat. It is not totally unthinkable that a longbowman will win a round of combat against a modern armor, but it will not win enough rounds to win the battle (in general). However, it will sometimes damage the modern armor, which means that a scientific edge in civ4 doesn't mean automatic victory in all and every combat. You cannot steamroll an opponent if you're one technology ahead of them. Maybe this can also be achieved with other combat models that lower the variance in outcomes, but this system works pretty well. The only 'problem' are the jump points in victory chances and that can be modified by doing variable amounts of damage.

By the way, calculating a combat result costs a negligible amount of time. It's the animations that take a fixed amount of time to be shown to the player.

Atanvarno
Dec 20, 2005, 07:55 AM
If I have a Flanking II & Drill IV unit fighting an equal Drill IV unit, will my 'immune to first strikes' from Flanking II first take away the opponents first strikes and then add mine, or will it compare the first strikes, conclude that we have the same amount, give no first strikes to either and then remove the opponents first strikes (by immunity)?

In short: Is immunity to first strikes taken in before or after the comparison of first strikes?

Thalassicus
Dec 20, 2005, 11:40 AM
[...]

By the way, calculating a combat result costs a negligible amount of time. It's the animations that take a fixed amount of time to be shown to the player.
The situation I was thinking about is between human turns, when the AI's make their moves. Not sure how much of an advantage consolidating combat into one formula result would be, but it would still be more efficient nonetheless. The winner, health remaining, and XP gained in combat all could likely be calculated by an iterative formula rather than the recursive/iterative rounds-of-combat formula. There's really no way of knowing without seeing what the actual code looks like :)

Beamup
Dec 20, 2005, 11:47 AM
In short: Is immunity to first strikes taken in before or after the comparison of first strikes?
Given the interpretation of first strikes as "rounds of immunity," I believe you'd get your first strikes.

This is because there is never any actual "comparison of first strikes." There are only rounds where neither unit can be damaged. But if you're immune to first strikes, the enemy can be damaged after all. And you still can't because of your first strikes that are still working.

DaveMcW
Dec 20, 2005, 11:52 AM
The situation I was thinking about is between human turns, when the AI's make their moves. Not sure how much of an advantage consolidating combat into one formula result would be, but it would still be more efficient nonetheless. The winner, health remaining, and XP gained in combat all could likely be calculated by an iterative formula rather than the recursive/iterative rounds-of-combat formula. There's really no way of knowing without seeing what the actual code looks like :)During AI turns, most of the processing power is sucked up by the AIs themselves.

Atanvarno
Dec 20, 2005, 05:01 PM
First strike round(s) are special. The number of them is determined by looking at the number of first strike rounds of the attacker and the defender. Whichever number is greater gets the difference of values in first strike opportunities.
Given the interpretation of first strikes as "rounds of immunity," I believe you'd get your first strikes.

This is because there is never any actual "comparison of first strikes." There are only rounds where neither unit can be damaged. But if you're immune to first strikes, the enemy can be damaged after all. And you still can't because of your first strikes that are still working.
Which version is it?

Zombie69
Dec 20, 2005, 05:33 PM
I think it's the latter. The first was a while ago before we understood that first strike rounds are played out even when both units have them.

Arathorn
Dec 21, 2005, 03:21 PM
Beamup (and Zombie69) are correct. That's another part of the article I should rewrite now that we have greater understanding of how first strikes work out.

Arathorn

Roland Johansen
Dec 22, 2005, 10:29 PM
From the patch 1.52 change log:
-firepower in combat now based on max strength

You're going to have to change that in your article too...


Also from the change log:
-combat info now shows odds of success


I wonder if this includes first strikes as I remember something about the game not considering first strikes when picking the best defender. If the ingame probabilities are calculated exactly correct, then this may also help with testing.

Arathorn
Dec 22, 2005, 11:01 PM
Yeah. The 1.52 patch will require a re-visit to this article. Already looking at things a little bit, trying to figure out what they mean by "firepower". I'm thinking damage done, but I'm going to need to test.

Arathorn

Kaleb
Dec 23, 2005, 12:11 PM
whoah:

Firepower in combat is now based on max strength

guess that's going to mean a lot of recalculations for some people :sad:

glad I'm too lazy to do it... :mischief:

Krikkitone
Dec 23, 2005, 04:14 PM
So basically that means that hitpoints now hurt 2 ways
1. chance of doing damage
2. amount of damage you have

Where as they used to hurt 4 ways
3. damage you do
4. damage they do

So a 5/10 unit is 1/4 a 10/10 unit
making it better than a 5/5 unit (which is about 1/8 of a 10/10 unit)

This should eliminate a lot of spearman v. tank complaints (because a 4/28 tank will have the edge v. a spearman now)

Zombie69
Dec 24, 2005, 10:25 AM
I think it's a horrible change. Now we'll see more injured tanks rolling over enemies without even stopping. I was glad that you had to heal injured units. Not anymore...

Grogs
Dec 24, 2005, 11:24 AM
I think it's a horrible change. Now we'll see more injured tanks rolling over enemies without even stopping. I was glad that you had to heal injured units. Not anymore...

I don't think it's so bad. A wounded tank will still have a tough time taking out infantry, or even rifles in a city. Frankly, if you're taking a city that's guarded by anything less than that, it's a forgone conclusion anyway - this just makes it a little faster. It also works both ways. Even though your suicide artillery has dropped that infantry to 10 str, they'll still put up a pretty good fight when you try and take them out.

Kaleb
Dec 25, 2005, 10:40 AM
yeah, it's a double-edged sword. I have found that once you have done some collateral damage on a city even strong units falls pretty quick because of the multiplier effect of damage on a unit's overall strength. so it will take a bit more effort to take a city. another way of looking at it is when you take a city your units will be more damaged, because the defenders DID more damage.

so you'll have units that end up weaker from the attack, but won't be as ineffective as they would have been with that amount of strength before

so it's a bit of take some, lose some - but I am in favour of the change because it is easier to understand and estimate a units effectiveness

Luhh
Dec 27, 2005, 03:32 AM
I like the change. Power for the win!

Celebithil
Dec 29, 2005, 03:28 AM
So a 5/10 unit is 1/4 a 10/10 unit
making it better than a 5/5 unit (which is about 1/8 of a 10/10 unit)

This should eliminate a lot of spearman v. tank complaints (because a 4/28 tank will have the edge v. a spearman now)

I think a 5/10 unit still is worse than a 10/10 unit, but not as much as before. If they fight each other the chance of hitting are 50% for both and the damage done is 28 (for the 5/10 unit) respectively 14 (for the 5/5 unit), so the 5/10 unit needs 4 hits to kill the 5/5 unit, but the 5/5 unit also only needs 4 hits (because the 5/10 unit only has 50hp remaining). Hence the odds of winning with both units is 1/2.

A 4/28 unit will also still be a little worse than a 4/4 unit. However the differences aren't as big as they used to be (odds of winning with the 4/28 unit are now 5/16 versus previously 1/32).

These calculations are done assuming the new system's only change is that damage done is calculated using full strenght power.

Thalassicus
Jan 07, 2006, 04:55 AM
Do you know if it's possible to have a single formula give the odds of success, for use in spreadsheets?

It seems to be a statistics question, but I haven’t taken a course in that in some time :)

Without first strikes taken into account, it could be described like this:

Players A and B have a P(A) and P(B) chance to win a round in a game
When they win a round, they receive points equal to Ta and Tb
X points are required to win the game
Find the formula for W(A), the probability A will win the game

(EEp, the memories! :lol:)

Even first strike could likely be worked into a formula, it's probability-based and dependent on the same variables (although harder to deduce).

It's going to be incorporated into a table to compare the cost-benefit of different naval vessels (where terrain doesn't play as much of a factor) based on strength, cost, and other factors (like chance to withdraw or board). The strength is used to calculate combat odds, cost is used to find the number of units required to have an even battle, and the final average hammers lost or gained are then calculated. The break even point can then be found where one unit type will (on average) lose the same number of hammers when engaging another in combat, and combat stats adjusted accordingly depending on which unit is ment to counter the other.

Roland Johansen
Jan 07, 2006, 06:04 AM
Somebody already did this and made a program to calculate the probabilities: program to calculate chances of victory in combat (http://c4combat.narod.ru/c4c.htm)

I think the basic idea is the following. Based on the comparitive strengths of the units, you can calculate how much damage each unit does if it wins a round of combat and the chance that it wins a round of combat (see the first post of Arathorn in this thread). Using these amounts of damage, you can calculate how many times a unit has to score a hit to do a total damage that is equal to or exceeds 100 hitpoints. Say that unit A has a chance to win a round of combat of A_chance and needs to score a hit for A_times to kill unit B and that unit B has a chance to win a round of combat of B_chance and needs to score a hit for B_times to kill unit A (note that A_times, B_times, A_chance and B_chance are directly dependent on the relative strengths of the units (and their starting hitpoints) as described in Arathorns article.

Then the chance for A to win the battle is:

{sum x= 0 to B_times - 1} (A_times -1 + x)! / ( (A_times -1)! * x! ) * A_chance^A_times * B_chance^x

Note that A_chance + B_chance =1 and x^y is a notation to denote x to the power y. It's a bit difficult to describce the formula without the correct mathematical symbols. It looks a bit ugly in this format, I can't help that.

Thalassicus
Jan 07, 2006, 10:39 AM
I think that's what I was looking for. Have I got this right?

http://img277.imageshack.us/img277/4669/formula3oh.png

a, b = # rounds to win combat
P(A), P(B) = Probability of A and B to win a round

Do you know how to enter sigma notation with upper and lower limits in Excel? The Sum function name is reserved for adding together cells. I've tried Sigma() and Summation() and looked around the menus...havn't found anything. http://www.simtropolis.com/idealbb/images/smilies/41.gif

Thalassicus
Jan 07, 2006, 11:47 AM
Thank you! I plugged that formula into my calculator and it worked great! The only change was the upper limit of the summation to b, rather than b-1 (additional iteration).

Thank you very much! :clap:

Now I just need to figure out how to get it into Excel...

This'll make it much faster to balance new units than going back and forth to calculate combat results constantly :)

Requies
Jan 07, 2006, 12:25 PM
I think that's what I was looking for. Have I got this right?

http://img427.imageshack.us/img427/1926/formula1ew.png

a, b = # rounds to win combat
P(A), P(B) = Probability of A and B to win a round

Do you know how to enter the summation formula (Sigma) in Excel? The Sum() function name is reserved for the summation of cell contents. I've tried Sigma() and looked around the menus...havn't found anything.

Hmmmm, couldn't you just use the sum based on their summing up of cells. And just have a series from 0 to b-1 of those cells?

Req

Thalassicus
Jan 07, 2006, 12:53 PM
Yeah, that would work. I'd think there would be a formula somewhere for it, though. Graphing calculators have it after all: Sigma(expr, var, low, up)...

I'll go with cell iterations. Do you know the syntax for a formula-defined cell reference? I think it's something like L1:"L"&(I7-1) (for the range of L1 to L (B-1), but I've used dynamic cell references maybe three times in ten years...don't have the syntax right :crazyeye:

It's remarkably hard to find anything in the "help" files on some topics.

DaviddesJ
Jan 07, 2006, 02:44 PM
Ignore this post.

Requies
Jan 07, 2006, 03:23 PM
Yeah, that would work. I'd think there would be a formula somewhere for it, though. Graphing calculators have it after all: Sigma(expr, var, low, up)...

I'll go with cell iterations. Do you know the syntax for a formula-defined cell reference? I think it's something like L1:"L"&(I7-1) (for the range of L1 to L (B-1), but I've used dynamic cell references maybe three times in ten years...don't have the syntax right :crazyeye:

It's remarkably hard to find anything in the "help" files on some topics.

Errrm, what are you trying to do? What's a formula-defined cell reference?

Req

Thalassicus
Jan 07, 2006, 06:00 PM
Rather than defining a cell reference Chance to Win = Sum(L1:L7), it's defined as Sum(L1:L(value of B), where B is a formula dependent on variables. It's a cell reference that's dependent on the a, which used to be done with concactenating the values you need together with the & sign, by defining the row and column references seperately. I think it might be a function call now, so I'm looking around.

Anyways, the final outcome of this is having a similar calculator for use in balancing units. When you attack an enemy stack with equal hammer-cost of units of your own, I'm using the average hammers remaining after the attack for an estimate of combat effectiveness. It's much easier than trying to eyeball many variables (some new gameplay mechanics). For example, to find the break-even point in value with a unit that has a 100% capture chance on the attack where cost (around 50) and withdraw rates are variable, compared to a unit costing 120 hammers and much higher strength. It spun my head trying to find a starting point until I decided to measure the ambiguous property of value with a more definable quantity like hammers remaining after engagements.

For example, I've found that if an equal hammer's-worth of Submarines with Flanking II attacks a stack of Battleships with Combat II (15 subs vs 10 battleships, 2250 hammers each), the attacker will lose an average 298 hammers in the engagement, with the defender losing an average of 18. This results in a significant net loss of hammers (this takes into account second-attacks where the defender is wounded). This is in comparison to equal stacks of battleships engaging, or battleships with aircraft, which are both currently better. The Destroyer is also a very useless unit type right now, since subs actually beat it on the defense (due to withdraw and lower cost), as do battleships.

To create good unit-counters with multiple variables (combat bonuses, withdraw, capture) the catch is then finding what bonuses the attacker might recieve that bring the cost-effectiveness to a break-even point. In the case of subs I slightly lowered their cost and gave them a combat modifier to bring them to 10% more effective than battleships when attacking that unit type, and gave destroyers a defensive bonus to make them better at countering subs.

This also works great when creating new units, to give a starting point on balancing and save a lot of playtesting :)

fed1943
Jan 08, 2006, 03:16 AM
I think that just considering the hammers forgets the beakers spended to research the necessary technologies.
Best regards,

Beamup
Jan 08, 2006, 06:59 AM
It's remarkably hard to find anything in the "help" files on some topics.
It would only be remarkable if you thought Micro$oft actually wanted you to be able to do anything with their products without paying through the nose for tech support...

Thalassicus
Jan 08, 2006, 10:40 AM
I think that just considering the hammers forgets the beakers spended to research the necessary technologies.
Best regards,
True, but what method could be used to take that into account? There's multiple research paths to come to any distinct technology, and most of the time the units have about the same beaker cost to reach (carriers, subs, and battleships are all at about the same level on the tech tree, for one).

Roland Johansen
Jan 08, 2006, 06:19 PM
Quite ambitious balancing tool, but probably really impossible to get it completely right. How much do you value the extra speed of the destroyer and the ability to intercept airplanes and see submarines compared to the raw power of battleships and their special ability to do collateral damage.

It's really difficult to balance units in Civ4 with all of these abilities, but your program could definitely help.

I can't help you with your excell problems, good luck!

eg577
Jan 09, 2006, 03:38 AM
Just my 2 cents, but in my experience it isn't really worth doing calculations with a complicated sum like that. I think you are better off writing a a program to run 1,000 simulated battles instead of using the formula. It is faster and easier to code. You can also get more information (like average hp) with a simple modification of the program, but you will double your complexity if you try to find a formula for average hp (it'll probably be like a double sum with an even messier summand).

If you want to stick with the sum formula, I think there is a way to do it in Excel. I never found a way in excel to do something like sum(expr,start,end), but it sounds like you've used excel more than me. In order to get a variable-sized-lengthed sum you can write a formula so that the summands become zero when you've exceeded the last term.

This can be done with absolute values:

b * { |b_max - b|/(b_max - b) + 1 }/2

If I did that correctly this returns the value of b when b<bmax and returns 0 when b>bmax. Make b_max a non-integer to avoid having an undefined cell.

Thalassicus
Jan 09, 2006, 05:54 AM
All I'm using a unified formula for is calculating pure combat results (chance of success and HP remaining on the loser), then use that result in many other cells. I agree it would get overly complex doing it all at once. :) You end up in the same place as using an iterative program to calculate individual rounds.

It's like the choice of iterative or recursive problem solving, both arrive at the same result through different methods.

I got it working though: found that they (being microsoft...) replaced the old operators with a new obscurely named "Offset" function. :rolleyes:

carn
Jan 09, 2006, 06:03 AM
a more definable quantity like hammers remaining after engagements.



How do you value very damaged units, like retreated subs?
i think it is wrong to give them full hammer value, as they will be easy targets, until they find time to heal.

Carn

tproc
Jan 09, 2006, 03:56 PM
eg577: I tried writing the program. Still working through bugs with promotions and such, but please check this out.
http://mywebpages.comcast.net/proc/civ4/index.html
Input willingly accepted.

Real reason I was reading this thread, did I miss it? How did 1.52 change combat calculations in reguards to health. Hopefully, it is here and I just did too much skimming

tproc
Jan 09, 2006, 03:59 PM
Found my answer about health... darn find on screen didn't work on previous pages.

mudhut
Jan 10, 2006, 12:22 AM
On the previous page people started to discuss the effects of patch 1.52 changing the combat calculation - but didn't really finish the discussion.

I understand that for wounded units, the unit's base (undamaged) strength is used for determining the damage done when a successful hit is made. Is this correct? Are there any other changes? Would love one of you statistical gurus to help me out.

-Mudhut

KingG
Jan 13, 2006, 07:58 AM
How does collateral damage, which is integral to combat, specifically work please ? I've seen mentions and searched the forums but am still unclear.

Does the attacker deal collateral damage (at half-rate, with D&A strengths modified only for attacker barrage bonuses) each round of combat he is successful ? It's mentioned early in the thread but I cannot be sure how to interpret.

Thalassicus
Jan 13, 2006, 11:21 AM
How do you value very damaged units, like retreated subs?
i think it is wrong to give them full hammer value, as they will be easy targets, until they find time to heal.

Carn
Very true, which has to be taken into account. I just use cost-effectiveness for one engagement as a starting point, and then take into consideration other factors like the important one you mention. Plus, you can't really be sure how useful a unit is until you actually try it out in several games. This helps me get an idea of what to use for inital values, and then adjust it from there -- it reduces the playtesting time needed to get a unit going :)

Arathorn
Jan 13, 2006, 12:19 PM
Does the attacker deal collateral damage (at half-rate, with D&A strengths modified only for attacker barrage bonuses) each round of combat he is successful ?

No. Collateral damage is a one-time thing, when the unit attacks. Whether the collateral-causing units wins, loses, retreats, etc. does not matter at all. A very-injured catapult can still deal pretty good collateral damage....

The first two posts in this thread actually expain it pretty well, I think.

Arathorn

KingG
Jan 13, 2006, 03:53 PM
Arathorn, I did some World Builder simulations to look at collateral damage to make sure I understood how collateral damage works. You were almost spot on in the initial post and that was before the patch so I don't know if the results I got are new to v1.52.

I had noticed that the messages about collateral damage, "you have done collateral damage to x units", aren't always right and I think I have the answer.

After my tests it seems to me -

The attacker does a number of collateral damage hits that is one less than the number of defenders regardless of their HPs, up to the maximum allowed for the unit (for the cats in my testing this was six); and the amount of damage was as you said.

For each collateral hit, a unit in the defending stack that is not the primary defender is selected and the damage is taken from its HPs with the proviso that it may not drop below the minimum (50% for cat attacks).

One defender can take more than one collateral hit and it also seems that units below the damage threshold can be selected, which will make one of the collateral strikes effectively harmless.

So basically, the numbers of strikes, and the targets of the strikes, don't seem to be dependent on whether defending units were already below the collateral threshold. I am not sure the selections are random but there is multiple damage done to some units and when units are below the threshold fewer effective collateral strikes are possible.

"... collateral damage to x units" really means "x collateral hits to the stack".

Thanks for a great article.

slothman
Jan 15, 2006, 08:14 AM
OK I attempted to get the odds from the various posts.
This may be very hard to understand.
The sum function should be the same as the png file shown.

First defining these variables:
Ha and Hb are the starting hit points
A and B are the modified strengths of the units

Pa and Pb are the odds of one round;
A/[A+D] and D+[A+D]

La and Lb are the hp losses;
floor(20*[3A + D]/[3D + A]) and floor(20*[3D + A]/[3A + D])

a and b are the number of rounds required to win;
roundup(Ha/La) and roundup(Hb/Lb)

Does that mean the chance of the whole battle and therefore loss of one unit is?
percent = sum{"i=0->[b-1]","(a-1+i)!/([a-1]!*[i]!*[Pa]^a*[Pb]^i)"}
And the result hitpoints is the starting hitpoints - number of
lost rounds*hitpoints defender can do per round?

All this assumes no first hit or retreat or anything.



An example is:
Attacker is preatorian with 90 starting HP and 8.8 modified strength.
Defender is swordsman with 100 starting HP and 6.2 modified strength.

A = 8.8
D = 6.2
R = 8.8/6.2 = 1.42

Pa = 8.8/[8.8+6.2] = 8.8/15 = 0.59
Pb = 6.2/[8.8+6.2] = 6.2/15 = 0.41

La = floor(20*[3*8.8 + 6.2]/[3*6.2 + 8.8]) = floor(20*32.6/27.4) =23
Lb = floor(20*[3*6.2 + 8.8]/[3*8.8 + 6.2]) = floor(20*27.4/32.6) =32

a = roundup(90/23) = roundup(3.91) = 4
b = roundup(100/32) = roundup(3.13) = 4

battle chance is:

sum{"i=0->[4-1]","(4-1+i)!/([4-1]!*[i]!*[0.59]^4*[0.41]^i)"}
sum{"i=0->3","(3+i)!/(3!*[i]!*[0.12]*[0.41]^i)"}


i=0 ;(3+0)!/(3!*[0]!*[0.12]*[0.41]^0) = 3!/(6*1*0.12*1)
i=1 ;(3+1)!/(3!*[1]!*[0.12]*[0.41]^1) = 4!/(6*1*0.12*0.41)
i=2 ;(3+2)!/(3!*[2]!*[0.12]*[0.41]^2) = 5!/(6*2*0.12*0.17)
i=3 ;(3+3)!/(3!*[3]!*[0.12]*[0.41]^3) = 6!/(6*6*0.12*0.07)

battle chance = (6/0.72 + 24/0.30 + 120/0.24 + 720/0.30)
battle chance = (8.33 + 80 + 500 + 2400) = (2988.33)%

That is of course a false number.
Where did I go wrong?

Roland Johansen
Jan 15, 2006, 06:40 PM
OK I attempted to get the odds from the various posts.
This may be very hard to understand.
The sum function should be the same as the png file shown.

First defining these variables:
Ha and Hb are the starting hit points
A and B are the modified strengths of the units

Pa and Pb are the odds of one round;
A/[A+D] and D+[A+D]

La and Lb are the hp losses;
floor(20*[3A + D]/[3D + A]) and floor(20*[3D + A]/[3A + D])

A number of posts ago (post 204-212), it was concluded that after patch 1.52, the hitpoint loss was based on the base strength not modified for hitpoint loss. The odds of winning one round are still based on the modified strengths.

a and b are the number of rounds required to win;
roundup(Ha/La) and roundup(Hb/Lb)

Does that mean the chance of the whole battle and therefore loss of one unit is?
percent = sum{"i=0->[b-1]","(a-1+i)!/([a-1]!*[i]!*[Pa]^a*[Pb]^i)"}
And the result hitpoints is the starting hitpoints - number of
lost rounds*hitpoints defender can do per round?

All this assumes no first hit or retreat or anything.

Yes, that is correct.



An example is:
Attacker is preatorian with 90 starting HP and 8.8 modified strength.
Defender is swordsman with 100 starting HP and 6.2 modified strength.

A = 8.8
D = 6.2
R = 8.8/6.2 = 1.42

Pa = 8.8/[8.8+6.2] = 8.8/15 = 0.59
Pb = 6.2/[8.8+6.2] = 6.2/15 = 0.41

Correct (allthough I don't know if the probabilities are rounded at two decimals, I seriously doubt that. But it can only produce some rounding error at the end, nothing big.)

La = floor(20*[3*8.8 + 6.2]/[3*6.2 + 8.8]) = floor(20*32.6/27.4) =23
Lb = floor(20*[3*6.2 + 8.8]/[3*8.8 + 6.2]) = floor(20*27.4/32.6) =32

Based on base strength (praetorian base strength 9.8? 0.9 * 9.8 = 8.8) it becomes:
La = floor(20*[3*9.8 + 6.2]/[3*6.2 + 9.8]) = floor(20*35.6/28.4) =25
Lb = floor(20*[3*6.2 + 9.8]/[3*9.8 + 6.2]) = floor(20*28.4/35.6) =15

Note that there was an additional calculation error in that second calculation of yours. Only one of the units can do more than 20 damage per round when using these formulas.

a = roundup(90/23) = roundup(3.91) = 4
b = roundup(100/32) = roundup(3.13) = 4

La is the amount of damage that A does to B per round so (A has the higher strength and thus does more damage):
a = roundup(90/15) = roundup(6) = 6 (number of rounds B needs to win to defeat A)
b = roundup(100/25) = roundup(4) = 4 (number of rounds A has to win to kill B)


battle chance is:

sum{"i=0->[4-1]","(4-1+i)!/([4-1]!*[i]!*[0.59]^4*[0.41]^i)"}
sum{"i=0->3","(3+i)!/(3!*[i]!*[0.12]*[0.41]^i)"}


i=0 ;(3+0)!/(3!*[0]!*[0.12]*[0.41]^0) = 3!/(6*1*0.12*1)
i=1 ;(3+1)!/(3!*[1]!*[0.12]*[0.41]^1) = 4!/(6*1*0.12*0.41)
i=2 ;(3+2)!/(3!*[2]!*[0.12]*[0.41]^2) = 5!/(6*2*0.12*0.17)
i=3 ;(3+3)!/(3!*[3]!*[0.12]*[0.41]^3) = 6!/(6*6*0.12*0.07)

battle chance = (6/0.72 + 24/0.30 + 120/0.24 + 720/0.30)
battle chance = (8.33 + 80 + 500 + 2400) = (2988.33)%

That is of course a false number.
Where did I go wrong?

Here is the big error. You're dividing instead of multiplying a part of the formula.

Chance that A wins 4 rounds and B 0:
((3+0)!/3!* 0! )* 0.58667^4 * 0.41333^0 = 0.1185
Chance that A wins 4 rounds and B 1:
((3+1)!/3!* 1! )* 0.58667^4 * 0.41333^1 = 0.1959
Chance that A wins 4 rounds and B 2:
((3+2)!/3!* 2! )* 0.58667^4 * 0.41333^2 = 0.2024
Chance that A wins 4 rounds and B 3:
((3+3)!/3!* 3! )* 0.58667^4 * 0.41333^3 = 0.1673
Chance that A wins 4 rounds and B 4:
((3+4)!/3!* 4! )* 0.58667^4 * 0.41333^4 = 0.1210
Chance that A wins 4 rounds and B 5:
((3+5)!/3!* 5! )* 0.58667^4 * 0.41333^5 = 0.0800

Summed up = 0.8851

This is a probability, a number between 0 and 1. To get a percentage chance, it has to be multiplied by 100, which results in a 88.51% chance. I hope that I didn't make any errors. You really should use a combat calculator to do this.

Roland Johansen
Jan 15, 2006, 06:41 PM
I just noticed something:

The combat calculator that I linked in post 214 (I don't actually know who created it) doesn't take into account the change in patch 1.52 where damage dealt became based on base strength value (not modified for hitpoint loss).

I think that the changelog of the patch is pretty clear in this, but did anyone actually test if damage dealt is based on maximum strength or based on actual strength (adjusted for hitpoint loss)?

carn
Jan 16, 2006, 03:16 AM
I just noticed something:

The combat calculator that I linked in post 214 (I don't actually know who created it) doesn't take into account the change in patch 1.52 where damage dealt became based on base strength value (not modified for hitpoint loss).

I think that the changelog of the patch is pretty clear in this, but did anyone actually test if damage dealt is based on maximum strength or based on actual strength (adjusted for hitpoint loss)?

I didn't test, but my poor swordsman and cho-ko-nu tested at delphi. Annoying longbowman always did 25 damage even if they started with health <20 into combat.

Carn

Roland Johansen
Jan 16, 2006, 05:59 AM
I didn't test, but my poor swordsman and cho-ko-nu tested at delphi. Annoying longbowman always did 25 damage even if they started with health <20 into combat.

Carn

I remember similar things. I guess that calculator is out of date.

ZippyRiver
Jan 16, 2006, 12:22 PM
Damaged units can inflict the same damage as a full health unit This is the damage potential for the unit.

However, I have plenty of examples where the damaged unit won rounds at a rate expected from one undamaged. So it appears that damage is not taken into account when determining who wins the round. Give the AI a mixed stack of defenders, and give yourself 2 specialized units. If the first unit gets destroyed, but damages the defender, note the combat log. Attack with your second unit. Even if the first defender is damaged to a point that the second-in-line defender (slightly lower base potential damage) should step up, it will still select the damaged one instead.

You also see this regularly when attacking with fighters. Hitting a city with say 2 infanty, one of them has city defence 1. The city def one unit will still defend after sustaining damages.

edit:
To simplify my point, I believe the only thing damage does is reduce hit points. It has no effect anywhere else.

Roland Johansen
Jan 16, 2006, 02:30 PM
According to tests done in version 1.09 of this game, it works as described in the first post. Chance to hit is based on actual strength modified for the unit's hitpoints. It could have changed in version 1.52. I haven't seen any tests with that version, so maybe the article is not up to date and you are right that it has changed. It is clear (by looking at the combat logs) that damage done is based on full unit strength in version 1.52. It was based on actual unit strength in version 1.09.

But on the other hand, your observations aren't really scientifically presented. If you think the article is wrong, then you should do some tests that show that the chance to hit is based on full hitpoint strength.

I believe that the original writer of the article has become slightly less interested in researching the combat mechanics as he hasn't posted a lot in this thread for a while. It is quite understandable as he has done a lot of work to establish the formulas in the first post and in the patch they changed some things again.

ZippyRiver
Jan 16, 2006, 03:03 PM
Oh yeah. I am very appreciative of the OP and the work put into this. But alas, some of the info is outdaded. I was replying to a post, keeping 1.52 in mind as that is the most current and wide spread version.

There currently is good discussion going on (including screenshots) on combat 1.52 under general discussions (combat 1.52). We're just looking at numbers and probabilities of specific examples.

Celebithil
Jan 22, 2006, 09:38 AM
I'm too lazy too test it myself now, but with the new real combat odds given in patch 1.52 next to the strengths of units, you can easily calculate what the odds of winning a round should be, and thus test if it's based on full health units or not.

Roland Johansen
Jan 22, 2006, 11:03 AM
I'm too lazy too test it myself now, but with the new real combat odds given in patch 1.52 next to the strengths of units, you can easily calculate what the odds of winning a round should be, and thus test if it's based on full health units or not.

This assumes that the ingame combat odds calculator is correct which is not true. There have been multiple reports in the bug forum that the ingame calculator produces victory percentages of over 100% which obviously can't be correct.

TheVictor
Jan 23, 2006, 08:47 AM
Hello,

I have another question : I have a few swordsmen, all level 4 ( 3 promotions and 10 of 17 XP ) who fight only against barbarian archers. The problem is, they don't get any more XP from these fights once they've reached this level.

Why?! I thought the minimum XP you get is 1?

Thanks

Victor

Zombie69
Jan 23, 2006, 09:26 AM
XP from animals is limited at 5 total, and from barbarians it's limited at 10 total. Try using more inexperienced units instead and bring them up to 10 XP as well.

_alphaBeta_
Feb 02, 2006, 03:00 PM
Great original post.

Quick question - When a warrior attacks an animal of strength 2 in the early game the strengths read something like "2 vs. 1.8" There are no other attributes listed in the odds window to explain how a 2 strength animal got reduced to 1.8 (or something similar). Is this a game difficulty issue? This happened on noble.

I believe the same happens with barbarians as well.

DaviddesJ
Feb 02, 2006, 03:14 PM
Quick question - When a warrior attacks an animal of strength 2 in the early game the strengths read something like "2 vs. 1.8" There are no other attributes listed in the odds window to explain how a 2 strength animal got reduced to 1.8 (or something similar). Is this a game difficulty issue? This happened on noble.

I believe the same happens with barbarians as well.

These handicap adjustments are specified in Civ4HandicapInfo:


Handicap iAnimalBonus iBarbarianBonus

Settler -70 -40
Chieftan -60 -30
Warlord -50 -20
Noble -40 -10
Prince -30 -5
Monarch -20 0
Emperor -10 0
Immortal -5 0
Deity 0 0


I don't know exactly how these translate into the combat statistics.

_alphaBeta_
Feb 02, 2006, 03:35 PM
Ok, at least I'm not crazy. It's clear that some kind of advantage is given to the player over animals and barb units at lower difficulties. This handicap definitely applies when attacking barb units, but it will be hard to know if it has an effect defensively. Either way, this answers my question so thank you!