AIs and the Art of War

That's a relatively new modifier (well, was added by ROM/AND I think), and you're right -the AI doesn't really understand it. I'll look into doing something about it...

Could you post a save with a good example where an AI is poised to attack but doesn't/can't due to this, so I have a good test case please.


V27 View attachment save.part1.rar View attachment save.part2.rar

Here if you can salvage it. Had to abandon this game because it crashes after skipping a turn and I was playing another game in between so no autosaves. It's huge (20MB) so maybe that causes problems.

BTW are there some limits after which the game gets too unstable in general?
 
V27 View attachment 349595 View attachment 349596

Here if you can salvage it. Had to abandon this game because it crashes after skipping a turn and I was playing another game in between so no autosaves. It's huge (20MB) so maybe that causes problems.

BTW are there some limits after which the game gets too unstable in general?

We're generally addressing any such limits as they are found. If you're using viewports then the answer should be 'no'. Without viewports large maps will eventually become unstable usually due to running out of process memory. Several limitations that were present in V29 are fixed on the SVN version however, and I am no aware of any scale-instability on the current SVN version with viewports (and indeed without up to about 'Large' or possibly one above in map size on 64-bit systems with 4G RAM)
 
We're generally addressing any such limits as they are found. If you're using viewports then the answer should be 'no'. Without viewports large maps will eventually become unstable usually due to running out of process memory. Several limitations that were present in V29 are fixed on the SVN version however, and I am no aware of any scale-instability on the current SVN version with viewports (and indeed without up to about 'Large' or possibly one above in map size on 64-bit systems with 4G RAM)

There very well could be as yet unknown errors in highly developed games stemming from integer (or other types potentially) overflows.
 
Some things I noticed on the very recent AI:

1) AI struggels if it can't get straight to the city if it wants to attack.
For example, the AI needs to pass my Fort which isn't directly on their way:

W W W W
1 L L L 2
W W F W

(W=Water, L=Land, F=Fort)
If the AI wants to walk from 1 to 2, they need to conquer my Fort because of it's ZoC. (I know it's poorly illustrated, but Koshling knows what I mean, he as my Savegame and is working on it)



2a) AI won't use Ships to get over a small water area if departure and arrival is at the same continent. Imagine the small area of water between Spain and Africa. If The AI in North Africa want to conquer a city in Spain, they would walk all the way, Over Egypt, Suez, East Europe, the Alpes, France... Even if they HAVE enough ships.

2b) That is a problem but it gets even worse: Imagine on Suez would be an active Volcano so there is no way to walk this way! The Player would easily use ships to pass the volcano, but the AI just keeps sitting in Africa.

2c) And I think that's the same as 2a and 2b: The AI can't use land-transports or, if they want to go from India to Korea, ships, eventhough ships have 3 or more movement and their troops only 1.

3a) AI uses Forts to connect resources, even on their own territory, which is great. But it doesn't defend them properly (if at all) even if they see my large army nearby. It's very easy to conquer those forts so they haven't access to the resource anymore - and can't get it back so fast because I know that I need to defend my forts.

3b) AI rarely uses forts to secure their boarders. Especially small landbridges are so much easier to defend when you have a fort. And, I don't know if it's possible, but since you have a SoC it should work: They never use Forts to secure resources outside of their boarders.

4) There are weird things going on with the odds...
a) Wenn I attack with my Hero Sargon, he has 100% victory chance. When I attack with any other hero, they have ~40% chance. He can't be THAT much stronger? (Savegame is following)
b) My chances of attacking with my hero are around 95%, but when I surround the city with ballista elefants, the chances for my here are only 5% ?! (Also, Savegame is coming later)
c) Even though they say the victory chances for my Praetorians are ~90%, 2/3 of them die (n=15). This MIGHT be bad luck, but could also be wrong displayed. May have a Savegame, but it is probably reproducable with the two others since they were all at the same siege within a few turns.

5) Same savegames as 4) -> My stack is sitting on a hill next to a city, and they have some many units that they could easy kill me. They might lose a lot of units, but they should be able to kill my entire stack - leaving my empire mostly undefended, except for a few Town Watchman.

6) The AI doen't use SoD. I know you know that, Koshling, and I know why the AI can't do it, I just want to mention it here so it won't be forgotten.

7) The AI doesn't know when it can use the size of their stack even with low individual odds. IE If you have 10 Defenders and the AI has 50% chance to win, it doesn't matter for the AI if it has 10 or 1000 units.

