Combat Odds

I often win at low odds.
When Im trying to soften up a mob with a skeleton so my adept can get the kill.
 
For your tests I would recommend samples of identical units on each side and the same odds rather than just bunches of different units. You're probably tracking results in a game but it would be cool to see:

1. 100 swordsmen attacking 100 warriors with both in grasslands.
2. 100 swordsmen attacking 100 warriors on a hill (do terrain bonuses mess with the odds?).

ok here the results (500 combats tested):

1. should be 78,3 % (got 79,4 %)
2. should be 66,4 % (got 66,8 %)

seems alright and slightly better than showed.
 
Cool analysis, Im very interested.

Keep in mind that combat odds are an estimation. The game approximates your chance of winning, but it isnt like it just roles those odds to determine the combat. The real combat is a whole series of attacks and defenses, with modifiers and bonuses adjusting the odds in different ways. So it may not be exact, but it should be pretty close in large samples.

For your tests I would recommend samples of identical units on each side and the same odds rather than just bunches of different units. You're probably tracking results in a game but it would be cool to see:

1. 100 swordsmen attacking 100 warriors with both in grasslands.
2. 100 swordsmen attacking 100 warriors on a hill (do terrain bonuses mess with the odds?).
3. 100 swordmen attacking 100 warriors with dance of blades (do first strikes mess with the odds?).

That kind of testing may help us if there a significant descrepancy is shown.

Notably for the large scale tests of identical units - use "Stack Attack" and count the survivors to determine the number of victories.
 
I'm not too convinced with the tests goin on, as most of them seem to be tests of base, non-upgraded units against eachother. I think alot of the "possible" problems have to do with all of the promotions a unit might recieve. It seems your heavily promoted units, or else heavily promoted targets/enemies are the ones where combats don't always seem to fit the percentages, and the computer units always seem to have a ton of promotions.

I will agree that you definately remember the combats you lose, but I'm totally fine with losing every once in a while with a 95%+ odd. But at the same time, it seems like when you have odds in the 70%'s, it's almost like a grand victory to actually win one. Seems like you get that 74% odd battle that you can't avoid starting, and if you win, it calls for a celebration as it's so rare. But again, I think my problems relate to heavily upgraded units, I would hope Civ4 would be able to calculate a simple Str5 unit vs a Str7 unit with no buffs.

All in all though, this is a problem that can be dealt with (if it really is a problem ;) ), you just don't do combats below 80%, and you don't do combats with hero or favored units under 96%. The current FFH mod is amazing, and all of the work done with recent patches and up and coming patches sound great, so this "possible problem" could take a back seat for all I care. Whatever free time you guys have to devote to working on the mod I'm sure could be put to better use for the time being, as said, there are ways to deal with this.
 
I'm not too convinced with the tests goin on, as most of them seem to be tests of base, non-upgraded units against eachother. I think alot of the "possible" problems have to do with all of the promotions a unit might recieve. It seems your heavily promoted units, or else heavily promoted targets/enemies are the ones where combats don't always seem to fit the percentages, and the computer units always seem to have a ton of promotions.

I will agree that you definately remember the combats you lose, but I'm totally fine with losing every once in a while with a 95%+ odd. But at the same time, it seems like when you have odds in the 70%'s, it's almost like a grand victory to actually win one. Seems like you get that 74% odd battle that you can't avoid starting, and if you win, it calls for a celebration as it's so rare. But again, I think my problems relate to heavily upgraded units, I would hope Civ4 would be able to calculate a simple Str5 unit vs a Str7 unit with no buffs.

All in all though, this is a problem that can be dealt with (if it really is a problem ;) ), you just don't do combats below 80%, and you don't do combats with hero or favored units under 96%. The current FFH mod is amazing, and all of the work done with recent patches and up and coming patches sound great, so this "possible problem" could take a back seat for all I care. Whatever free time you guys have to devote to working on the mod I'm sure could be put to better use for the time being, as said, there are ways to deal with this.

Excellent post. You state the problem well, and give a good solution.

I really haven't played vanilla civ/BtS much, but I tried not too long ago and I honestly didn't think there was as much of a problem with the combat odds as you see in FFH. Maybe it does have something to do with all the add-ons that bring that outstanding flavor of the mod to us.

It really is easy to write here how much this whole thing doesn't bother us, but if you lose a fully promoted Beastmaster to a lowly orc axeman like I just did...well, that has all happened to us and you just cuss, bang the table and move on. ;)
 
