Unofficial BTS 3.13 patch

Doesn't the AI just assemble an army as big as possible, then check if it is big enough for its goal? So, the AI doesn't build an army which is big enough to accomplish a goal (capture a city), but instead builds a big army and then checks whether its big enough for a goal it then determines (such as capturing a city). Or am I mistaken?

Answering that question isn't easy. Back tracking to try and figure out how the AI is making decisions is complicated by the fact that it's a fairly complicated decision tree. A lot of what I'm reporting is factually incorrect because I'm trying to simplify it as much as possible.

For example, there are different AI settings that can be assigned to units. Some will directly get the UNITAI_CITY_ATTACK value, others will get UNITAI_ATTACK. The former is primarily aimed at attacking cities (obviously), although it can be assigned other tasks if necessary (it can attack adjacent units, etc). The latter is a more general attacker, but also can attack cities. It's attack choices are much different that the former, however.

However, to try and directly answer your question as much as possible, apparently the AI considers a group "ready to attack" if it has:
Code:
(AI_getBirthmark() % (1 + GET_PLAYER(getOwnerINLINE()).getCurrentEra())) + 4
units (or more), where AI_getBirthmark() is a random number from 0 - 9999. So basically a random number from 1 to 1 + era, + 4. The AI will still attack cities/units if it happens to be adjacent to them with less than that number, but it seems to be the minimum for a group to actually move towards an enemy city.

If the AI uses a stupid formula to re-evaluate the attack order, then it will still perform suicide attacks. Maybe less suicide attacks, but it will still happen. Especially since the defender has all kinds of bonuses which are undervalued in a system where strength values are just added to determine stack strength. If a defender has twice the unit strength of an attacker (after modifiers), then it will on average kill more than 2 of such attackers.

I can't tell for sure, but it sounds like you're still a little confused about the strength values. Remember, these are modified strength values. So a Longbow in a city on a hill with CG3, and the city having 60% culture, is going to have a "strength" of 18.6.

I don't know if it's easy to learn the AI to split its army in a few mixed unit-groups.

Neither do I, but I suspect it's not a trivial task.

Pillaging is not very cost-effective, but when the decision is between pillaging and dying against a good city defence, then pillaging is probably better.

Certainly, but those aren't the only options. Again, waiting for reinforcements, retreating, or simply disbanding the stack are all alternatives. I'm just not sure that the damage you'll do to the enemy is worth the benefits they may gain, and the cost to yourself.

But it's probably hard for an AI to estimate these reinforcements.

That's an understatement. ;)

edit: Oh, forgot something else, semi-unrelated to the previous, but also an issue. As it stands right now, if the AI attacks with a stack, it is committed to attacking with the stack. That is, it doesn't alter it's attack decision based on the results of previous fights. This probably also should be changed, yes?

Bh
 
Answering that question isn't easy. Back tracking to try and figure out how the AI is making decisions is complicated by the fact that it's a fairly complicated decision tree. A lot of what I'm reporting is factually incorrect because I'm trying to simplify it as much as possible.

That's probably necessary if you want to make any kind of discussion about the AI possible. You're doing a good job keeping things fairly simple.

However, to try and directly answer your question as much as possible, apparently the AI considers a group "ready to attack" if it has:
Code:
(AI_getBirthmark() % (1 + GET_PLAYER(getOwnerINLINE()).getCurrentEra())) + 4
units (or more), where AI_getBirthmark() is a random number from 0 - 9999. So basically a random number from 1 to 1 + era, + 4. The AI will still attack cities/units if it happens to be adjacent to them with less than that number, but it seems to be the minimum for a group to actually move towards an enemy city.

Ok, so the AI creates bigger armies while the game goes on, that's ok I guess. And I guess, it uses such attack groups when it is looking to attack a city to see if it has enough troops to do so.

In the game, I'm often attacked by much much larger groups, so I guess these attack groups tend to grow in strength during peace time or a few smaller attack groups are assembled into bigger groups before an attack.

I can't tell for sure, but it sounds like you're still a little confused about the strength values. Remember, these are modified strength values. So a Longbow in a city on a hill with CG3, and the city having 60% culture, is going to have a "strength" of 18.6.

