AIs and the Art of War

Were you guys complaining about siege units? Have a look at this!
What's strange is that not all AI civs are doing this. Healer spam is mostly solved btw.

I believe that turning off Terrain Damage in the BUG options should cut down on the healer spam, but I don't know what causes the AI to spam siege units like no tomorrow. There are so many siege units in my game, I'm sure it's slowing down turn processing.
 

Attachments

  • lots of siege.jpg
    lots of siege.jpg
    293.1 KB · Views: 268
Healer spam may be solved, but Shepherd and Apothecary spam isn't. For instance, in my current game, the Maori are staffing their only remaining city with 20 shepherds and 40 apothecaries, in addition to a mere handful of longbowmen. That's just silly.
 
Healer spam may be solved, but Shepherd and Apothecary spam isn't. For instance, in my current game, the Maori are staffing their only remaining city with 20 shepherds and 40 apothecaries, in addition to a mere handful of longbowmen. That's just silly.

Did you change iNumHeal for ALL healing units by +4?


RE the above post. That actually is a helpful post. I think I have a clue what's taking place there - a LOT of city attack stacks are being seeded. That's not exactly what I would've expected to see so it points to another issue entirely that I hadn't considered being a problem.
 
Did you change iNumHeal for ALL healing units by +4?

I remember doing a find-and-replace on a lot of units, but possibly not all of them. I'll have to check.
 
I'd think the main reason they would be overstaffing one last city with so many healers is because those had been built for other purposes but never upheld those or had managed to get out of the way of danger while those they were intended to help heal did not. If they are still training them, it's because they were queued to be trained when the need for them existed and there's nothing in the code to interrupt or adjust that queue once the units have been ordered.
 
My fear in using this particular dial is that it may create some unexpected mathematical results but someone can try it out to find the right balance.:

Code:
	<Define>
		<DefineName>C2C_ROUGH_BOMBARD_VALUE_MODIFIER</DefineName>
		<iDefineIntVal>0</iDefineIntVal>
	</Define>
Try taking it into the negative and see if it helps. Maybe -20 for a test run.

I changed this to -25, for the moment the AI attack stacks look more reasonable. Thanks!
Instead of healers they now use one healer and many shepherds, any quick fix to that?
 
I changed this to -25, for the moment the AI attack stacks look more reasonable. Thanks!
Instead of healers they now use one healer and many shepherds, any quick fix to that?

Are they using a lot of animals or maintaining a lot of animals? That's what should tend to prompt lots of shepherds.
 
I'd like to address Alberts2, Koshling, AIAndy, anyone who is knowledgeable about the unit AI portions of the code for a bit. I think we need a deeper discussion on some of these issues as I often feel like I'm guessing about certain things and it would be good to share our understandings and strategize together to find better ways to improve things. Suffice it to say I REALLY don't want to do anything that's going to cause unanticipated results.

To start the discussion, we're still having some difficulty with city attack stack formation. This is just one of many issues I'd like to discuss but we need to start somewhere right?

By the way, Alberts2, our discussion and the results of your implementation of the new Hunter companion AI produced what I believe is an outstanding improvement for the AI. (Putting the needs for a hunting party in proper perspective to some other potential concerns is still one of a great many priority issues the AI still has but if the AI isn't being harassed I think it's currently very appropriate - and effective.) So that's a real inspiration for us knocking heads further. Well done man!

Anyhow, this particular section in the code is troubling to me. I made an adjustment here a while back and I'll explain it and why I did but let me first post the code and then I'll bring up the discussion points.

This segment is found in
void CvCityAI::AI_chooseProduction()
and falls into the routine that determines current build priorities for the city.
Code:
if( iStartAttackStackRand > 0 )
		{
			int iAttackCityCount = kPlayer.AI_totalAreaUnitAIs(pArea, UNITAI_ATTACK_CITY);
			int iAttackCount = iAttackCityCount + kPlayer.AI_totalAreaUnitAIs(pArea, UNITAI_ATTACK);

			if( (iAttackCount) == 0 )
			{
				if( !bFinancialTrouble )
				{
					if (AI_chooseUnit("build attack force", UNITAI_ATTACK, iStartAttackStackRand))
					{
						return;
					}
				}
			}
			else
			{
				if( (iAttackCount > 1) && (iAttackCityCount == 0) )
				{
					if (AI_chooseUnit("start city attack stack", UNITAI_ATTACK_CITY))
					{
						return;
					}
				}
				else if (iAttackCityCount < (3 + iBuildUnitProb / 10))
				{
					if (AI_chooseUnit("add to city attack stack", UNITAI_ATTACK_CITY))
					{
						return;
					}
				}
				else if (iAttackCount-iAttackCityCount < (3 + iBuildUnitProb / 10))
				{
					if (AI_chooseUnit("add to attack stack", UNITAI_ATTACK))
					{
						return;
					}
				}
			}
		}