The first time I used the WB and saw how annoying placing specific units/giving specific units specific promotions was, I kind of decided I wouldn't bother with WB any more.
But now that I've read you can edit maps via notepad, what would one have to do to give e.g. a stack of 100 warriors X specific promotions (always the same)?

Although intentional and a result of this combat system, the difference between e.g. str 3 v str 5 and str 10 vs str 19 is also rather counterintuitive, isn't it?

And I do agree that the remaining HP of a unit don't seem to make any sense whatsoever. If my hero wins with 99% odds and ends up with 10 HP or less, that not only means that these odds were a lot less certain (had he lost the final round, he would have lost, and losing one round is a lot more likely than 1%), but that they also don't make much sense. Likewise, it just seems counterintuitive to win really low% battles and the unit still has almost 100 HP.

First strikes could easily be bugged (and screw a lot with combat odds) - perhaps someone could test this between non-barbarians?
 
84/100 is still an accurate distribution in the +- range. Your experimental results will approach the theoretical yields as the number of trials reaches infinity. I.e. do a couple thousand more of those trials and average the results and I guarantee you will get 90.x% =)

I know much has been written about Combat Odds in Civ4/FFH. Many of us can remember that version in which the combat odds were really whacky.

Well, it seemed like in the latest version I was losing quite a few battles in which I was favored by what I would call overwhelming combat odds - 90% or greater. My definition.

Of course, you always tend to remember those losses and sometimes lose track of the many combat victories you are piling up.

Anyway, as a retiree, I have plenty of time on my hands, so I decided to run a small sample test during my current game. I charted 100 battles where I had combat odds of 90% or greater.

Care to guess how many of those battles I won?

How about 84?

Included in the 100 were 37 battles where the odds were 99.9%. A sure thing, right? I lost three of those.

It was a small sample size and I'm not sure you can conclude anything from the test. Honestly, I thought I would have more than 16 losses in the 100 battles. It just seemed like I was losing more battles when I was heavily favored to win in my games.

One thing I have noted is that if you win quite a few battles when the odds are high, you can bet your string will end, even with the high odds. I guess that makes sense. But, it is really annoying to win a few battles and then lose that veteran unit when the odds are 98.6% to win.

Of course, the flip side of this is how many battles you win when the odds are heavily against you. I find you win very few of those, perhaps less than even the low odds would indicate. But, really, I think most of us would avoid battles, especially with good units, when the combat odds are low. It does seem, though, that you often, and I mean often, lose the 60-70% battles a lot more than you win as the odds would indicate.

Anyway, maybe my next test will be to run a sample of battles where the odds are 10% or less and see how many I would win.

For the statistician purists out there, I apologize if my simple test and analysis offends you - just wanted to see if there was any kind of pattern with all those 90+% battles I was losing. :)
 
Okay, so here's the monkey wrench:

These aren't huge samples, but are very... telling.

First take 28 Wraiths pitted vs 28 Iron Golems.
IG's are strength 10,and immune to death.
Wraiths are Strength 6 + 3 death.

Combat odds show Wraiths having about 4% chance of victory. They win 3 times out of 28. So we are about right there. Odds computed showed a strength 10 vs a strength 6 unit (Makes sense, they are immune to death).

Second, however, we have 43 Spectres vs 43 Wood Golems.

The spectres have death affinity, and 3 sources of Death, so show as have 6 Strength (3 + 3 Death)
Wood Golems are strength 6 and have immunity to death.

Combat odds show Spectres with .9% (!) to win against the Golems. IT shows a strength 6 Golem vs a strength 3 Spectre. This still looks right because the golems are immune to the death damage.