I probably wasn't clear because I was assuming you had followed the discussion I had with Krikkitone about better estimating the strength of a stack. The thing is that a strength 2 unit is stronger than 2 strength 1 units. In this case, the AI might have 2 city raider 1 macemen valued at 2 * (1.2*8)=19.2 and thus think it is going to beat that longbowman. However, that isn't going to work. Even without it's first strike, the longbowman is more likely to win that encounter and the first strike (which I thought wasn't accounted for in the presently used strength formula) is further considerably strengthening the position of the longbowman.

Certainly, but those aren't the only options. Again, waiting for reinforcements, retreating, or simply disbanding the stack are all alternatives. I'm just not sure that the damage you'll do to the enemy is worth the benefits they may gain, and the cost to yourself.

Yes, I mentioned retreating. Waiting for reinforcements is a nice idea, but can only be successfully implemented if the AI knows how long it takes to get these reinforcements. Otherwise, it can't make a decent decision. I think that disbanding the stack shouldn't happen. Pillaging should almost always be better. Yes, I know, you deprive the enemy of experience and great general points. But, really, think about it: an army is being disbanded so that the enemy can't become more experienced from fighting this army. That's really a pitiful army. ;)

edit: Oh, forgot something else, semi-unrelated to the previous, but also an issue. As it stands right now, if the AI attacks with a stack, it is committed to attacking with the stack. That is, it doesn't alter it's attack decision based on the results of previous fights. This probably also should be changed, yes?

Do you mean the following: AI attacks a city defended by 6 units with its attack army of 10 because it thinks it can win. It attacks with the first 5 units and still hasn't inflicted meaningful damage. However, because it doesn't re-evaluate this decision, it keeps attacking until all 10 units are dead. Is that what you mean?

Calculating the strength of both parties is a fairly quick calculation so it could probably be done after each individual fight between these 2 stacks. The battle should continue if the not-used units in your stack are still stronger than the enemy stack OR if your unit is likely to win the present match up.
 
In the game, I'm often attacked by much much larger groups, so I guess these attack groups tend to grow in strength during peace time or a few smaller attack groups are assembled into bigger groups before an attack.

That was the minimum that it would consider sufficient to launch an attack. Obviously if it has more troops on hand, it'll use them.

I probably wasn't clear because I was assuming you had followed the discussion I had with Krikkitone about better estimating the strength of a stack.

No, I'd been following it, but I mistook your definition of "strength". I guess it's a side-effect of using the same word with multiple definitions.

I think that disbanding the stack shouldn't happen. Pillaging should almost always be better. Yes, I know, you deprive the enemy of experience and great general points. But, really, think about it: an army is being disbanded so that the enemy can't become more experienced from fighting this army. That's really a pitiful army. ;)

Any army that is, by definition, suicidal IS a pitiful army. If you split up to pillage, hit a few squares, and then are mopped up by the enemy, what have you accomplished? Sure, you've done some minor damage, but in return, they did get that experience and GG points.

I'm not advocating it as something that happens every time, but I'm sure you'd agree that it is, in fact, a better option than simply suiciding?

Do you mean the following: AI attacks a city defended by 6 units with its attack army of 10 because it thinks it can win. It attacks with the first 5 units and still hasn't inflicted meaningful damage. However, because it doesn't re-evaluate this decision, it keeps attacking until all 10 units are dead. Is that what you mean?

Yes, that's exactly what I mean. At some point the attackers should say "Ok, there is no longer any real chance of winning", and back away (assuming they lost units attacking, pillaging probably isn't a realistic choice). That's not happening.

OR if your unit is likely to win the present match up.

Really? So taking an extremely silly case of 1 Swordsman vs 10 Archers, if the Swordsman has a chance of winning it should attack? I'm not sure that's really a good idea, you'll likely beat an Archer, yes, but you'll then likely lose the Swordsman. Not very cost-effective when you could simply withdraw the Swordsman and use him in another attack later.

Bh
 
No, I'd been following it, but I mistook your definition of "strength". I guess it's a side-effect of using the same word with multiple definitions.

Yes, it is a bit confusing. I'll try to make it more clear what I'm talking about the next time.

Any army that is, by definition, suicidal IS a pitiful army. If you split up to pillage, hit a few squares, and then are mopped up by the enemy, what have you accomplished? Sure, you've done some minor damage, but in return, they did get that experience and GG points.

