Unofficial BTS 3.13 patch

I'm wondering if my original point on amphibious attacks has been slightly overlooked guys ;)

[snip]

As I said in an earlier post, if I DID have enough troops sitting around to completely disrupt the ais stack when it lands(troops that could reach the point of incursion in 1 or 2 turns), then there isn't a cat's chance in hell of it holding the city anyway. So why waste all those troops in the first place?

You think that the AI loses so many units because it attacks amphibiously. I say they lose so many units because they don't use their units correctly. I regularly attack well defended AI cities with a direct amphibious invasion and rarely do I lose more units than the defending party. Now, ok, I admit, I'm a little smarter than the AI (hey, no insults please, I know I'm asking for it), but it really isn't that hard (theoretically) to make the AI attack smarter when it attacks amphibiously.

Normally, when the AI attacks a city by land, then it will first bombard, then attack with siege units and then with normal units picking the best normal units for the job. However, when it attacks amphibiously, it doesn't see the stack of units inside the ships as one single stack. It attacks with the first transport cargo (or galleon cargo) and then with the next and the next. It might be that the 6-th ship contains all the siege units, but that doesn't mean it will use that cargo first. It might also use a ship loaded with knights against the riflemen before it uses the ship loaded with grenadiers.

If the AI would use the frigates that are guarding the galleons to first remove the cultural defence bonus and then use 6 city raider 2 cannons against your 4 riflemen defenders (it's not to hard to get city raider 2, but I won't assume city raider 3), then it will easily defeat the extremely wounded riflemen with any other units that are in the ships (preferably grenadiers of course). Of course, the AI may not promote its units so well, but I'm not assuming a stack of 12 galleons filled with units either. Just using the collateral damage first and seeing all the transported units as a single stack to select units from would make a huge difference. The amphibious penalty is quite easy to overcome.

(I just world buildered an example and in that example the defender lost 4 riflemen (unfortified, city garrison 2) and the attacker lost 3 cannons (city raider 2). 3 other cannons attacked and retreated and the extremely wounded riflemen were then slaughtered.)

It's actually implossible to do an exact calculation of victory between 2 large stacks. Combat results between 2 units has no outside factors. Combat between multiple units does. For example, if my Axeman stack attacks a city with 2 units in it, one possibility is that I beat the odds, and kill the first unit. Another is that I lose, but damage the unit heavily. Another that I damage it weakly, or don't damage it at all. Predicting any further combat would require knowing the results ahead of time, which is impossible.

Ok, you may know a lot more about programming, but I guess that I know more about mathematics (or at least about stochastics) if you're saying this. ;)

Yes, you can calculate those odds exactly. I'm not saying that it's very easy or something like that. It has to do with conditional chances if you've had something like that at school. You can split the theoretical outcome in several paths and calculate the odds of each of these paths and then add the odds of the ones that give the result that you want (say: group A wins). The more units in both groups, the more theoretical outcomes, the more chances of these paths you will have to calculate and add. If the groups become fairly large, then even a modern computer will not be able to calculate the chances as the number of paths rises exponentially with the number of units in both groups.

As a comparison, it is similar to calculating the chances that if you roll 3 dices and add the eyes on the dices, that the outcome is more than say 14. There are several ways to get a result higher than 14 and you just have to add the chances on each of these results. The fact that throwing a one with the first die will make it impossible to get an outcome more than 14 doesn't make it impossible to calculate the odds of getting a combined result higher than 14 in general.

(If I sound condescending: I don't mean to.)

That's another way to do it, but I'm not sure that 10 times would be a sufficiently large sample size to determine the probability.

That depends on how accurate you want to get. I don't think you need to get very accurate in this case. With most attacks it is very clear which side will win so that you will mostly see one side win 10 out of 10 battles or lose 10 out of 10 battles. The problem that we're facing now is that the AI will still often attack (over land or sea) in cases where it would likely lose 10 out of 10 battles if this test were performed. The reason is that the testing algorithm used now to see whether it is smart to attack is pretty poor.

Example: Say we let the AI do an attack with a stack on another stack if it wins 6 out of 10 battles in the test case. What is the chance of this happening while the AI actually only had a 20% of victory in this battle?

Answer 0.657% (less than 1 %).

And I don't even think it is that bad if the AI were to attack while it only had a 20% chance of victory. Having only a 20% chance of victory in a battle between 2 stacks actually indicates a pretty close fight between these 2 stacks. Both stacks are very likely to incur serious losses. If a stack is likely to win without losses then the chances of victory in general are likely very close to 100%.



From the looks of it, it merely does a "plot strength" comparison. Plot strength seems to merely be the sum of the strength of all the units on a tile (modified based on promotions/terrain/etc). The combat odds are simply the ratio of strengths (attackter str x 100 / defender str).

Bh

That's a pretty bad comparison of the strength of stacks of units. I wonder how it calculates the specific bonuses against certain units as it is not inherently known whether these bonuses are applicable to the fight. That depends on a lot of factors.

Of course it also doesn't take into account collateral damage which is hugely important (as you already said).

Another example why this is a bad comparison: It values a strength 5 unit equal to 5 strength 1 units. However, a strength 5 unit has a 95.3% chance of emerging victorious in a battle with a stack of 5 strength 1 units. It has an 80.6% chance of emerging victorious form a battle with a stack of 7 strength 1 units.

Now, if I were to give the strength 5 units 3 first strikes, then it becomes even more ridiculous:
99.98% chance to emerge victorious from a battle with 5 strength 1 units
99.9% chance to emerge victorious from a battle with 7 strength 1 units.

There are many many cases which will actually regularly occur during a game where this estimate of the strength of a stack is really bad. (And I say that as someone who has a university degree in mathematics. I know what I'm talking about. Although I dislike using this as an argument as it really isn't.)
 
Yes, you can calculate those odds exactly.

Yes, you're right, I shouldn't have used the word "impossible".

Example: Say we let the AI do an attack with a stack on another stack if it wins 6 out of 10 battles in the test case. What is the chance of this happening while the AI actually only had a 20% of victory in this battle?

Answer 0.657% (less than 1 %).

Ok, but you've proven you've got a good understanding of math, so you know that's not the proper question. The proper question would be, if the AI only had a 20% chance of victory, what is the probability that it would come up with 6 or more wins in the test case. I'm not going to do the math, but it's definitely higher than 1%. And even that's not really a great question, because you're talking about results that are are off by 300+%.

And I don't even think it is that bad if the AI were to attack while it only had a 20% chance of victory. Having only a 20% chance of victory in a battle between 2 stacks actually indicates a pretty close fight between these 2 stacks. Both stacks are very likely to incur serious losses. If a stack is likely to win without losses then the chances of victory in general are likely very close to 100%.

But that's a completely different issue than the previous one. This is merely a case of deciding what odds the AI needs in order to justify attacking. Although I certainly wouldn't consider 20% justifiable. While I agree that the stacks are probably semi-close in strength, you'd still lose 4 out of 5 times. And you have to consider not just whether you can win, but also in what shape you're going to be if you win. Unless you are on a razing mission, you're going to want to keep the city. Is winning with a single unit left that's at 5 HP worth the cost? The chances of keeping the city are virtually nil.

Another example why this is a bad comparison: It values a strength 5 unit equal to 5 strength 1 units. However, a strength 5 unit has a 95.3% chance of emerging victorious in a battle with a stack of 5 strength 1 units. It has an 80.6% chance of emerging victorious form a battle with a stack of 7 strength 1 units.

I think your math may be off there. Unless I'm mistaken, you're taking the chance of winning a 5 vs 1 fight, and applying it to all 5 battles? You have to remember that if in the first fight you got wounded, that lowers the chance of victory in the subsequent battles. I think the actual chance of winning is lower than you think.

There are many many cases which will actually regularly occur during a game where this estimate of the strength of a stack is really bad. (And I say that as someone who has a university degree in mathematics. I know what I'm talking about. Although I dislike using this as an argument as it really isn't.)

You don't have to convince me of that. :)

It's just a matter of coming up with the best, feasible alternative.

Bh
 
Ok, but you've proven you've got a good understanding of math, so you know that's not the proper question. The proper question would be, if the AI only had a 20% chance of victory, what is the probability that it would come up with 6 or more wins in the test case. I'm not going to do the math, but it's definitely higher than 1%. And even that's not really a great question, because you're talking about results that are are off by 300+%.

Hmm, it's getting a little late here, so I should go to bed, but I'll respond to this last post. I did mean 6 or more, I just didn't write 6 or more.

And that chance is actually 0.657%.

I agree that it's not accurate (20% is way different than 6 out of 10), but we don't need accuracy. We just need something that can prevent the AI from doing suicidal attacks, preferably without simulating a 1000 battles between the stacks (although maybe even that wouldn't take long for a computer). A 20% chance battle between stacks of size 10+ is not suicidal as it will inflict damage, but of course it isn't a wise one as you mention later in your post when talking about keeping a city that was captured.

But that's a completely different issue than the previous one. This is merely a case of deciding what odds the AI needs in order to justify attacking. Although I certainly wouldn't consider 20% justifiable. While I agree that the stacks are probably semi-close in strength, you'd still lose 4 out of 5 times. And you have to consider not just whether you can win, but also in what shape you're going to be if you win. Unless you are on a razing mission, you're going to want to keep the city. Is winning with a single unit left that's at 5 HP worth the cost? The chances of keeping the city are virtually nil.

If you want to win and be in good shape, you probably want to win 9 or 10 out of 10 battles. If you have a battle between 2 stacks of 20 units, and you lose 1 out of 10 and win 9 out of 10, then the stacks are probably pretty equal in strength and the likely winner is also pretty much banged up. Otherwise the winner wouldn't lose 1 out of 10.

We would probably not want to make it too complicated. We can make all kinds of restrictions on when to attack, but we have to focus on the goal. We just want to prevent the AI from making ridiculous attacks that it is surely going to lose. If we want more than that, then the battle estimates are going to have to be refined.

I think your math may be off there. Unless I'm mistaken, you're taking the chance of winning a 5 vs 1 fight, and applying it to all 5 battles? You have to remember that if in the first fight you got wounded, that lowers the chance of victory in the subsequent battles. I think the actual chance of winning is lower than you think.

Ok, I have to be accurate so that we don't misunderstand one another. I'm talking about a strength 5 unit (without modifiers) defending against an attack of 5 strength 1 units during one turn (also without modifiers) and no retreating or healing or upgrading.

I do know that the strength 5 unit is likely to become weaker with every fight and thus likely to get more and more damage in each fight. The reason that it is very likely to win nonetheless is because of the various advantages stronger units get in battle. They don't only have a higher chance to score a hit during each round of combat, but they also do more damage and receive less damage.
In this case, the stronger unit is 5 times more likely to score a hit and when it scores a hit it damages the weaker unit for 4 times as much damage. It wins the first battle when only scoring 3 hits while to lose would require 10 hits.

The expected number of hitpoints left after encountering the first strength 1 unit is 94 out of 100. It's not 80 as some might expect based on a 5 to 1 strength relation.

In civ3, a strength 5 unit would be fairly equal to 5 strength 1 units, in civ 4 strength is non-linear.

You don't have to convince me of that. :)

I shouldn't have mentioned it.

Oh, by the way, here is a combat calculator that I used for some of the percentages that I've mentioned. It's a pretty nice one. I wouldn't have liked to calculate all those percentages by hand (the 0.657% is done by hand as it has nothing to do with that combat calculator).
 
Actually instead of a % chance of success, what might be better is Average losses (ie number of units killed) Since battle success also includes killing enemy units, and success relies on your units not dying

So run the 10 simulations
for each simulation count the number of each sides units that died...
and then give the Average of those 10 simulations.
And the number of times the AI succeded out of 10

So An AI could assess the situation as
Gain=Average number of enemy deaths+chance of winning battle
Cost=Number of unit deaths

If the AI wanted to conquer cities it would be more careful about the cost (at least when considering the total number left alive for a garrison v. likely counter conquest forces.)
 
In all of these examples, you're talking about an AI that is seriously weaker than you. It really doesn't matter what this AI does. It is not going to win if you are that much more advanced than it is.

I think you're missing part of my point. My point is that the AI launched the units when they were viable (my towns defended by longbowmen) and by the time they got to my border they were non-viable.

And I play on normal speed with small or smaller maps to avoid this as much as possible!
 
I did mean 6 or more, I just didn't write 6 or more.

And that chance is actually 0.657%.

Really? That seems rather low to me, but since I'm too lazy to do the math myself, I'll take your word for it. :lol:

A 20% chance battle between stacks of size 10+ is not suicidal as it will inflict damage, but of course it isn't a wise one as you mention later in your post when talking about keeping a city that was captured.

I personally don't disqualify an attack from being suicidal simply because it inflicts damage.

If you want to win and be in good shape, you probably want to win 9 or 10 out of 10 battles. If you have a battle between 2 stacks of 20 units, and you lose 1 out of 10 and win 9 out of 10, then the stacks are probably pretty equal in strength and the likely winner is also pretty much banged up. Otherwise the winner wouldn't lose 1 out of 10.

I still think you are underestimating deviation with a sample size that small. If you have one unit attacking another unit, and it has a 10% chance to win, statistically it should win 1 out of 10 battles. Is it really that likely to be "banged up"?

Remember, whatever code we have for stacks of 20+ units will also be used for single units. It needs to be effective for both.

We would probably not want to make it too complicated. We can make all kinds of restrictions on when to attack, but we have to focus on the goal. We just want to prevent the AI from making ridiculous attacks that it is surely going to lose. If we want more than that, then the battle estimates are going to have to be refined.

I don't think that's all we want. The idea isn't simply to stop suicide attacks, it's to make the AI more intelligent about attack decisions. At least, that's been my focus on this.

The other issue here is the one Duuk mentioned - often the AI will make what's a correct decision (based on current odds) to attack a city. But it doesn't appear to re-evaluate that decision when it arrives. A re-evaluation at that point would probable decrease the incidents of "suicide attacks" more than any other factor would.

Bh
 
Actually instead of a % chance of success, what might be better is Average losses (ie number of units killed) Since battle success also includes killing enemy units, and success relies on your units not dying

So run the 10 simulations
for each simulation count the number of each sides units that died...
and then give the Average of those 10 simulations.
And the number of times the AI succeded out of 10

So An AI could assess the situation as
Gain=Average number of enemy deaths+chance of winning battle
Cost=Number of unit deaths

If the AI wanted to conquer cities it would be more careful about the cost (at least when considering the total number left alive for a garrison v. likely counter conquest forces.)

When using the information from a simulation battle run, you can use a lot more information than what I first suggested (number of wins). This can be used to refine the decision making even further.

But I'm against making the AI too cautious, so we should define the parameters of victory pretty well and only avoid the really stupid attacks.

For instance, Montezuma sometimes creates stupid amounts of units which results in a lesser ability to research. On the other hand, a newer player who have never encountered him or someone who underestimates his unit buildup will sometimes have a very weak defence. In such a match up you could see Montezuma attacking 5 cities defended with 1 infantry each with 60 cavalry. Those 60 cavalry are going to capture those 5 cities but will suffer dearly for it. Still I think the AI should capture those cities. It should not say: ok, lets research a bit better technology so that my 60 cavalry can become something better and only then conquer those cities. By the time Montezuma has better units, its enemy will also have better units and maybe also more better units. It has a military superiority (in pure raw strength) now and it should use it now.

The most important thing is to improve the suicide attacks where the AI attacks while the human player knows this will result in a massacre without any result. The kind of attacks where 5 cavalry attack a city with a decent defence bonus and 3 fortified infantry. You'd probably get a 0 out of 10 chance of victory in a simulation for such attacks.

If one wants to expand the risk analysis for the AI, then the acceptable risk should be dependant on the goal.

-If the goal is capturing a city, then you could demand: at least 9 out of 10 victories and at least 1/5 th of the attacking forces survive.
Otherwise
50% chance retreat
50% chance pillage

Yes I know that 1/5 th is pretty poor, but we also don't want an AI that shies away from attacking a city just to sit there and do nothing. If it can kill all the defenders of a city and keep it with a small force, then that's a decent performance. Even if the defender captures it back, there will be severe damage to buildings and population and the original defenders are lost

-If the goal is destroying a city, then you could demand: at least 9 out of 10 victories (number of attacking forces left doesn't matter).
Otherwise
50% chance retreat
50% chance pillage

-If the goal is weakening or destroying an advancing enemy stack: damage to enemy > 1/2 damage to my units (counted in hammer-cost of units).
otherwise
defend cities that could be attacked

-If the goal is weakening an enemy stack about to capture one of my cities: use all the collateral damage units available. Use other units if damage to enemy > damage to my units (counted in hammer-cost of units).
otherwise
defend cities that could be attacked

I do realise that such goals will sometimes result in AI attacks which aren't very wise. But we also don't want an AI that never dares to attack because of the losses it might suffer.

I think you're missing part of my point. My point is that the AI launched the units when they were viable (my towns defended by longbowmen) and by the time they got to my border they were non-viable.

And I play on normal speed with small or smaller maps to avoid this as much as possible!

Yes, that happens sometimes. It happens more on the quicker game speeds. I personally think that the bigger the map you play on, the slower the game speed that you should use for an enjoyable game experience.

Players on this forum also sometimes complain about their units becoming obsolete during a war. Moving to a war and waging a war takes a while and the reinforcement lines are a lot shorter for the defending party.

Still, if someone is attacking your riflemen with knights, even if the attack is coming from a distant foe, then I guess he hasn't researched cavalry while his knights are attacking you as it takes quite some time to move from knights to cuirassiers to cavalry in the tech tree. He must have been less advanced compared to you from the start.

You shouldn't make the AI too hesitant about attacks, so if its knight force arrives at your border cities defended by large amounts of riflemen, then the AI planning to declare war should not necessarily retreat. If you know that it will retreat, then you can use that in a game by upgrading at the last instant or by moving defenders around. You will see puppet-master strategies emerging again in civilization 4 like they were available in civilization 3. Instead I think, the AI facing impossible-to-capture cities should either (50% chance) retreat or (50% chance) pillage as much as possible. The randomness will ensure that you can't control the AI actions like a puppet-master. All the time it should watch for opportunities to capture cities which might use defenders to attack the pillagers and thus weaken their defences.
 
Really? That seems rather low to me, but since I'm too lazy to do the math myself, I'll take your word for it. :lol:

No, I don't like that. My word isn't that meaningful as you don't know me that well. So here it is:

It's 0.2^6*0.8^4 * 10!/(6!*4!) + 0.2^7*0.8^3 * 10!/(7!*3!) + 0.2^8*0.8^2 * 10!/(8!*2!) + 0.2^9*0.8 * 10!/9! + 0.2^10.

The first term (that's the chance to win exactly 6 out of 10 fights with odds 20%) is the most important term (0.55%).

I personally don't disqualify an attack from being suicidal simply because it inflicts damage.

With damage, I meant kills, not just hitpoints, but ok, still somewhat suicidal if you're likely to lose the complete battle.

I still think you are underestimating deviation with a sample size that small. If you have one unit attacking another unit, and it has a 10% chance to win, statistically it should win 1 out of 10 battles. Is it really that likely to be "banged up"?

Remember, whatever code we have for stacks of 20+ units will also be used for single units. It needs to be effective for both.

A sample size of 10 is not good enough for battles between single units. Ah, what the heck, just pick a sample size of 100. It's not going to take any serious calculation time anyway. Maybe revert to the normal percentage chance of victory for single unit battles (as calculated in the game at present) as it's probably quicker in that case.

I don't think that's all we want. The idea isn't simply to stop suicide attacks, it's to make the AI more intelligent about attack decisions. At least, that's been my focus on this.

Ok, if you don't just want to stop suicide attacks, but want an intelligent attacking AI, then you're asking for a lot. The AI also has problems with assembling an army with the right units and the right promotions so there is room for a lot of improvement in that area too.

The goal of the AI also determines whether an attack is 'intelligent'.

Normally, suiciding 3 catapults onto a stack of 10 units while not subsequently attacking it isn't that smart, but when that stack is about to attack one of your cities and those collateral damage attacks have made the stack too weak to do so, then it is quite intelligent.

So if you want to make the AI intelligent in its attacks, then you will have to set acceptable results for each of the different goals it might have. I assume that the AI has some 'goals'...

The other issue here is the one Duuk mentioned - often the AI will make what's a correct decision (based on current odds) to attack a city. But it doesn't appear to re-evaluate that decision when it arrives. A re-evaluation at that point would probable decrease the incidents of "suicide attacks" more than any other factor would.

Yes, a re-evaluation would be good. Maybe retreat or pillage in that case.
 
I really can't believe it doesn't re-evaluate now, this to me is a glaring omission. On a huge map, it can sometimes take a dozen or more turns to reach a target. Its like "don't worry general, we scouted the city in 1350, and they only had a longbow and a crossbow", but arriving in 1376 and finding that there are now several longbows, crossbows and knights, but attacking it as if it was still 1350 :lol:

I'm not sure if this kind of "false logic" applies to war declerations too (e.g. we are going to war with "x" nation" and then arriving 30 turns later and finding the defender much too tough but attacking anyway), but if so, surely some check needs performing there too....
 
With damage, I meant kills, not just hitpoints, but ok, still somewhat suicidal if you're likely to lose the complete battle.

No, I understood that you meant kills, but even still, attacking a city with 5 defenders and killing 2 of them doesn't really strike me as a very useful exercise.

A sample size of 10 is not good enough for battles between single units. Ah, what the heck, just pick a sample size of 100. It's not going to take any serious calculation time anyway. Maybe revert to the normal percentage chance of victory for single unit battles (as calculated in the game at present) as it's probably quicker in that case.

Before we fall too much in love with this idea, we need to find out if it's feasible. The main problem with it is that it's all virtual. The game isn't set up to handle virtual combat (well, the game is all virtual combat, but you know what I mean). When a unit gets hit, for example, it takes damage. But since the combat is virtual, we can't actually have it take damage. Ditto for the unit being killed.

We could duplicate the units abstractly, but then they aren't actually on a game plot, meaning their strengths would be incorrect. We could duplicate the units directly, but that would involve placing them on the plot, which would completely mess up the units on the plot.

So instead, what'll be necessary is copying all of the combat code, and setting it up to handle all of the damage/death virtually. That's a more ambitious task than you might think.

Ok, if you don't just want to stop suicide attacks, but want an intelligent attacking AI, then you're asking for a lot. The AI also has problems with assembling an army with the right units and the right promotions so there is room for a lot of improvement in that area too.

No, I'm not going for intelligent, just more intelligent. I guess it's really just a factor of the "suicide" issue. I don't want the AI making attacks where it's likely to lose. Or, better to say that I think there should be a low chance of that occuring. So that involves both picking a target intelligently (for example, when it's picking a city to attack, it generally gets restricted to a particular range, which may or may not be the best choice), and evaluation of combat odds once it arrives at the target.

Also, in the case of amphibious, determining whether landing the troops is a better choice than attacking amphibiously (although, really, unless all the units on the ship have the amphibious assault promotion, the odds attacking from land will always be better).

Normally, suiciding 3 catapults onto a stack of 10 units while not subsequently attacking it isn't that smart, but when that stack is about to attack one of your cities and those collateral damage attacks have made the stack too weak to do so, then it is quite intelligent.

The nice thing is that the city attack code is completely separate from the normal attack code. So we don't have to worry about messing up other attack cases by changing the city attack code.

Yes, a re-evaluation would be good. Maybe retreat or pillage in that case.

Retreat/Pillage/Re-target/Attack anyway, probably.

Bh
 
I'm not sure if this kind of "false logic" applies to war declerations too (e.g. we are going to war with "x" nation" and then arriving 30 turns later and finding the defender much too tough but attacking anyway), but if so, surely some check needs performing there too....

I thought that the war declaration was based on the total power of an opposing civilization. Although the specific target city might be the result of ancient scouting knowledge.

The AI will be busy with assembling troops and such before it actually declares the war, so the enemy might improve in power during that time.

However, I don't think that is too different from how a human player thinks. A human player will typically also decide to declare war and then start assembling an army to do the job. However, a human is probably better at assembling a capable army, picking a nice target and executing the war competently (and of course re-evaluating the decisions)

Before we fall too much in love with this idea, we need to find out if it's feasible. The main problem with it is that it's all virtual. The game isn't set up to handle virtual combat (well, the game is all virtual combat, but you know what I mean). When a unit gets hit, for example, it takes damage. But since the combat is virtual, we can't actually have it take damage. Ditto for the unit being killed.

We could duplicate the units abstractly, but then they aren't actually on a game plot, meaning their strengths would be incorrect. We could duplicate the units directly, but that would involve placing them on the plot, which would completely mess up the units on the plot.

So instead, what'll be necessary is copying all of the combat code, and setting it up to handle all of the damage/death virtually. That's a more ambitious task than you might think.

I must say that I actually expected it to be too hard. It would have been nice if the game had been set up with this from the start. The problem is that combat in civ4 uses pretty complicated formulas and with unit match ups and first strikes and collateral damage having a huge influence on the outcome of a battle, it can be very hard to estimate the result of a battle between stacks just by adding some unit strengths. One could probably create a better formula for estimating the strength of a city attack stack, but it would never be as good as a simulation. It is for instance very hard to estimate the effect of a bonus against melee units. Whether or not this bonus has an effect depends on whether or not this unit will engage a melee unit which is again hard to predict. The effect of first strikes is also hard to calculate. First strikes are very effective if there is a big power difference and only marginally effective if the power difference is small.

It's certainly possible to improve the rather simple purely strength based formula which you described earlier, but it will never become an excellent estimate of the strength of a stack.

When calculating the strength of a stack, do you have access to the stats of the various opposing units? It would be very useful to estimate the strength of the earlier mentioned bonus vs melee if you would know how many melee units there are in the opposing stack or actually what fraction of the opposing units is a melee unit.

Also, in the case of amphibious, determining whether landing the troops is a better choice than attacking amphibiously (although, really, unless all the units on the ship have the amphibious assault promotion, the odds attacking from land will always be better).

I must say that I still disagree with the general dislike of the amphibious attack. I regularly use it and it generally means that I need 1 or 2 extra collateral damage attacks before the enemy is weakened enough to attack. I would probably lose more if I lost 1 turn by landing first and only then attacking.

Have you found the code that is used for an amphibious attack? When I see the AI using that, it seems that it is unaware of the units in the other transport ships. It seems as if the AI attacks with one ship cargo before if uses and is aware of the other ship cargo's. I've seen the AI use attack units and almost destroying my defence with them and then use a few siege units as finishing attackers which of course could not kill my units.

The nice thing is that the city attack code is completely separate from the normal attack code. So we don't have to worry about messing up other attack cases by changing the city attack code.

Ok, it's good to know that the AI uses different attack routines for different goals.
 
this discussion is brilliant (including binomial distributions, wow), don't get me wrong, but I think the solution to the amphibious dilemma is far easier (and could even be more realistic).

Simple question: do any of you know of any case in world's history where an attacking army assaulted a city or fortress from it's navy entirely? I mean, did you ever read about catapults firing from the ships?

The problem here, from my point of view, is that the amphibious assault in Civ4 has been extremely simplified, and has gone too far from reality.

The solution is simple: only certain units can attack from boats, as is and was in real life (Viking berzerkers, Marines, etc). All the others have to disembark first and then attack.

That shouldn't be hard to code, right?

My 2 cents. Congrats on the level of discussion. :goodjob:
 
The solution is simple: only certain units can attack from boats, as is and was in real life (Viking berzerkers, Marines, etc). All the others have to disembark first and then attack.

The guys storming the beach at Normandy would like a word with you. ;)

Bh
 
It's 0.2^6*0.8^4 * 10!/(6!*4!) + 0.2^7*0.8^3 * 10!/(7!*3!) + 0.2^8*0.8^2 * 10!/(8!*2!) + 0.2^9*0.8 * 10!/9! + 0.2^10.

Roland is correct. He's using the right formula, and I double-checked it in SAS software with sdf('binomial', 5, 0.2, 10) = 0.00637.

IMHO, simulation is by far the most reliable method here. Once you could establish benchmarks via simulation, then maybe you could start modeling it and using the simulation benchmarks to test the models, but I'd be surprised if we were able to come up with a good model, as Civ-obsessed as we are. Nevertheless, PM me if you're interested, and I'd be happy to put my Prob/Stat PhD to good use for a change ;).

It just so happens that my day job is writing software for sample size determination. So for those of you interested in coding up some battle simulations, here's an idea of how many you'll need:

If you want to be able to estimate victory probabilities with a margin of error of at most +/- 10% in a 95% confidence interval (i.e, be able to say "I'm 95% sure that our victory odds here are 60%-80%"), then you need to run at most 100 battle simulations. If the underlying victory probability is close to 0 or 1, you'll need less simulations. You could program an algorithm to stop simulating if the victory estimate is shaping up to be close to 0 or 1.

If you want the margin of error to be at most +/- 5% (i.e, be able to say "I'm 95% sure that our victory odds here are 65%-75%"), then you'd need between 200 and 400 battle simulations. Below are tables for the truly curious, showing the chances of achieving the target margin of error with various underlying victory probabilities and simulation sample sizes.

Of course, "victory" here can be defined any way you like---such as surviving with a certain number of units intact with a certain amount of health, or winning within a certain number of turns. That's part of the beauty of the simulation approach: you don't need to go do more math each time you want to try a different victory condition.

Spoiler Simulation Requirements :

Code:
Probability of achieving margin of error of at most +/- 10%:

Victory  --Number of Simulations---
   Prob     25     50     75    100
-------  -----  -----  -----  -----
   0.05  0.642  0.997  1.000  1.000
   0.10  0.271  0.878  1.000  1.000
   0.15  0.093  0.519  0.999  1.000
   0.20  0.027  0.190  0.965  1.000
   0.25  0.007  0.045  0.771  1.000
   0.30  0.002  0.007  0.407  1.000
   0.35  <.001  <.001  0.124  1.000
   0.40  <.001  <.001  0.021  1.000
   0.45  <.001  <.001  0.002  1.000
   0.50  <.001  <.001  <.001  1.000
   0.55  <.001  <.001  0.002  1.000
   0.60  <.001  <.001  0.021  1.000
   0.65  <.001  <.001  0.124  1.000
   0.70  0.002  0.007  0.407  1.000
   0.75  0.007  0.045  0.771  1.000
   0.80  0.027  0.190  0.965  1.000
   0.85  0.093  0.519  0.999  1.000
   0.90  0.271  0.878  1.000  1.000
   0.95  0.642  0.997  1.000  1.000

Probability of achieving margin of error of at most +/- 5%:

Victory  ---------------------Number of Simulations-------------------
   Prob    200    225    250    275    300    325    350    375    400
-------  -----  -----  -----  -----  -----  -----  -----  -----  -----
   0.05  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000
   0.10  0.990  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000
   0.15  0.549  0.894  0.992  1.000  1.000  1.000  1.000  1.000  1.000
   0.20  0.043  0.229  0.599  0.941  0.998  1.000  1.000  1.000  1.000
   0.25  <.001  0.006  0.052  0.329  0.770  0.992  1.000  1.000  1.000
   0.30  <.001  <.001  <.001  0.011  0.115  0.644  0.991  1.000  1.000
   0.35  <.001  <.001  <.001  <.001  0.001  0.061  0.633  1.000  1.000
   0.40  <.001  <.001  <.001  <.001  <.001  <.001  0.056  0.948  1.000
   0.45  <.001  <.001  <.001  <.001  <.001  <.001  <.001  0.369  1.000
   0.50  <.001  <.001  <.001  <.001  <.001  <.001  <.001  0.023  1.000
   0.55  <.001  <.001  <.001  <.001  <.001  <.001  <.001  0.369  1.000
   0.60  <.001  <.001  <.001  <.001  <.001  <.001  0.056  0.948  1.000
   0.65  <.001  <.001  <.001  <.001  0.001  0.061  0.633  1.000  1.000
   0.70  <.001  <.001  <.001  0.011  0.115  0.644  0.991  1.000  1.000
   0.75  <.001  0.006  0.052  0.329  0.770  0.992  1.000  1.000  1.000
   0.80  0.043  0.229  0.599  0.941  0.998  1.000  1.000  1.000  1.000
   0.85  0.549  0.894  0.992  1.000  1.000  1.000  1.000  1.000  1.000
   0.90  0.990  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000
   0.95  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000

And I suppose it's unlikely that anyone out there has SAS (although most universities have site licenses), but for the truly insane, here's the SAS 9.2 program I wrote to compute those tables. (We haven't released v9.2 yet, but hopefully within a few months we will).

Spoiler SAS Program Computing the Tables :
Code:
proc power;
   ods output output=probs;
   onesamplefreq ci=wilson
   halfwidth=0.1
   ntotal=25 to 100 by 25
   proportion=0.05 to 0.95 by 0.05
probwidth=.;
run;
%powtable(data=probs, rows=proportion, cols=ntotal, entries=probwidth);

proc power;
   ods output output=probs;
   onesamplefreq ci=wilson
   halfwidth=0.05
   ntotal=200 to 400 by 25
   proportion=0.05 to 0.95 by 0.05
   probwidth=.;
run;
%powtable(data=probs, rows=proportion, cols=ntotal, entries=probwidth);
 
The guys storming the beach at Normandy would like a word with you. ;)

Bh

exactly. And they will tell me: you're right. They had to disembark first, and then attack. The only artillery support they received came from the BB's and the air (both already modeled in Civ4 as bombardment). Did you know of any transport carrying artillery that fired from within the transports? ;)

In fact, the key objective of the campaign was the port of Cherbourg. Did you see them storm the port itself? I didn't think so. In terms of Civ4, they disembarked first "on a contiguous tile" from where to attack inland and the port-city.

I mean it. This has to be the easiest and most logical solution, but it has to be implemented by Firaxis; if not, this turns out a mod.

I stand my ground. Any other opinion?
 
Roland is correct. He's using the right formula, and I double-checked it in SAS software with sdf('binomial', 5, 0.2, 10) = 0.00637.

Oh, I know he's right. I only assumed he was wrong to begin with because he listed 0.637% as being for just 6 out of 10 - if that were the case, then 6+ out of 10 would have been higher.

If you want to be able to estimate victory probabilities with a margin of error of at most +/- 10% in a 95% confidence interval (i.e, be able to say "I'm 95% sure that our victory odds here are 60%-80%"), then you need to run at most 100 battle simulations. If the underlying victory probability is close to 0 or 1, you'll need less simulations. You could program an algorithm to stop simulating if the victory estimate is shaping up to be close to 0 or 1.

I'm not sure that 100 simulations is realistically doable. I mean, it's fine for a a single battle. But the problem is that when a particular unit is trying to determine a city to attack, it scans all the cities in a certain radius, and then calculations victory chances (choosing the one with the highest victory chance). With a large radius, that will result in a lot of calculations. And that's for a single army.

I guess there's no real way to decide if it's feasible or not beyond doing it. I just wish I had access to the profiler Firaxis was using.

Bh
 
exactly. And they will tell me: you're right. They had to disembark first, and then attack. The only artillery support they received came from the BB's and the air (both already modeled in Civ4 as bombardment). Did you know of any transport carrying artillery that fired from within the transports?

That's a bit of a moving goalpost. Your original position was that only specific units (Berserkers and Marines were the two you mentioned) should be able to do amphibious assaults.

In fact, the key objective of the campaign was the port of Cherbourg. Did you see them storm the port itself? I didn't think so. In terms of Civ4, they disembarked first "on a contiguous tile" from where to attack inland and the port-city.

That argument doesn't work. Regardless of whether they did what Civ would consider a direct city attack or not, it was an amphibious assault.

Even leaving that aside, I in no way buy real-world examples as motivation to change Civ IV. Civ is a game. Gameplay will always trump realism.

I mean it. This has to be the easiest and most logical solution, but it has to be implemented by Firaxis; if not, this turns out a mod.

You know what the easiest and most logical solution to the AI making bad decisions is? Removing the AI from the game. But I don't think anyone's going to be forwarding that as a good idea.

I know that I, for one, would not support removing amphibious assaults except for specific units. There are too many times when I can make good use of it.

Bh
 
The solution is simple: only certain units can attack from boats, as is and was in real life (Viking berzerkers, Marines, etc). All the others have to disembark first and then attack.

That shouldn't be hard to code, right?

My 2 cents. Congrats on the level of discussion. :goodjob:

That was how it was done in Civ 1-3 and it was a BAD idea. One tile island cities were unattackable until the modern era, and Naval power was a joke.

Changing the game Engine for this would be a bad idea by Bhuric OR Firaxis.

I do agree about the general problem with amphibious assaults tends to be not looking at the whole stack. (sometimes when doing an amphibious attack, I'll get bored and just order the stack to attack)... the order gets very wierd, unlike when they are a land stack.




As for improving the odds of the Strength modifiers
How about this calculation

Strength (with Generic and Terrain relevant modifiers) Squared for each unit, and modified for First Strikes

Sum up each TYPE of unit

Then whaen you know the basic Composition of each Stack

Collateral Damage ability modifies the unit's strength based on number of units in the other stack (up to its cap)

Unit Specific bonuses are then used for a NEW calculation of individual unit strength based on the prevalence of that TYPE of unit in the Other Stack [the unit-specific bonus effect should be calculated differently for attackers and defenders]

and then run through the Individual units with their new modified Strength (squared) and sum it up for a 'Stack Power' v. that other Stack.
 
I'm not sure that 100 simulations is realistically doable. I mean, it's fine for a a single battle. But the problem is that when a particular unit is trying to determine a city to attack, it scans all the cities in a certain radius, and then calculations victory chances (choosing the one with the highest victory chance). With a large radius, that will result in a lot of calculations. And that's for a single army.

Good point. But maybe we could also settle for a larger margin of error. Dare I suggest a game option for "AI Combat Calculation Precision---Low, Medium, High"? :lol:

Here's a table of simulation requirements including larger margins of error:
Code:
 Margin    Number of
of Error  Simulations
--------  -----------
+/-  5%     200-400
+/- 10%      50-100
+/- 15%      20-40
+/- 20%      10-20
+/- 25%       5-10
I guess there's no real way to decide if it's feasible or not beyond doing it. I just wish I had access to the profiler Firaxis was using.

What's a profiler, and why don't we have access? I thought all the AI was in either Python or the CVGameCore.
 
Good point. But maybe we could also settle for a larger margin of error. Dare I suggest a game option for "AI Combat Calculation Precision---Low, Medium, High"?

I can't add game options, so you'll have to take that up with Firaxis.

What's a profiler, and why don't we have access? I thought all the AI was in either Python or the CVGameCore.

A profiler is designed to show you how much time a program is spending in any particular function. If I had access to it, I could very quickly find how much time was being spent in the combat simulator. But without it, it'll be hard to determine. I've got a fairly powerful computer, so what seems fine to me may turn out to be too slow for others.

Bh
 
Back
Top Bottom