HOWEVER. When we fight these 43 combats, the spectres win 29 of 43 combats. Further more, checking the combat log shows them as strength 6 vs the golems. (Whereas the combat log for the wraiths showed them as strength 6 as well, which meant the death damage wasn't calculated).

Conclusion: I suspect that the effects which check for immunity in the combat code, trigger BEFORE the effects which check for affinity. So units with immunity are immune to only built in effects, not those based by affinity.
 
Okay, so here's the monkey wrench:

These aren't huge samples, but are very... telling.

First take 28 Wraiths pitted vs 28 Iron Golems.
IG's are strength 10,and immune to death.
Wraiths are Strength 6 + 3 death.

Combat odds show Wraiths having about 4% chance of victory. They win 3 times out of 28. So we are about right there. Odds computed showed a strength 10 vs a strength 6 unit (Makes sense, they are immune to death).

Second, however, we have 43 Spectres vs 43 Wood Golems.

The spectres have death affinity, and 3 sources of Death, so show as have 6 Strength (3 + 3 Death)
Wood Golems are strength 6 and have immunity to death.

Combat odds show Spectres with .9% (!) to win against the Golems. IT shows a strength 6 Golem vs a strength 3 Spectre. This still looks right because the golems are immune to the death damage.

HOWEVER. When we fight these 43 combats, the spectres win 29 of 43 combats. Further more, checking the combat log shows them as strength 6 vs the golems. (Whereas the combat log for the wraiths showed them as strength 6 as well, which meant the death damage wasn't calculated).

Conclusion: I suspect that the effects which check for immunity in the combat code, trigger BEFORE the effects which check for affinity. So units with immunity are immune to only built in effects, not those based by affinity.

We recently discovered in another thread that damage resistance isnt being calculated correctly. So if you attack with the Wraith that defending Iron Golem doesnt get to ignore the death damage. That could be a lot of the reson people are seeing odd combat results. It will be fixed in 0.33, until then any combat odds tests should be run without and resistance situations.
 
I ran one using dance of blades on 100 warriors vs 100 normal warriors, no other mods. All on grassland. 56.8% victory chance. 62% win, or 62 warriors that I had left, 38 that Keelyn had left. That's a 5% deviation. I consider that pretty good, but make of it what you will. I hope that helps the first strike thing.
 
I have replicable proof that first strikes are not always handled correctly when calculating combat odds.

Edit the XML so that warriors (strength 3) have 500 first strikes.
Use World Builder to create warriors and a Margalards (strength 22 orangutan , no special abilities) on adjacent grassland

The combat odds will display as <0.1%, but out of 100 attempts I won every one of them.


This is an extreme example, but it was designed to demonstrate a discrepancy in the way combat odds are calculated when first strikes are involved.

I repeated this test because nobody seemed to take it seriously/everybody thought it was due to difficulty settings and barbarian autowins.
The quoted post is correct. I've placed 15 stacks of 2 warriors each with 500 First Strikes (not First Strike chances) belonging to me as Sabathiel Bannor against 10 stacks of 2 Margalards each and 5 stacks of 2 Avatars of Wrath each, all of which belonged to Valledia of the Amurites.

First of all, displayed combat odds with alt + mouseover were 0.1%, and 0.0% in the combat logs. Not only did all of my warriors win with full hp (i.e. none of the 30 warriors received even one hit), which shows there's a serious problem (although the value of 500 First Strikes is extreme, that doesn't make the problem any less severe - 4-7 First Strikes is very possible with Drill I-IV, for example, although I don't know how First Strike Chances would work), but they also received respectively 234 XP against the Margalards and 352 XP against the Avatars, meaning that the calculated XP actually takes the displayed odds into account and not the real odds of (Close to? I never lost, but chance dictates that the number must be below 100% unless there's another bug somewhere...) 100%.

If you want to test this yourself, follow these steps:

1) All Warriors have been changed in the file Fall From Heaven 2 032\Assets\XML\Units\CIV4UnitInfos.xml to have 500 First Strikes. To do this manually, you have to search for <type>unit_warrior and then for <iFirstStrikes>. Then change <iFirstStrikes>0</iFirstStrikes> to <iFirstStrikes>500</iFirstStrikes>. Remember to make a backup of the file beforehand and change this back afterwards or your games will go very, very quickly from now on :P.
You have done this correctly if the Warriors ingame have 500 First Strikes.
2) Start FFH II after doing changes. (it may be possible to reload the XMLs without restarting FFH, but I have 0 experience with modding, so I don't know how to do that)
3) Take this save file: http://www.sendspace.com/file/m9dq6e and place it in your BTS saves folder, then load it normally as a Singleplayer game. It's not perfect as I still have my normal starting units etc., but otherwise it gets the job done :P.

Basically, the two bugs are #1 that the displayed combat odds are the calculated combat odds (this is different to i.e. the damage resistance bug) - displayed as 0.0%, really nearly 100%. #2 that the calculated experience also takes these combat odds into account; you get totally absurd amounts of experience.