8) As far as I can tell, the AI does not plan ahead when going to war. If I have a city in the far north (or in a desert), they go for it with a giant stack, but since they get so much terrain damage, they retreat without even attacking. If I plan to conquer an ice/desert city, I use either desert/ice combat promotions, the march promotion + a healer or I build a fort near my target city where my troops can heal.
Note: This might be fixed now. I never play with terrain damage on since I saw that, because it really cripples the AI. A city with a decent deense (like 5 Riflemen and a Wall) can easily be defended just a few tiles away from my enemies boarders and be an excellent Airbase.
I don't have a savegame now, but it can be easily provided if you need it, just let me know!

9) When my "Friend" moves a big stack of units through my territory, I build a large stack of well promoted Bandit Riders or anything else with hidden nationality and beat the s**t out of their stack. This way I get GG Points, Slaves and I know, the AI will use the stack against ME later anyway -.- It would be very sneaky if the AI (on higher difficulties) would do this, IF it knows it doesn't need your support against their enemies and/or if they wants to attack you later.

10) Sometimes it is wiser to leave your city and let the enemy conquer it. Especally if you have mostly units designed to city attack. Would be another thing that would the AI on higher difficulties makes smarter, not better by giving it more bonus.

11) I have no idea why, but the AI seems to have their primary stacks nowhere near the Boarder. In my game, the Zulu control the complete african continent. There is no "neutral" or barbarian territory there. I am the only threat for them, near the suez cannel. But their stack is just not there.
-> The AI should keep their stacks near the boarders so they can counterattack quickly. Maybe not in my visible range, so they can suprise me.


That's all from the top of my head now, I'll let you know once I find something else.

And if you need savegames for something, I'll try to get them, making up a situation with the WB if necessary ;) Just let me know!
 
Added two Savegames to the post above.


Also, now the Celts declared war on me 30-40 turns ago and I've never seen a stack larger than 10 units! They only attack my Fort north of Nordington (North of my Capital) with single units or try to attack with Bandit Raiders in Turkey, but nothing more.
 
2b) That is a problem but it gets even worse: Imagine on Suez would be an active Volcano so there is no way to walk this way! The Player would easily use ships to pass the volcano, but the AI just keeps sitting in Africa.

I can confirm this. In my current game a huge continent is divided by a mountain range in the middle. All of the AI players are crowded in the eastern half of the continent (not sure why the map generator made this so) and all space has been used up by the 4 civs there for a long time. But no civ ever tried to settle the huge open land in the west directly behind the mountains by means of ships. I can´t say though what would have happened after mountaineering because before they researched that all the land was already occupied by me ;) ...
 
I can confirm this. In my current game a huge continent is divided by a mountain range in the middle. All of the AI players are crowded in the eastern half of the continent (not sure why the map generator made this so) and all space has been used up by the 4 civs there for a long time. But no civ ever tried to settle the huge open land in the west directly behind the mountains by means of ships. I can´t say though what would have happened after mountaineering because before they researched that all the land was already occupied by me ;) ...

This is a known issue, which I am aware of, and which I need to tackle at some point. If they had mountaineering they would have settled it (just FYI).
 
Two Savegames:
-Sargon Strange Odds is for 4a -> He has 100% while others are WAY weaker. Is that normal?

-Strange Odds is for 4b: See what odds you hae with different units, the heros, the Elephants, the Preatorians... Then move the Ballista Elephants around the city, so that on every tile around the city is one Elephant. Now check the odds again. In my game they dropped from 95% to 5%!

Also, could you try to attack with the Preatorians/Heros? For 4c: When I did it they said the Odds are high, but I lost more units than I expected.

Both of these are (more or less) correct, but it's VERY easy to be mislead, and one mechanic hat is involved in this is worthy of further discussion!

Firstly, if you look carefully at the odds details in each case you'll see that it is NOT always the same unit that is defending.

In the first case (the Sargon test save) against every unit EXCEPT Sargon the defender is a hero (Kahina), but when Sargon attacks the defender is a horse archer. Unsurprisingly, Sargon easily beats up a horse archer! I'll come back to why the choice of defender is different below...

In the second case (S&D odds) the same thing happens. At first the defender is a War Wagon, and the odds are decent. However, as soon as S&D cuts in the defender changes to the hero Kahina, and the odds drop (very) dramatically. If you look closely you'll find that as you add more surrounding elephants your odds do slightly improve, so the actual effect of S&D is working fine.

