Combat Odds - A New Approach?

eldar

ChiefTank
Joined
Apr 19, 2004
Messages
3,244
Location
Mechanicsburg, PA
My current game has me thinking. Let me describe the real-world situation first, it's very basic: I am Egypt, and have War Chariots (2-1-2, 20s). My only current viable opponent is Carthage, who have Numidian Mercenaries (2-3-1, 30s). Just for completeness, it ought to be stated that both Civs have had their Golden Ages due to previous wars with the Ottomans, who are now an OCC and with whom I've just signed a peace treaty.

It's still relatively early in the game, and the Carthaginian cities are mostly sizes 1-6, and are mainly on flat land. The level is Emperor, and I'm anticipating 2 defenders per city outside of the capital, and 4 in the capital. These defenders I expect to be mostly Regulars, with 3hps, and I will be mostly attacking with Veterans, with 4hps.

If I plug these values into the Combat Calculator, it's an almost even split. It says I win about 1/3 of the time, I lose about 1/3 of the time, and I retreat about 1/3 of the time. Okay... so that maybe indicates that I need to take 3 units along per defender? I think intuitively, any experienced player wouldn't need to be told the odds. If you have a 2-attack unit vs. a 3-defense defender, taking 3 units per defender seems about "right" when you don't have artillery support (and I don't).

Can I come up with a different way of calculating that this intuition, and what the Combat Calculator is telling me, is right? That I will typically need to roll up 6 units per city I want to take, and probably a dozen or more for the capital?

Well, I think I've come up with something (and please forgive me if it's already been thought of).

What I'm interested in is not the odds, the percentages, and so on. What I'm concerned with is simply this:

How many rounds of combat will it take to kill the defender?

That will tell me how many hit points are lost, between attacker(s) and defender, during the combat. From this, I can work out how many attackers I am likely to require.

So let's get down to my example: War Chariot vs. Numidian Mercenary.

The attack value is simple: it is 2.
The base defense value is 3. The unit is on flat ground in a Town (size 1-6) (+10%) and is fortified (+25%), for a total defensive modifier of +35%. 3 * 1.35 = 4.05, the modified defensive value.

So the combat odds for each round is:
Attacker: 2 / (2 + 4.05)
Defender: 4.05 / (2 + 4.05)

This can be re-worded as the following:

The attacker wins 2 out of every 6.05 combat rounds.

Or:

After 6.05 combat rounds, the defender will have lost 2hps, and the attacker(s) will have lost 4.05hps.

Well, I want to know how many combat rounds will be required to take 3hps from the defender. Since 3 (the desired number of hps) divided by 2 (the number I already know about) = 1.5, multiplying the total number of combat rounds by 1.5 should give me the result I want. 6.05 * 1.5 = 9.075.

To take 3hps off a given defender will require 9.075 combat rounds. Since I can't actually fight 9.075 rounds, and 9 won't be enough, this figure will have to be rounded up to 10 combat rounds.

So in 10 combat rounds, the defender will be killed (probably).

If the defender loses 3hps, then my attackers, between them, will lose 7hps. They have 4hps each, so, if I'm really lucky, the first attacker will lose, and the second will win with 1hp left.

What if my first attacker retreats? It will have lost 3hps, meaning I still have, in all likelihood, 4hps to lose before the defender dies. My second attacker may die (50% odds of retreating with a Vet unit - if the first has already retreated, law of averages and so on, ahem!)

So all of this backs up the intuitive notion, and the hinted-at notion from the Combat Calculator, that 3 units are what is required to do the job.

What I'm not taking into account of here is the chance of the defender promoting, but other than the random chance of that happening, I'm not expecting an automatic promotion. The defender won't be killing 2 units, so won't get that chance. If, in doing this calculation, it looks like the defender will get a promotion, I'd have to go back and re-calculate, giving the defender an extra hp. If it looks like the defender gets a double promotion, re-calculate with +2hps for the defender.

General Method Outline

Here's an outline of the general method to use. It's not a perfect replacement for an iterative process such as the Combat Calculator, because promotions are random, and so are retreats, not to mention defensive bombardment, the possibility that you may have to take out a low-defense defender (such as an Archer or Longbow) in between main defenders, and so on. However it's a good starting guide to give a notion of how many units you're likely to need per defender, and in fact the more defenders, the more likely it is to be accurate. This method is probably statistically better for Sid than it is for Chieftan!

