Combat Explained....

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
 
Arathorn said:
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:
 
Beamup said:
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.
 
Aminor said:
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)
 
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.
 
double post
 
Uniqueuponhim said:
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.


Uniqueuponhim said:
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.



Uniqueuponhim said:
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.
 
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.
 
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
 
Aminor said:
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.
 
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.
 
@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
 
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.
 
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
 
Beamup said:
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.
 
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.
 
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.
 
eg577 said:
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?
 
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?
 
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:
Code:
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")
 
Top Bottom