I'm not advocating it as something that happens every time, but I'm sure you'd agree that it is, in fact, a better option than simply suiciding?

I guess we're talking about a situation where there is a serious technological disparity between the two armies. So, not only can the weaker army not capture the city, but also each unit is significantly weaker compared to the opponent so that they'll inflict very low losses on the enemy when they're attacked while pillaging the enemies land.

Ok, that happens sometimes. It probably happens most when a lunatic like Montezuma builds a huge army and gets a little technologically backward and attacks the human player who didn't invest in units and is just teching as fast as possible.

So what would happen is Montezuma attacks with his force of 50 knights/macemen/pikemen/etc, you reinforce your city with riflemen to such an extent that he thinks an attack is suicidal and then he disbands his army. Hmm, I must say, that would probably be a pretty hilarious moment in the game. ;) :lol:

Yes, I know, killing his army would gain experience and GG-points. But if you are that much more advanced, then you can also get those experience points and GG-points by attacking him. Such a war could only end one way. I don't think Monty should make things easier by disbanding his troops for you. He should be crazy Monty and go on a pillaging streak. Take as many as possible of your men, women and children with him into death or something like that. He's programmed to be this crazy lunatic, so let him end as one. ;)

Also GG-points and experience points are certainly worth something, but they're not the most important resource in civ4 and their value also diminishes as you gain more and more. Each promotion takes more experience, each great general require more points.

If the more advanced nation doesn't kill Montezuma and just slaughters this army, then Montezuma will just start rebuilding his knights/macemen/pikeman/etc army pouring every hammer he has in it to try and match the power rating (of the power graph) of the more advanced nations.

There is actually one real reason why I don't want the AI starting to disband his attacking armies. It feels too gamey. Yes, I guess there could be situations where a human player playing the game might think it is more efficient to disband his army than to give his opponent the opportunity to gain experience points. But I don't want the AI to act like that. We also don't want the AI to start ignoring any diplomatic relations and just attack whenever the opportunity is there. We want the AI to simulate a civilization and a civilization doesn't disband its own armies when facing a (locally) stronger army.

Yes, that's exactly what I mean. At some point the attackers should say "Ok, there is no longer any real chance of winning", and back away (assuming they lost units attacking, pillaging probably isn't a realistic choice). That's not happening.

Yep, I can agree with that.

Really? So taking an extremely silly case of 1 Swordsman vs 10 Archers, if the Swordsman has a chance of winning it should attack? I'm not sure that's really a good idea, you'll likely beat an Archer, yes, but you'll then likely lose the Swordsman. Not very cost-effective when you could simply withdraw the Swordsman and use him in another attack later.

I guess every rule that you make can result in a situation where the rule is stupid. However, I don't think the above described situation is all that likely to occur. Why would the AI move an attack stack of a single unit towards a well protected city? We can only hope to create an algorithm that works in most cases and we should try to create it in such a way that it makes the right decision in the situations which are likely to occur during a game.

I was more thinking about the following case. The AI has weakened the defences of a city by bombarding the cultural defence and using several collateral damage attacks but has had some bad luck or misjudged the strength of the opposition. So the algorithm says that the defenders (5 half strength archers) are stronger than the left over attackers (2 full strength swordsmen). At this point, I wouldn't want the swordsmen to stop attacking. The archers are weakened to such an extent that an attack is a free kill and not attacking would give those archers experience and time to heal. I think it's better to get everything out of that attack now. Otherwise those suicide collateral attacks were useless. Maybe killing those archers will make a conquest with reinforcements which are arriving possible, maybe not, but at that point, they are 'free' kills. Given the effort invested into trying to kill the defenders of a city, I think you should usually take those 'free' kills. However, I certainly admit that you can create situations where it would be stupid. I just think that in general, it's a good idea.
 
Somewhere in this topic it's said that the A.I. does take promotions into account when deciding to go to war. Does that mean that if I leave units unpromoted it would encourage attacks?
 
If I create a game while using the unofficial patch (not installed as a mod, but replacing my normal dll), can others who don't use it load and play a save of that game?
 