1. Note down attack strength (A) and number of attacker hit points (Ahp).
2. Work out the modified defensive strength from the base defense and modifiers (mD).
3. Note down how many hit points you need to remove from the defender (Dhp).
4. Now take the single-round combat odds formula:

AWinOdds = A / (A + mD)

And note that this implies that the defender will lose A hit points in (A + mD) combat rounds.

To work out how many combat rounds will, on average, be required for the defender to lose Dhp hit points, multiply (A + mD) by (Dhp / A).

So:

NumCombatRounds = (A + mD) * (Dhp / A)

Or this can be re-written as:

NumCombatRounds = Dhp * (1 + (mD / A))

Round up NumCombatRounds (always) to give the result, FinalCombatRounds.

Now you can work out how many attacker hps (AhpLoss) will be lost with the simple formula:

AhpLoss = FinalCombatRounds - Dhp

From the value of AhpLoss, and knowing the makeup of your available forces, it should be possible to work out the optimum number of attackers per defender.

The above, then, is my "new way" of looking at combat. It's not 100% complete, of course the RNG can come along and wreck things, it usually does, but over time as with all such statistical things, it will even out.

I guess I'll now leave this open to comment so the usual suspects can come along and drill holes right through this analysis!
 
It is not terrible as a simple first approximation, but the main flaw that I see is that you cannot use all of your attackers’ hps in one turn (unless they all have infinite blitz ability). The issue of “wasted” attacker hps actually makes this method less accurate as the number of units increases.

Play around with Offa’s town capture simulator. Plug in the number of attackers that your method indicates would be sufficient, and I would bet that you are bringing significantly fewer units than you actually need.
 
Yes I do use this method, which was described to me by Wardancer, perhaps while discussing our first SGOTM together. Knowing his facility for analysing systems like turn-based combat, he probably thought the approach was so obvious that it didn't deserve a dedicated article. I however think it is worth formal discussion, so well done for taking the time to explain it in precise terms. :goodjob:

To get over the problem of not accounting for promotions, you can change your model to assume that all defenders will need to lose 5hp instead of 3. Of course in the final event, many defenders won't ever make it to elite status, but that fact just gives you a nice margin of error, which can go to address the other problem of 'unused' attacker hp.
Mind you, I'm not sure that you really end up wasting that many attacker hp in most seiges. In your example, even killing a 1hp numidian requires a budget of 3hp of 3MC, so you only waste 1hp when using a vet 3MC.
 
You waste a minimum of 1 hp for every attacker that wins (or retreats) and generally more if the attacker strength is greater than the defender strength. Simple example - suppose a town is defended by 4 5/5 spears with no defensive bonuses (not even the 10% flatland bonus). How many 5/5 archers would you bring to capture that city? This method indicates that 4 would be sufficient as often as not.
 
Ah, I see what you mean. eldar is actually rather vague about how you should get from the variable AhpLoss to the number of attackers required (nA). For sure you can't just let Ahp = AhpLoss, i.e. nA = AhpLoss / Axp (the number of hp per attacker).
Personally, when using the system, I have always estimated nA = FinalCombatRounds / Axp. This actually gives quite an overestimate of nA, because it is equivalent to saying that each attacking hp only fights once. In fact every time an attacking hp wins a round of combat, it gets to fight again unless the defending unit has died. So I wonder how that overestimate compares to the underestimate caused by failing to account for 'overkill' combats, where the attacker has many more hp than the defender... more algebra needed. :crazyeye:
 
I compiled a spreadsheet of the WCs vs NMercs combats. I've not done any analysis of it, but I can upload it once I'm back on the PC it's on. FWIW, I seriously overestimated the Carthaginian strength, only one city caused me any serious trouble. 3 units per defender was about right and I think (don't have the figures right in front of me) that my eventual attrition rate was within expected bounds. The war only consisted of 50 battles though so not enough data.

[As an aside - in the same game, later on, the Spanish completed in very quick succession the ToA, Pyramids, Hanging Gardens, and Sun Tzu, in 4 different cities. ToA would've kicked off their GA as they'd built the Colossus too but really - talk about Wonder Addiciton!!]
 
Hello,
I haven't played civ for a few years now :eek:, but decided to have a little peek at the site, as I am not really completely cured.

