• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Combat Explained....

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 :)
 
I think that just considering the hammers forgets the beakers spended to research the necessary technologies.
Best regards,
 
Thalassicus said:
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...
 
fed1943 said:
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).
 
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!
 
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.
 
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:
 
Thalassicus said:
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
 
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
 
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
 
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.
 
carn said:
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 :)
 
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
 
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.
 
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]!*!*[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]!*!*[0.59]^4*[0.41]^i)"}
sum{"i=0->3","(3+i)!/(3!*!*[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?
 
slothman said:
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.

slothman said:
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]!*!*[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.



slothman said:
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.)

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

slothman said:
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)


slothman said:
battle chance is:

sum{"i=0->[4-1]","(4-1+i)!/([4-1]!*!*[0.59]^4*[0.41]^i)"}
sum{"i=0->3","(3+i)!/(3!*!*[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.
 
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)?
 
Roland Johansen said:
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
 
carn said:
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.
 
Back
Top Bottom