Somewhere in this topic it's said that the A.I. does take promotions into account when deciding to go to war. Does that mean that if I leave units unpromoted it would encourage attacks?

That's not an accurate summation, no. The AI takes promotions into consideration when it is comparing stack strength. But the war declaration is based off the power ranking, which doesn't take promotions into consideration.

Bh
 
This may have been answered, but i haven't been here long enough to catch up on the whole forum. :blush:

But here goes: Why is it that when the AI attacks with a mixed stack it does not send all of the siege engines first? I see a number of times the AI will attack with the siege attacking in random order with the other units and because of that the total strength of the attack is weakened. Attacks that might have succeeded instead threw away large numbers of units.
 
I was more thinking about the following case. The AI has weakened the defences of a city by bombarding the cultural defence and using several collateral damage attacks but has had some bad luck or misjudged the strength of the opposition. So the algorithm says that the defenders (5 half strength archers) are stronger than the left over attackers (2 full strength swordsmen). At this point, I wouldn't want the swordsmen to stop attacking. The archers are weakened to such an extent that an attack is a free kill and not attacking would give those archers experience and time to heal. I think it's better to get everything out of that attack now. Otherwise those suicide collateral attacks were useless. Maybe killing those archers will make a conquest with reinforcements which are arriving possible, maybe not, but at that point, they are 'free' kills. Given the effort invested into trying to kill the defenders of a city, I think you should usually take those 'free' kills. However, I certainly admit that you can create situations where it would be stupid. I just think that in general, it's a good idea.

This is where I need to have a good collection of save files to test against. While you can set up individual attacks with WorldBuilder, it's not good for tests involving things like wounded units. Nor is it really "easy" to set up city attacks. And playing through games until I get to spots where the AI is attacking me isn't really a good plan either. So if you (or anyone else) have examples of bad AI attacks, or AI attacks where it becomes obvious after a few losses that they should withdraw, that would be helpful.

Bh
 
This is where I need to have a good collection of save files to test against. While you can set up individual attacks with WorldBuilder, it's not good for tests involving things like wounded units. Nor is it really "easy" to set up city attacks. And playing through games until I get to spots where the AI is attacking me isn't really a good plan either. So if you (or anyone else) have examples of bad AI attacks, or AI attacks where it becomes obvious after a few losses that they should withdraw, that would be helpful.

Bh

I'm not playing the game a lot at the moment, but if I get a situation then I'll post a savegame in this thread.

Are you looking for any situation, or just city attack situations, situations with siege units, or something else?
 
Good question. Hard one to answer. City attacks are probably the most valuable - especially ones with obviously poor odds. Any stack attacks where it's obvious that the AI should have called it off at some point would be valuable as well.

The hardest one is going to be trying to check city attack decisions, because there's nothing in game to let you know when those are made... Not sure how I'll test that case.

BTW, it looks like it's going to be a little easier than I thought to do the pseudo combat calculations.

Bh
 
Good question. Hard one to answer. City attacks are probably the most valuable - especially ones with obviously poor odds. Any stack attacks where it's obvious that the AI should have called it off at some point would be valuable as well.

The hardest one is going to be trying to check city attack decisions, because there's nothing in game to let you know when those are made... Not sure how I'll test that case.

Ok, I'll see if some rather stupid behaviour of the AI occurs in the near future.

BTW, it looks like it's going to be a little easier than I thought to do the pseudo combat calculations.

Bh

You mean simulation runs? Sounds good. :) Any idea how many the game can do in a reasonable amount of time?
 
You mean simulation runs? Sounds good. :) Any idea how many the game can do in a reasonable amount of time?

No, I haven't got to that stage yet. Right now I can just simulate 1-on-1 combat. Still have to put together stack combat, and then figure out how to deal with the results. But hey, can't be that hard. ;)

Bh
 
But here goes: Why is it that when the AI attacks with a mixed stack it does not send all of the siege engines first? I see a number of times the AI will attack with the siege attacking in random order with the other units and because of that the total strength of the attack is weakened. Attacks that might have succeeded instead threw away large numbers of units.

Are you referring to amphibious assaults? The AI doesn't consider the units onboard different ships to be part of the same stack, so considers the cargo individually when deciding to attack.

Bh
 