Ok, lets start with some questions.
1) If I'm understanding this right, any call to build a unit with AI_chooseUnit is translated through the brokerage and may end up being a call to another city to build the unit, not necessarily this one. Am I correct?

2) City attack stacks will also themselves make calls to the brokerage (tendering) system to ask to be filled to its optimal stack size and content. Correct?

3) If a city attack ai unit is trained (without necessarily being called by a city attack stack request of the brokerage system but rather from a call here) and there is then subsequently a call for a city attack ai unit BY the brokerage, this unit will be found first and answer the call before another unit is ordered for training? Is that right? I'm a little confused on this point. If that's correct then:

4) The newly trained city AI unit that was ordered by a city (and not an existing stack) would come out and immediately start calling for other units to form its own stack with right?

Assuming 3 and 4 are correct:
5) What then happens when a unit that is already calling for other units to be trained and join it in forming a new city attack stack is itself called to join another stack by the brokerage finding a suitable match for another stack's call? Does this potentially start a domino effect that will call far more than expected amount of city attack units to be trained?

6) Would it then stand to reason that our method of counting city attack and attack UNITS rather than STACKS is completely flawed here? This really means that as a stack begins to form, it keeps any further stacks from being able to form right? Or even worse, it only considers the nation to have a stack formed if the count of those AI's is currently geographically local to the city? It just seems very flawed to be taking a count of units rather than a count of centralized units that comprise the leaders of each stack. Even counting groups wouldn't quite be the same.

7) If all of the above is true and there IS the suspected 'issue', should we add a new AI specifically to lead city (and other types of) attack stacks that is only called for by the city (in this function) and then is tasked to ask of the brokerage mechanism for the appropriate balance of additional units it seeks for its army? (then if killed later another unit in the stack is selected to become the stack leader and its AI is changed accordingly) Or would it be better to use some other sort of solution? I've insinuated MY proposal.


The change I made was quite a while ago as it looked like the AI was only ever building one siege unit because it would only potentially build one when it was called through this routine. I later found the issue was located elsewhere in that the city attack stacks were, once started, asking the brokerage for only attack AIs and weren't asking for CITY attack AIs.

But that's the root of another issue. If siege units become the leader of a city attack stack, many can't attack all targets properly and will ignore targets, potentially even cities themselves, that they could and should be attacking. I've really come to the conclusion that for this and the benefit of better crafting promotion selections for siege, that siege units would be easier managed if split up into new AI types for each of their specific roles, then become a part of what is called for by a stack leader.

I also wonder how effective the Shadow command is. Is it already established that we can tell the AI to build separate mini-stacks that have their own behavior commands but generally march right along with another stack of an AI type? Is it easily established that a stack of an AI type isn't to feel ready to do certain things (like deploy) unless stacks of another AI type are fully prepared to accompany them?

I'm getting ahead of myself. Let's talk more about the questions above and see where this goes.
 
1) Yes, any unit creation is a brokerage request (except settlers I think??). However, that's generally a good thing since the brokerage system will source it from a city that takes account of:
1.1) Whether it has more urgent build needs, so it allows cities that don;t have urgent needs to be building for others
1.2) What promotions a unit of this type will get at each building city (tends to prefer building at cities that have more promotion benefits for that type of unit)
1.3) How far away it is (prefers close obviously) [note this is path distance not crow-flies distance]
A unit built-to-order in this way will immediately move to the ordering city on completion (it **can** be intercepted form higher priority use but in general it shouldn't be most of the time)

2) Yes

3) Yes unless it is being used for something with a higher priority already

4) When it gets to the ordering city yes. I don't think it will before this (but not 100% sure)

5) Not certain, but it definitely shouldn't cause a cascade. At worst it will leave the units it previously asked for looking around again for something else to do (and if a different stack is calling for attackers they will fill those tenders)

6) Depends what the count is used for. Do you want to regulate the number of independently functioning and target generating) stacks, or the total military strength? Either way existence of one stack should not prevent another from forming (at least not due to the brokerage system - not sure if there is other code that inhibits attack stack formation). As far as the brokerage system is concerned multiple attack stacks can be asking for new units, and the brokerage system will try to fill all the requests (subject to the requested priority)

7), No opinion really. What you say sounds plausible, but I don't really see why it is different from what the cityAI AI type does now. With your solution you would have to handle promotion when the leader died (rather than others in the stack already having the same AI type). I don't really see the benefit since you can do any special processing in the existing AI type's routines conditionally on it being stack leader of a stack of more than 1 (or any other threshold you want) units

Siege units probably really need their own AI type. C2C adds lots of mechanics to city attack that differentiate siege units from others much more than base Civ did. I am unsure how well Shadow works.
 
Great and thorough response! Thank you!
Do you want to regulate the number of independently functioning and target generating) stacks, or the total military strength?