The only thing changed from normal FFH to this case is the number of First Strikes, so there's a (possibly huge) bug with First Strikes (and probably not related to FFH, but a general Civ4/BTS bug). It's really quite logical to win every fight with so many First Strikes, though - the Warriors basically get 500 shots at winning combat rounds without enemy retaliation, and they apparently deal 8 damage per round, so they only have to win 13 of 500 rounds to win unharmed.
According to this article, the chance to win a combat round is A/(A+D), or modified strength of attacker divided by (modified strength of attackers + modified strength of defender), therefore 3/(33+3) for Warriors against Avatars, or 1/12. We were supposed to learn this at school, but I completely forgot the formula needed for this - in any case, it's basically guaranteed to win 13 out of 500 combat rounds with a chance per round of about 8.3%.

Great job finding that out, DrStalker! I wonder whether this problem can be fixed easily, though...

EDIT: I don't know why, but if you press next turn and let the AI do the attacking, it only (sometimes) attacks the warriors with the Avatars and never with the Margalards. I have no idea why that is, though - neither Avatars nor Margalards nor the summoned Iras have any chance of winning whatsoever.
 
Could you guys go a bit further with the massive First Strike tests please?

Set the warrior to 1 Strength, and his opponent to 100. See if you still always win with 500 First strikes.

If you do (yikes!) try it at a Warrior Strength of 0. Hopefully you lose then. If so, go back to Warrior Strength of 1, and start reducing the number of first strikes, see how close to 20 you can get.


My fear is that a First Strike might be an automatic hit, rather than a "you can't hit me if I lose" like it is supposed to be. Cause realistically in 500 hits it should be pretty hard for a 3 strength warrior to succeed at the 18 or so that he needs against a 18 strength opponent so consistently
 
Could you guys go a bit further with the massive First Strike tests please?

Set the warrior to 1 Strength, and his opponent to 100. See if you still always win with 500 First strikes.

If you do (yikes!) try it at a Warrior Strength of 0. Hopefully you lose then. If so, go back to Warrior Strength of 1, and start reducing the number of first strikes, see how close to 20 you can get.


My fear is that a First Strike might be an automatic hit, rather than a "you can't hit me if I lose" like it is supposed to be. Cause realistically in 500 hits it should be pretty hard for a 3 strength warrior to succeed at the 18 or so that he needs against a 18 strength opponent so consistently

I'll test that, too. As I said, though, even against a 33 str target (Avatar of Wrath), the Warrior still dealt 8 damage per won round (and according to the linked article, this value is capped at 6 damage, so you'd never need to win more than 17 rounds against an opponent with the maximum of 100 HP), so he still only needed to win 13 rounds at 1/12 = 8.33% winning chances.
Can a strength 0 warrior even attack?
EDIT: In any case, all I know about how combat works comes from the article I linked above. If it is correct, then it's completely obvious that the Warriors would win, and there's just a problem with the combat odds.

I'll report back after I've tested this. Can you tell me how to reload the XML without restarting the game?
 
i tested it too.
warrior strength 1 and 500 first strikes vs axeman strength 100.
the displayed combatchance was < 0.1 and all warriors lose the combat (tested 35). the axeman with the worst hp has 36 health left.

so i'll try to set the strength of the axeman down until the first warrior win a battle.
 
Unfortunately you can't reload the XML unless you restart the game.

I forgot you had linked an article on the details for combat. Was going off nearly 1 year old memory from a similar article :)

As long as it makes sense that the warrior CAN win in those combats, no worries about going any further. It has accurately portrayed that the combat odds just come out wrong for large quantities of first strikes.

Mayhaps the combat odds could be re-written to account for first strikes, then re-calculate probable strength values based on assumed damage, THEN run the rest of the non-first strike odds calculations.

Though it'd need all those other odds in order to calculate the probable outcome of the first strikes anyway, so it could get tricky to make that work out at all...
 
Set the warrior to 1 Strength, and his opponent to 100. See if you still always win with 500 First strikes.

If you do (yikes!) try it at a Warrior Strength of 0. Hopefully you lose then. If so, go back to Warrior Strength of 1, and start reducing the number of first strikes, see how close to 20 you can get.


My fear is that a First Strike might be an automatic hit, rather than a "you can't hit me if I lose" like it is supposed to be. Cause realistically in 500 hits it should be pretty hard for a 3 strength warrior to succeed at the 18 or so that he needs against a 18 strength opponent so consistently