In both cases the reason the defender changes is that the hero gets RELATIVELY better in some circumstances, coupled with (and this is the important part) the fact that the code HALVES the evaluation of unique units when choosing what to defend with (I don NOT mean it halves their actual defensive value, just the measure it uses to CHOOSE the defender). The net result is that in cases where the hero is approximately twice as strong as the next best defender the small changes in RELATIVE strength (due to surround and destroy code which is sensitive to several factors) can result in a switch between a hero and a half-as-strong other unit as the chosen defender. Obviously if you kill the easy ones, it will EVENTUALLY defend with the hero, and you'll get the much worse odds at that point anyway.

One other factor, which plays a huge role in the Sargon case, is first strike immunity. Horse archers are immune. Kahina is not. Sargon has a decent first strike capability - hence the horse archer's RELATIVE value increase (compared to Kahina's) a LOT against Sargon.

There was also a small bug in the S&D code due to the combat mod, which I will fix, but it doesn't play a substantial role in this analysis.

So, in summary, it's correct for the way the game currently works!

HOWEVER, I'm not sure it SHOULD be halving the evaluation of heroes in this way. The reason it does it (I guess) is that you probably would prefer to lose a non-hero compared to a hero, so it preferentially defends with not-TO-much-worse other defenders first. That logic seems fine to me. However, a factor of TWO seems too much. I would think we might want to change this - I suggest making it a global define as a percentage modifier to apply to heroes, and set it around 75% (rather than the current [hard coded] 50%).

Opinions welcome...
 
Wow... this is an amazing game analysis! I haven't pay much attention on details of the odds. Btw, I changed the save so that the units lost most of it's first strikes. I try to give them a promotion to counter that (ex changing from Drill I to Combat I) but I think the Warlord is somewhat weaker now.
 
I believe the purpose of the heroes being evaluated at half like that is so that you won't lose your best to their best. Rather you'll send, which is VERY frustrating to the attacker mind you, your fodder up first, let them waste their best units on rounds of attacks which weaken them a bit, then come back up with a solid defense once their strength has been largely wasted and now they've only got left what they'd prefer not to attack with but if they do it will be almost entirely futile.

It makes defense far more clever this way than it was in vanilla where you'd always have the strongest defender come up in the stack first. I would prefer we see this is the point of the mechanism rather than attempt to approach it as an overly aggressive attempt to code a way to make heroes and such slightly more survivable by having them avoid combat until they are more confident in success.

If anything, a more complex coding could even identify unit levels and, as they develop, have the code reduce their perceived value for sending them up as the primary unit to defend with, even if they ARE stronger. For the same reasons as mentioned above, your field commanders would want to preserve these well developed units and send the fodder in first, to an extent anyhow, just enough to blunt the attacker's spearheads.

I'm of course a little curious about the bug in my earlier code. For the mistakes I make now despite beginning to see much of the code in the dll as a language I understand as I read and write it, rather than a technical puzzle, I shudder to think of the mistakes that may lurk in some of these earlier code works.
 
I believe the purpose of the heroes being evaluated at half like that is so that you won't lose your best to their best. Rather you'll send, which is VERY frustrating to the attacker mind you, your fodder up first, let them waste their best units on rounds of attacks which weaken them a bit, then come back up with a solid defense once their strength has been largely wasted and now they've only got left what they'd prefer not to attack with but if they do it will be almost entirely futile.

It makes defense far more clever this way than it was in vanilla where you'd always have the strongest defender come up in the stack first. I would prefer we see this is the point of the mechanism rather than attempt to approach it as an overly aggressive attempt to code a way to make heroes and such slightly more survivable by having them avoid combat until they are more confident in success.

If anything, a more complex coding could even identify unit levels and, as they develop, have the code reduce their perceived value for sending them up as the primary unit to defend with, even if they ARE stronger. For the same reasons as mentioned above, your field commanders would want to preserve these well developed units and send the fodder in first, to an extent anyhow, just enough to blunt the attacker's spearheads.

I'm of course a little curious about the bug in my earlier code. For the mistakes I make now despite beginning to see much of the code in the dll as a language I understand as I read and write it, rather than a technical puzzle, I shudder to think of the mistakes that may lurk in some of these earlier code works.

FYI - the minor error was that when calculated the S&D bonus your changes accidentally introduced terrain defense bonuses into the calculation when processing he surrounding units (S&D calc only included them for the actual attacker originally, and that was very deliberate). This is the difference between passing NULL for the plot to evaluate against rather than the actual defending unit's plot.
 
T-bird: I don't know about you, but I break off an attack when the odds start getting to unacceptable (% dependent upon the situation). Those same best units can attack again the next turn. If they beat up on fodder they won't be that hurt.
 