This subject does pique my interest, as it is something that I once pondered for some time. As Chamnix says, my Town Capture Simulator is designed for this sort of problem. Frankly, I don't understand why people use basic combat calculators when such a fine product is freely available :blush:

The relevant link is in my signature. I did actually add a save file facility to it but I don't think I ever uploaded it; clearly I could if anyone wants it.
 
Maybe one could use both as some times you attack towns and some times you attack in the open. There is one catch though on the town issue, you tend to not know what is in the town.
 
There is an option to select "outside" in the size of town box in my programme, which should deal with attacking out in the open.

By the way eldar, I hope you have remembered to factor in complications such as defender promotions. My programme goes to some length to simulate this properly (which is why it asks whether the defender is from a militaristic civ). In practice if you are taking on tough defenders with weak attackers, you might as well assume the defenders are all elites: this is overly conservative but more accurate than hoping they only have 3 HPs.

When taking a big town the exact odds of success become very difficult to calculate, so multiple simulations seem better. Most of us use fast units when possible so retreats have to be factored in. Of course you can get a pretty good feel for this sort of thing intuitively, but for the occasion important battle it is nice to know fairly accurately how many attackers to bring along. The percentage chance you are prepared to accept is obviously up to you.

For the case in question the stats are:
attackers
No 3 power 2 HP 4 exp 4 river 0 fast 1

defenders
No 1 power 3 HP 3 exp 3 fast 0 fort 1 mil 0? mod def 4.05


8108 captures in 10000 attempts (81.1 % )
mean surviving attackers: 2.29 mean losses: 0.71
mean surviving defenders: 0.19
mean retreating attackers: 0.58
In successful attacks the mean final attacker was number 1.88
variance : 0.57

2843 captures with attacker 1
3357 captures with attacker 2
1908 captures with attacker 3

80% success is not a figure I would be very happy with. It goes up to 91% with four attackers, with the mean loss increasing to 0.76, a lot more acceptable.
 
Great the outside function covers that. Now my comparison of Zachriel's and yours. I ran a regular archer attacking an elite spear in a town. The town had a wall. No other factors.

100 trials shows 8% for archer and yours shows 14%.I ignored the fractions.
1000 trials closed the gap some as it was then 9% to 12%.

I would tend to think the lower number more reasonable, but you cannot be sure.

At 100,000 Zach was 9.6% and yours bounced around in 12.3 to 12.6 range. I have no idea which is more accurate.

One thing I have not seen in any battle calc is to be able to use an army. I guess it would be hard as you would need an option for C3/PTW vs C3C.

Any thoughts on the variance?
 
I don't understand your results: I tried a regular archer attacking a single elite spear in a walled town. The result was (one million simulations):

attackers
No.1 power2 HP3 exp3 river0 fast 0



defenders
No.1 power2 HP5 exp5 fast0 fort1 mil0 mod def 3.7



56147 captures in 1000000 attempts (5.6 % )
mean surviving attackers: 0.06 mean losses: 0.94
mean surviving defenders: 0.94
mean retreating attackers: 0.0
In successful attacks the mean final attacker was number 1.0
variance : 0.0

56147 captures with attacker 1

I checked with Sirps combat advisor (a iterative programme that works with small attacks, but hangs (on my PC) in complex situations), and this gave 5.6%. The chance goes up to 8.2% if the defender isn't fortified. From what I remember about the game, defenders usually are fortfied.


The later versions of my simulator do allow armies. The permitted attacker hit points go up to 10 and there is a blitz option allowing a unit up to 4 attacks. This should cover most real possibilities. It is possible that tanks etc aren't entirely catered for (I suspect tank armies get to attackmore than 4 times a turn), but most games are over before modern warfare anyway.
 
I had the version at the top of your thread. I replaced it with the last one, but it is the same results.

Anyway I got more less the same answer AND I if I changed the count to a million, it just runs it with 1000. I would have to let the number accumulate from 10 runs to get a million, no sweat.

here is a pix:


Edit: I forgot to mention that I always get 2.7 factor on my runs and yours shows 3.7?
Edit 2: I see the difference, you are using a wall and I am not. That drops it down to the 5.6% range. The thing is not my run to yours, but the diff from Zach's tool to your tool. Yours may be the most correct one, that is what I am trying to determine. I hope it is at least close as yours has more to offer with the chance to try armies.
 