~40 Str 1 Warriors with 500 First Strikes vs ~40 Str 100 Margalards: 0 wins, all of them have between 34 (once) and 100 (once) HP left.
10 Str 1 Warriors with 500 First Strikes vs 10 Str 22 Margalards: 10 wins, all Warriors unharmed. Oh, and all of them received 704 XP.

I tried Warriors with Strength 0, but they couldn't even attack (same as e.g. Workers). According to the article about combat, their chance of winning a round would be 0/strength of defender, or 0, so they wouldn't be able to win combat in any case.

I won't test to see how many First Strikes make a win reasonably certain or impossible, that involves too much changing in the XML (and I had to place new Warriors in WB everytime I changed something in the XML, and I have no clue why/what I'd have to do differently). At the very least I'll wait with that until someone can tell me why the game doesn't display the correct odds.
In any case, damage per turn is indeed capped, which is why the Warriors in the Str 1 vs Str 100 fight still dealt 6 damage per won combat round. (I think the Margalards dealt ~58 damage, so 60 sounds like a reasonable cap for the other side).

Oh, and the savegame I linked sadly didn't have "New random seed on reload" activated, so bear that in mind. I had to save the game in WB and load it as a custom scenario to activate this option (which is absolutely necessary for this sort of testing, although it doesn't make my test in my last post any less valid).
 
The problem CIV4 has in determining combat chances in view of a large number of first strikes might be due to memory limitations and, possibly, rounding errors. A CIV4 combat never lasts longer than (17+first strikes) rounds --- in the most extreme case, the stronger unit needs 2 hits and the weaker unit 16 hits for a kill. This normally small number of rounds makes it easy to compute the winning chance exactly. If the number of first strikes is high, then an exact calculation is not feasible any more, because it would need to much time and memory (and the possibility to avoid rounding errors).

It is very probable that the programmers of CIV4 have (strongly) limited the amount of memory (or number of calculation steps) the combat chance calculator is granted, so exact calculations for high number of first strikes might not be possible.


Ad first strikes/first strike chances/automatic hits:

400 Str 1 Warriors with 500 first strikes vs. 400 Str 100 Bloodpets with 0 first strikes: no kills -> so, very probably first strikes are treated correctly and not as automated hits.


And for all those of you who always wanted to know how first strike chances are treated I've tried the following experiment:
2000 Str 4 Warriors with 45 first strike chances vs. 2000 Str 7 Bloodpets with 32 first strikes.

Basically, there are two possibilities (at least, they are the most obvious ones):
i) the warriors randomly have any number between 0 and 45 first strikes, every number has the same probability. Using the combat chance calculator at http://c4combat.narod.ru/c4c.htm, one finds that in this case the winning chance for the warriors should be well above 5% (7.1% are displayed by the combat chance calculator).
ii) Every first strike chance gives you a 50% chance for a first strike (so a chance of 2^{-45} for no/45 first strikes, 45*2^{-45} for 1 or 44 first strikes, and so on). In this case, chances are high (more than 99%) that the warriors have 30 or less first strikes - and therefore their winning probability as well should be below 1%.

In the test 135 warriors (6.75%) survived, which strongly favors the first first possibility.
 
Yeah I dont have a lot of interest in the massive first strikes test. All it does is magnify the deviation that may exist, but Im okay with some deviation as it is only an estimation. For example if a unit with first strike shows 10% to win a battle but its actually 11% thats not a huge deal to me. Even if we are able to exacerbate that deviation by giving the unit 100 first strikes and showing that the displayed 11% is actually 100%.

So tests of extreme nmumbers are only valuable if we assume that these numbers are exact. And we know that they aren't.
 
the only problem with +-5% deviation is when a unit like a hero has 94% chance to win, when it is really 89% is almost double the chance for the hero to be lost
with 45-55% it actually isn't that significant
of course, heros on the attack are the ones that matter most to people so go figure...
 
the only problem with +-5% deviation is when a unit like a hero has 94% chance to win, when it is really 89% is almost double the chance for the hero to be lost
with 45-55% it actually isn't that significant
of course, heros on the attack are the ones that matter most to people so go figure...

+-5% is more just the standard deviation for a test that is inconclusive. That is, if we do 100 or 200 trials and only get a 5% discrepency, it's probably just luck of the draw, not an actual problem with the odds calculation.

The only fudge that appears to be happening is with really large numbers of first strike... numbers that aren't actually doable in the game. 4-7 just isn't going to make almost any difference, though it is regrettable the calculator doesn't seem to take them into quite the proper effect.
 
Back
Top Bottom