T-bird: I don't know about you, but I break off an attack when the odds start getting to unacceptable (% dependent upon the situation). Those same best units can attack again the next turn

And you give your enemy time to build new unit or bring reinforcements. So this strategy is not always the best.
 
T-bird: I don't know about you, but I break off an attack when the odds start getting to unacceptable (% dependent upon the situation). Those same best units can attack again the next turn. If they beat up on fodder they won't be that hurt.

Ok, so in further evaluation of such a situation:
1) As Nimek points out, that extra round could mean a second chance at survival for the defender who has units on the way, units in construction, defensive buildings set to complete, reduced research to rake in gold for out of date units to be upgraded, a new tech to finish so units can be upgraded into something now undefeatable, another 5% fortification bonuses earned for some defenders who recently arrived to the battleground, and a chance to get their attack armies into a position to recapture the city or battleground plot if you do take it the next round. Every round the enemy can delay you from winning the battleground position, usually a city, is another chance for them to affect a change that may give them a new edge.

2) If the city is building or getting new fodder troops in at a steady rate, this could mean that the city may never be taken with this approach.

3) If your primary attackers wound themselves at all, which can happen even if they are far stronger than the 'fodder defenders', they cannot heal that round due to the fact that they acted (unless they have the march promotion or the ability to move and heal, units that act in a round cannot heal in the time to the next round.) So now you're primary attackers may not be able to take on the best defenders the next round and must wait and heal. Not 'that' hurt can still mean hurt enough that the best defenders now have a fighting chance to really kill off your hard earned veteran units if they try to press the attack the next round without healing. So commonly, there's another round bought so go back through pts 1 and 2 and consider all more likely with a second round of delay.

4) We have buildings that will potentially wound adjacent units to the city. This means that rather than healing if they sit out there, they could be taking even more damage and weakening further while those in the city are commonly enjoying the benefits of faster healing. There's further potential delay.

5) If your attack stack wears down in enemy territory, they are a ways away from home and re-enforcements are commonly difficult to bring to the front as they may be picked off by field defenders while on their way unless they wait to build themselves into a more survivable stack. However, your enemy's other cities are not only closer to the conflict but can usually use his own infrastructure (road system) to rush his defensive re-enforcements to the fight, or better yet, build a counter attack army that is specifically designed to defeat your invading forces.

I love forcing the enemy to take numerous rounds to get through a city, it lets me know exactly what I'll need to build to adequately defend myself, gives me a chance to wear down their power in the process, and get myself into position to counter with a crushing retaliation, whether they take the city eventually or not.

And recognizing the danger of allowing the enemy this time to bolster his reaction to my invasion, I will potentially waste some of my weaker attackers if I feel it could buy my way into the cities I'm attacking faster and of course it then becomes very frustrating that their best defenders just came to the front after fighting a number of 99% wins with my own best attackers.


All of this of course assumes that the fight is somewhat even in tech levels but I don't think this discussion comes up when you're taking tanks against archers.
 
Also i always play with emergency draft bug gameoption with means that big cities are more hard to capture. I love it.

More difficult means more glory for myself for this achivment
 
*shrug* You also have the option of not using your best attackers first. If the defender is going to put up fodder you can start with secondary attackers and see what he puts up to defend against them.
 
*shrug* You also have the option of not using your best attackers first. If the defender is going to put up fodder you can start with secondary attackers and see what he puts up to defend against them.

That's right... and that's probably the best way to go about it at that point provided that the fodder they throw up against your weaker attackers is still defeatable by those weaker attackers or you have enough numbers to run this gambit. All in all, it's a good design because it makes you think about how to attack properly right?

Attacking as a stack and letting always the strongest go in first is thus not the best way to go many times and therefore the lazier, newer, or less insightful player will suffer from a lack of careful planning.
 
Shaka is near my city of Thebes

He as a big stack of units (including rams). I think that he can win easily and capture city but istead he decided to move forward and dont even try to reduce defenses of Thebes

I also wondering wo thingsit shou

1 Why Shaka dont take to this big stack at least one medic
2 Why there is so much difference beetwen AI civ scores. (Shaka beats me almos twice when other civs have two time less than I - it should be more balanced i think)

After some more turns I ynik that AI cant handle noEntryLevel tag. AI never reduced defense in any of my cities that have above noentrylevel defenses.
 

Attachments

  • THEBES.zip
    3.8 MB · Views: 154
Top Bottom