You did specify a wall in your example.

I am pretty sure my programme gives the right answer. As a further check Bomber Escorts calculator (simpler utility with single attacker and defender only) gave 5.6%, which agrees with me. Zachriel was, as I remember, an entertaining writer and a pretty good player. Much as I would like to find a flaw in a rival programme, I have tried his utility and also get 5.7%.

I note that Zachriel's utility states that it is highly recursive. Mine isn't recursive at all :sheep:, so should be able to cope much better with large attacks.

Re the million simulations, I rather sneakily programmed it to default back to 1000 attempts if you ask for more than 100,000 simulations. I was worried about the programme hanging if it was overloaded with big simulations, eg 40 attackers and 20 defenders. You can ask for 100,000 simulations and press start 10 times. In practice, you don't really need that many simulations. After all, in the game you only get one :crazyeye:
 
Yeah I stated it had a wall, but ran the test without one, whoops. I was thinking of a post I read and it did not have a wall. I also now see one had a flat terrain and the other did not.

I remember Zach and his web page. Anyway, I will switch to yours now as I still got some funny results for the no walls, but with a wall and 30,000 they were very close. Thanks for the response.

BTW I remember you as well.
 
I finally got around to running a few test with armies and I wondered how the HP/level functions?
Say I use 12 for power (cav 6 attack, doubled by structures to 12) and 17 hit points. Not too uncommon for a cav army of 4 units.

Then you put in reg/vet/elite. I presume that was to allow for possible promotions. Now armies, could in theory get promotions. I have seen two vet to elite promotions in one battle. I doubt you could get more than that as the army would be killed about that time.

This occurs when on defense and gets a common promotion for the lead unit, if it was not elite. If it was elite, then it would have to be defeated and the next unit defend. By the time you get two promotions, you are down to red and the last unit. I am not saying it could not be done, but I have not seen three.

So I used vet for this choice. I ran a few Vs 3 units, 2 muskets and 1 pike. In the cases where there was 1 of 1000 failures to capture, I did not know if any promotions occurred or if there was a retreat.

The other thing was the bar ran well past the top of the graph and covered some of the report, so I was not sure what the last word was in report.

So my questions are 1) will it reflect any retreats (for armies) 2) will it gauge any promotions. The army would then have more hit points and increase its chance to win the battle. An AC army can have 22 HP and I have had them.

Does it have a means of knowing the make up and the max HP allowed? I suspect that would be a bit much to deal with, but maybe a field to denote the cap. A 17HP to start and 20 max for example.
 
So my questions are 1) will it reflect any retreats (for armies) 2) will it gauge any promotions. The army would then have more hit points and increase its chance to win the battle. An AC army can have 22 HP and I have had them.

Does it have a means of knowing the make up and the max HP allowed? I suspect that would be a bit much to deal with, but maybe a field to denote the cap. A 17HP to start and 20 max for example.

I wrote the simulator mainly to work out what to me were the likely battles in games: such as taking a city defended by 12 pikes with a load of knights/cav. For such attackers promotions make no difference in the current turn, although they are rather nice for later turns. Blitz attackers were added later, and I didn't add a facility to let them benefit from occasional promotions within the current turn. It would take a pretty big rewrite to accommodate this, which I doubt would be worthwhile. Even if I did this it would be hard to factor in what a human player would do with a seriously depleted army: eg would you attack again with an army down to 1-2 HP?

The programme treats an army as a single unit, but allows it multiple attacks in the turn. It doesn't really matter whether you designate it reg/veteran/elite. I put in a max of <20 HPs as I thought this was high enough. It would be trivial to allow more HP: All I have to do is change the number. I never considered ancient cav armies.

Retreats are calculated correctly, I believe. Defender promotions are also calculated carefully, as they make a great deal of difference within the turn.

The bar going off the top of the chart is a pity, but you can always resize the window to see the text. In addition it only happens with probabilities of >>50%. This doesn't happen much with the sort of battle that really benefits from a simulator.
 
Thanks for the info. It is not that common to have more than a 20HP army, so no big deal. The promotions is not a problem. I just wanted to know so I could factor that in. Even the bar going up is not a problem, once I know what the text would have been. Eventually I could remember it.
 
Back
Top Bottom