In reference to the discussion way back about ship defense selection... Apparently when selecting a unit for defense, it divides the "defense" value that it's calculating by (# of cargo + 1). The "defense" value is modified, so it's not precisely the str, but roughly close. So a transport with 1 unit on board would need roughly x2 the str of another unit to be selected to defend.

Not really relevant to any current discussion, but a nice FYI. ;)

Bh
 
Are you referring to amphibious assaults? The AI doesn't consider the units onboard different ships to be part of the same stack, so considers the cargo individually when deciding to attack.

Bh

I've had it happen as an amphibious assault, against a stack in the field, and against cities that the AI did not attack with all the siege first and because of that lost a lot of units that might have won if all the siege had gone first.
 
Just thinking further on what you said, it may well have been separate actual stacks in each case. But if so, that also is an issue that weakens the AI's war. In not combining the stacks and ordering the units before an attack, it lessens it's chance for a win.

I don't know enough about the programing to understand ways in which the AI's strategic and tactical decision making could be improved.

I suppose my issue is that if the human is remotely within spitting distance of the strength of the AI, victory isn't that tough because almost any experienced human player can out plan and out execute the AI. BtS improves that because the AI rushes defenders to vulnerable border cities instead of prioritizing defense of the core cities above all else. Also the super stacks it creates are in at least some cases an added difficulty for the player.

Still, I would find it more enjoyable if the AI was better at tactics and strategy rather than just having big numbers.
 
^^that's true. the AI tends to not send in all their artillery first and then attack with the regular units which can easily crush the softened up defenders. there are a lot of times when they could have taken a city by sending in all their artillery first and then attack the city and didn't.
 
No, I haven't got to that stage yet. Right now I can just simulate 1-on-1 combat. Still have to put together stack combat, and then figure out how to deal with the results. But hey, can't be that hard. ;)

Bh

Sounds like a piece of cake. ;)

Good luck with that.

In reference to the discussion way back about ship defense selection... Apparently when selecting a unit for defense, it divides the "defense" value that it's calculating by (# of cargo + 1). The "defense" value is modified, so it's not precisely the str, but roughly close. So a transport with 1 unit on board would need roughly x2 the str of another unit to be selected to defend.

Not really relevant to any current discussion, but a nice FYI. ;)

Bh

Ah, so the missile cruiser with 1 missile would defend before the empty transport but the missile cruiser with 4 missiles would defend after the empty transport. Sounds ok to me. It takes into account both the losses that you might sustain and the strength of the unit.
 
With regards to the attacking issue - units with collateral damage are not automatically selected to attack first.

How it works, roughly, is thusly:
Every unit within an attacking stack checks what its combat odds would be vs the best defender of the enemy.
If a unit can do collateral damage, its odds are modified by (100 + (iCollateralDamage x (# of defenders or iCollateralDamageMaxUnits)) / 5) / 100. iCollateralDamage appears to be 100 for all the default siege weapons. The iCollateralDamageMaxUnits varies from 6-8 (and it's always the lower of the two that is chosen). So effectively that formula is (100 + (100 x (# of defenders or iCollateralDamageMaxUnits)) / 5) / 100. So let's say that the defenders had 5 units in their stack (lower than any of the iCollateralDamageMaxUnits values). It would be (100 + (100 x 5) / 5) / 100, or (100 + 100) / 100, or 2. So the odds for a unit with collateral damage would by multiplied by 2.
Final step is to choose whatever unit has the highest (modified) odds of winning.

The last step is where the tricky part comes in. Let's make up some numbers for an example. Our stack is 1 Knight and 1 Catapult vs 5 Longbows (out in the open, so no bonuses), no promotions for anyone. So the Knight is str 10 vs str 6, the Catapult is str 5 vs str 6. I don't know the actual odds, and that's not really relevant, so let's assume the Knight has a 80% chance to win, and the Catapult has a 25% chance to win. Using the above formula, the modified odds for the Catapult would be 25 x 2, or 50%. But 50% is still below 80%. So instead of attacking with the Catapult, the AI would choose to attack with the Knight.

There are some other issues going on that can modify this to some degree, but I'm not going to go into that much detail - this is basically what's going on. This is very likely why you would see some units attack before siege weapons - because their chance of victory is much higher than the siege weapons' is.

Bh
 
Top Bottom