I think you really struck on the heart of the matter here. To answer the first question, I think its important to regulate the proper fulfilling of role needs first, then measure the military strength to infuse into those roles according to the perception of current need.

Case in point, at first you'd only need one city attack stack. However, as time goes on, the nation grows, perhaps the AI player preferences vary, and ability to maintain more military financially expands, it may be more valuable to have multiple city attack stacks. It can also be important to get the AI to start labeling its City Attack stacks and phases that they are in. Deployed, Building, Ready for Deployment etc. The size of a stack to be considered 'ready' would be measured by the perception of preparation for invasion that the enemy has. (And likewise, the size of defensive efforts should be related to the perception of potential or known enemy preparedness to invade.)

I'm finding this discussion is difficult to keep from going off into tangents but getting back on track, I was thinking it would be easier for the cities to build only seed units for stacks that would fulfill various roles. I was thinking this would be easier if new AIs were defined to do so.

However, you bring up this interesting point:
I don't really see the benefit since you can do any special processing in the existing AI type's routines conditionally on it being stack leader of a stack of more than 1 (or any other threshold you want) units
However, what about if you are talking about a stack of 1 unit that you ordered to be built so as to begin a new stack? Can you force that unit to deny any brokerage calls somehow so that it doesn't inadvertently become absorbed into another stack? Can you, when the unit is still on its own, count it as the lead unit of a stack that just hasn't begun to form beyond itself yet?

I suppose the ultimate answer to your first question is, yes, I'm looking for better stack regulation than just army strength regulation.

A major strategic weakness is that they build their reinforcements and send them one at a time, making them easily picked off. It would be MUCH better if they simply let their primary assault stack run down and rebuild another one in the background and after a point just pull back their primary assault stack for being reinforced at home. This is just one of many potential examples how stack management could/should be improved.

It also counts for city defenders. It would be better if the city defenders formed mini stacks with proper cross-stacking for optimal defending, and cities counted not how many defenders they had but how many mini-stacks they had and the statuses of those ministacks. If we then made it so that only the city that began building such a mini-stack would continue to finish it before that stack proceeded (all together) on to the destination they were built for we could perhaps reduce the 'death in transit' that a player can so easily inflict on the AI currently.
 
I think the Civ4 AI lacks in AI-Player level decision making. Basicly all unit stacks and cities act on their own that makes some of the things you want to do impossible at the moment. I don't know if the amount of work needed is really worth it.
 
Would it really be so hard to control stack development more by generating stack leader specific AIs? I'm thinking with the brokerage system it would actually make it pretty easily done. Not to say any AI work isn't pretty overwhelming. But some improvements do need to be made to make the AI much more competitive. And Koshling has pointed out before that lacking in much the same terminology.

I don't think it would be too difficult either to say, establish, at the player level, a priority of city targets to take down and to send attack stacks to sack them as long as another stack isn't already attempting it. Just how much more challenging would it be to have 3 concise invading armies, each going after different cities, than it would to have a closest target is the first target warfare approach from the AI? I think it would be a tremendous benefit for the mod.
 
In late ancient in a game without Start As Minors, the AIs are running around with Master Rangers (str 6), but still seem to feel the need to escort them everywhere. The worst the barbs can field is (str 5) comp bows, and my ambushers are no threat. I suppose if war was declared suddenly, it might help them, but it still seems overcautious.

While on that topic, the one unit they never include in their escort is the (trained or war) dog. If they did, my ambushers would have to be more careful to end turns in cities or palisades (ie. while we have open borders).
 
My game on two week old SVN.

Eternity, Emperor, in Ancient era- attacking a Portugeuse city which was defended by 70 Battering Rams and a couple of Archers.

Took a while to defeat them
 
Have a maximum UPT limit of, say, 40, and it will make those sort of occasions less extreme.
 
My game on two week old SVN.

Eternity, Emperor, in Ancient era- attacking a Portugeuse city which was defended by 70 Battering Rams and a couple of Archers.

Took a while to defeat them

It may look strange from a roleplay point of view, but Battering Rams are a strength 5 unit therefore not a bad unit to mass produce. Although it doesn't get the defensive bonuses archers get. 80 Rams are more effective than 80 healers. So I'm not sure this is actually a bug.
 
It may look strange from a roleplay point of view, but Battering Rams are a strength 5 unit therefore not a bad unit to mass produce. Although it doesn't get the defensive bonuses archers get. 80 Rams are more effective than 80 healers. So I'm not sure this is actually a bug.


Sure. It was a tough enough battle but Archers would have been far more effective plus Spears or Atlatls to take on my mammoths and Horses but Yes I was happy to see they had plenty of defenders
 
Now the AI is "gifting" me a Battering Ram every couple of turns. Just sending a single one up to my stack where I can capture it with Horses or Mammoths
 
Back
Top Bottom